java - Eclipselink updates entity field when it is not changed -
i have 2 entities @onetomany (entity1) & @manytoone (entity2) bidirectional relation. in @onetomany relation have @cascading{cascade.all}. when change boolean property false, of entity @manytoone relation true , false within transaction or method, causes database trigger update query set entity's boolean false, seems wrong because false , @ commit time still false. i'm using eclipselink 2.5.1 jpa implementation. can causes?
update(integer entityid) { tx.begin(); entity1 entity1 = findentity(entityid); for(entity2 entity2 : entity1.getentity2list()) { entity2.setbooleanproperty(boolean.true);//which false, set true programmatic purpose ; ... entity2.setbooleanproperty(boolean.false);//at point db updates boolean property false } em.merge(entity1); tx.commit(); }
so i'd guess eclipselink takes first change marking field "changed". there no logic save original value , consequently check if reset original value (it significant overhead have save original values of fields).
hence when merge object field marked having been changed whilst detached. consequently gets updated in datastore. can't it's "wrong", since trade-off between storing original values of fields , adding checks, against single datastore update statement (and user has in hands desired behaviour updating field when going merged value).
Comments
Post a Comment