cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nikita Timofeev (JIRA)" <>
Subject [jira] [Commented] (CAY-2210) Query cache: incorrect cache key for queries with custom value objects
Date Fri, 31 Mar 2017 13:55:42 GMT


Nikita Timofeev commented on CAY-2210:

To solve this issue (and also make it easier to support custom ValueObjects ) new interface
is introduced {{ValueObjectType<V, T>}}, 
that should define rule for translating this objects into cache string. 
It is also responsible for serializing custom objects into a value that can be stored in the
DB (i.e. recognized by {{ExtendedTypes}}).

To register this types {{ServerModule.contributeValueObjectTypes(Binder)}} method should be

Here is code for {{LocalDate}} type (as implemented in {{cayenne-java8}} module):
public class LocalDateValueType implements ValueObjectType<LocalDate, Date> {

    public Class<Date> getTargetType() {
        return Date.class;

    public Class<LocalDate> getValueType() {
        return LocalDate.class;

    public LocalDate toJavaObject(Date value) {
        return value.toLocalDate();

    public Date fromJavaObject(LocalDate object) {
        return Date.valueOf(object);

    public String toCacheKey(LocalDate object) {
        return object.toString();

> Query cache: incorrect cache key for queries with custom value objects
> ----------------------------------------------------------------------
>                 Key: CAY-2210
>                 URL:
>             Project: Cayenne
>          Issue Type: Bug
>            Reporter: Andrus Adamchik
>            Assignee: Nikita Timofeev
>             Fix For: 4.0.M6
> If we map any ObjAttributes of an entity to custom value types that do not have a repeatable
toString, our cache keys will stop working if these types are used as qualifier parameters.

> Per CAY-2050 ExtendedTypes now support unique toString. Perhaps we use this or a similar
method for cache key generation (actually can't use ExtendedType.toString directly for the
types that are trimming their display values, like arrays and Strings, so we'll need to amend
that API to use for cache keys).

This message was sent by Atlassian JIRA

View raw message