> What semantically is "isFresh" attribute? Is it a some business logic
> attibute, or simple "autoset" variable, like timestamp etc.?

No its business logic. In fact it defines the view-rights for the
specific apples to the plums :-)

> If former, you cannot live without ApplePlum ObjEntity. Is the problem
> then in just setting its default value? Then you can simply set it at
> database level.

OK, I will try to change my mind on this one. I have hoped I could
somehow access the intermediate object.

THanks!

Cheers
Christian


> If the default value is dynamic, like timestamp, you can try intercept
> Cayenne's generating of queries:
> http://cayenne.apache.org/doc30/custom-batchquerybuilder-factory.html
>
> 2011/2/18 Christian Grobmeier <grobme...@gmail.com>:
>> Hello,
>>
>> I have the following scenario:
>>
>> Apple 1 -> n ApplePlum n : 1 Plum
>>
>> I want store an additional flag in ApplePlum (lets say isFresh = true/false
>>
>> How can I do this? I know I should not use flattened relations, but
>> they are so nice, I would like to keep them. At least it would lead to
>> the Method getApplePlum->getPlum which is not very neat.
>>
>> In order to do so I have thought I could create a custom method in my
>> Apple class, which copies some code from the _Apple class.
>>
>> Like this:
>>
>> public void addToAppleAsFreshPlum(Plum value) {
>>        String relName = "ApplePlum";
>>        if (value == null) {
>>            throw new NullPointerException("Attempt to add null target
>> DataObject.");
>>        }
>>
>>        willConnect(relName, value);
>>        Object holder = readProperty("ApplePlum");
>>
>> // Now I would like to get the object created by the holder:
>>        ((ApplePlum)holder).setFresh(true);
>>
>>        getObjectContext().propertyChanged(this, relName, null, value);
>>
>>        if (holder instanceof Collection) {
>>            ((Collection<Object>) holder).add(value);
>>        }
>>        else if (holder instanceof Map) {
>>            ((Map<Object, Object>) holder).put(getMapKey(relName,
>> value), value);
>>        }
>>
>>        setReverseRelationship(relName, value);
>>    }
>>
>> Of course this does not work. I wonder if there is another option for
>> me? Any ideas?
>>
>> Thanks in advance
>> Christian
>>
>
>
>
> --
> Andrey
>



-- 
http://www.grobmeier.de

Reply via email to