[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.rt.eclipselink] merge does not copy basic mappings

Hi !

I have a problem with the merge since 1.1.0.r3634. The merge of the entityManager seems not to merge primitives attributes like long datatypes.
My source code looks like:


Entity entity = new Entity();
entity.setAId(1000);
..
Entity mergedEntity = em.merge(en);

Now the aId value of the mergedEntity is null. In the previous 1.0.1 release the primitive attributes were copied.

I looked at the source code of the ObjectBuilder.mergeIntoObject(Object target, boolean isUnInitialized, Object source, MergeManager mergeManager, boolean cascadeOnly, boolean isTargetCloneOfOriginal) method, that is part of the merge logic.

The source code looks a bit strange, because the isTargetCloneOfOriginal will doesn't take any effect. I think there is a problem in the boolean logic.

// PERF: Avoid synchronized enumerator as is concurrency bottleneck.
List mappings = this.descriptor.getMappings();
for (int index = 0; index < mappings.size(); index++) {
DatabaseMapping mapping = (DatabaseMapping)mappings.get(index);
if ((!cascadeOnly && !isTargetCloneOfOriginal) || (cascadeOnly && mapping.isForeignReferenceMapping())
|| (isTargetCloneOfOriginal && mapping.isCloningRequired())) {
mapping.mergeIntoObject(target, isUnInitialized, source, mergeManager);
} else if (isTargetCloneOfOriginal && mapping.isCloningRequired()) {
mapping.mergeIntoObject(target, isUnInitialized, source, mergeManager); } }


For me the second "else if" doesn't make sense, because it will never be reached. The same expression is in the first if statement, so this will be executed first. Perhaps there was forgotten to negate the isTargetCloneOfOriginal Boolean in the second if statement ?

Does anyboday agree with that?