Community
Participate
Working Groups
Under certain circumstances eclipselink throws an IllegalStateException while copying an object graph with cyclic dependencies. In the folowing example A, B and C are some entity classes. A has a reference to a collection of entites of type B (B_1), B has a reference to an entity of type C and C has references to a collection of entites of type B (B_2). So if an entity of type B is part B_1 it is also part of B_2: A -> B_1 -> C -> B_2 The exception occurrs, if the entites from B_2 are copied with a reduced AttributeGroup and the entities from B_1 are copied with a full AttributeGroup. In that case the different AttributeGroups are not merge in ObjectBuilder.copyObject (ObjectBuilder line 2700-2711). Internal Exception: java.lang.reflect.InvocationTargetException Target Invocation Exception: java.lang.IllegalStateException: Cannot get unfetched attribute [a] from detached object B. Mapping: org.eclipse.persistence.mappings.ManyToOneMapping Descriptor: RelationalDescriptor(B --> [DatabaseTable(B)]) at org.eclipse.persistence.exceptions.DescriptorException.targetInvocationWhileSettingValueThruMethodAccessor(DescriptorException.java:1768) at org.eclipse.persistence.internal.descriptors.MethodAttributeAccessor.setAttributeValueInObject(MethodAttributeAccessor.java:275) at org.eclipse.persistence.internal.descriptors.MethodAttributeAccessor.setAttributeValueInObject(MethodAttributeAccessor.java:226) at org.eclipse.persistence.mappings.DatabaseMapping.setAttributeValueInObject(DatabaseMapping.java:1652) at org.eclipse.persistence.internal.indirection.BasicIndirectionPolicy.reset(BasicIndirectionPolicy.java:273) at org.eclipse.persistence.mappings.ObjectReferenceMapping.buildCopy(ObjectReferenceMapping.java:142) at org.eclipse.persistence.internal.descriptors.ObjectBuilder.copyObject(ObjectBuilder.java:2771) at org.eclipse.persistence.internal.sessions.AbstractSession.copyInternal(AbstractSession.java:1141) at org.eclipse.persistence.mappings.CollectionMapping.copyElement(CollectionMapping.java:286) at org.eclipse.persistence.mappings.CollectionMapping.buildCopy(CollectionMapping.java:265) at org.eclipse.persistence.internal.descriptors.ObjectBuilder.copyObject(ObjectBuilder.java:2771) at org.eclipse.persistence.internal.sessions.AbstractSession.copyInternal(AbstractSession.java:1141) at org.eclipse.persistence.mappings.CollectionMapping.copyElement(CollectionMapping.java:286) at org.eclipse.persistence.mappings.CollectionMapping.buildCopy(CollectionMapping.java:265) at org.eclipse.persistence.internal.descriptors.ObjectBuilder.copyObject(ObjectBuilder.java:2771) at org.eclipse.persistence.internal.sessions.AbstractSession.copyInternal(AbstractSession.java:1141) at org.eclipse.persistence.internal.sessions.AbstractSession.copy(AbstractSession.java:1119) at org.eclipse.persistence.internal.jpa.EntityManagerImpl.copy(EntityManagerImpl.java:2834)
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink