apache cayenne - Data lost during SelectQuery -


example: s i've got object of class in relationship objects b, c , d.
if do:

selectquery query = new selectquery(a.class); query.addprefetch("b").setsemantics(prefetchtreenode.disjoint_prefetch_semantics); query.addprefetch("c").setsemantics(prefetchtreenode.disjoint_prefetch_semantics); list<?> res = context.performquery(query); 

then later:

selectquery query = new selectquery(a.class); query.addprefetch("d").setsemantics(prefetchtreenode.disjoint_prefetch_semantics); list<?> res = context.performquery(query); 

the relationships b , c invalidated (see datarowutils line 115).

i'm using cayenne 3.0.2 behavior seems identical in versions 3.1 , 3.2m1

is there way work around issue?

my idea override cayennedataobject in class function:

public void writepropertydirectly(string propname, object val) {     if(propname.equals("b") || propname.equals("c")) {         if(val instanceof fault && readpropertydirectly(propname) != null) {             return;         }     }     super.writepropertydirectly(propname, val); } 

is bad idea? seems work.
once loaded, don't want refresh b , c database @ all.
thanks

actually behavior expected. invalidation of to-one relationships done eagerly on select guarantee fresh view of them, , on premise should easy restore them memory cache when needed. simple fk relationship when call 'getb' or 'getc', object fault, , won't see db query.

an exception (an unexpected query when reading to-one) can happen few reasons. 1 eager garbage collection of objectcontext-local cache. prevent cayenne 3.1 , 3.2 provide ability specify retain strategy set 'cayenne.server.object_retain_strategy' property. can try 'hard' strategy , see if there's difference.

your above solution ok if know of scenarios accessed , refreshed. in general may cause hard-to-debug issues data refreshing.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -