views:

21

answers:

1

I have a parent object with a version locking policy defined as follows:

VersionLockingPolicy lockingPolicy = new VersionLockingPolicy();
lockingPolicy.setIsCascaded(true);
lockingPolicy.setWriteLockFieldName("CacheId");
descriptor.setOptimisticLockingPolicy(lockingPolicy);

and with a child mapped as follows:

OneToManyMapping childMapping = new OneToManyMapping();
childMapping.setAttributeName("children");
childMapping.setReferenceClass(Child.class);
childMapping.dontUseIndirection();
childMapping.privateOwnedRelationship();
childMapping.useBatchReading();
childMapping.useCollectionClass(ArrayList.class);
childMapping.addTargetForeignKeyFieldName("Child.ParentId", "Parent.Id");
descriptor.addMapping(childMapping);

When I change a field on the child and update the child cacheId directly on the database, eclipselink queries do not pick up the change. When I then update the cacheId of the parent object, eclipselink queries do return the change to the child field.

I thought the cascaded version locking policy was supposed to cause the parent to update when any of its private owned child objects were updated (as defined by their version fields). Was I wrong about that, or is there likely something wrong somewhere else in my code?

A: 

I was wrong. There is nothing in the eclipselink code that will do what I wanted.

I think I will simply add a trigger to the child objects to update the parent cacheId.

ILMTitan