| Summary: | Exception thrown when using LAZY fetch on VIRTUAL mapping | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | z_Archived | Reporter: | Guy Pelletier <guy.pelletier> | ||||||
| Component: | Eclipselink | Assignee: | Nobody - feel free to take it <nobody> | ||||||
| Status: | RESOLVED FIXED | QA Contact: | |||||||
| Severity: | normal | ||||||||
| Priority: | P3 | CC: | eclipselink.orm-inbox | ||||||
| Version: | unspecified | ||||||||
| Target Milestone: | --- | ||||||||
| Hardware: | PC | ||||||||
| OS: | Windows XP | ||||||||
| Whiteboard: | |||||||||
| Attachments: |
|
||||||||
Created attachment 173464 [details]
Proposed changes
This patch includes the fix for this bug (which specifically is the one line change from MappingAccessor line 1812).
The other changes include the addition of automated testing of dynamic persistence through the jpa/eclipselink extensions interface. Through this testing a couple other issues were uncovered and addressed.
1 - correct processing of parent classes
2 - correct potential infinite loop when no attribute-type is specified for a virtual attribute.
Changes have been submitted to the 2.1.1 and 2.2 streams. Reviewed by: Chris Delahunt, Andrei Ilitchev Tests: New test suite (EntityMappingsDynamicAdvancedJUnitTestCase) was added and run as part of the extended jpa test suite. Created attachment 174303 [details]
Amendment to original fix
Original patch caused errors during the OSGi testing.
This is an amendment to the original fix.
Reviewed: Andrei Ilitchev, James Sutherland
Verified: Edwin Tang
Existing All existing JPA and extended JPA tests pass without error.
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |
The following exception is thrown when a lazy setting is used on a virtual mapping. Exception in thread "main" java.lang.IllegalStateException: Can't overwrite cause at java.lang.Throwable.initCause(Throwable.java:320) at org.eclipse.persistence.exceptions.DescriptorException.errorAccessingSetMethodOfEntity(DescriptorException.java:390) at org.eclipse.persistence.internal.indirection.WeavedObjectBasicIndirectionPolicy.getSetMethod(WeavedObjectBasicIndirectionPolicy.java:81) at org.eclipse.persistence.internal.indirection.WeavedObjectBasicIndirectionPolicy.setRealAttributeValueInObject(WeavedObjectBasicIndirectionPolicy.java:125) at org.eclipse.persistence.internal.indirection.WeavedObjectBasicIndirectionPolicy.updateValueInObject(WeavedObjectBasicIndirectionPolicy.java:93) at org.eclipse.persistence.internal.indirection.WeavedObjectBasicIndirectionPolicy.getRealAttributeValueFromObject(WeavedObjectBasicIndirectionPolicy.java:61) at org.eclipse.persistence.mappings.ObjectReferenceMapping.cascadeRegisterNewIfRequired(ObjectReferenceMapping.java:820) at org.eclipse.persistence.mappings.ObjectReferenceMapping.cascadeRegisterNewIfRequired(ObjectReferenceMapping.java:800) at org.eclipse.persistence.internal.descriptors.ObjectBuilder.cascadeRegisterNewForCreate(ObjectBuilder.java:1684) at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.registerNewObjectForPersist(UnitOfWorkImpl.java:4212) at org.eclipse.persistence.internal.jpa.EntityManagerImpl.persist(EntityManagerImpl.java:384) at example.Samples.persistAll(Samples.java:608) at example.Main.runDynamicJPATest(Main.java:97) at example.Main.main(Main.java:45) Note: an explicit access="VIRTUAL" will work around the issue, that is, <one-to-one name="address" fetch="LAZY" target-entity="Address" access="VIRTUAL"> The following though will cause an exception, <persistence-unit-metadata> <persistence-unit-defaults> <access>VIRTUAL</access> </persistence-unit-defaults> </persistence-unit-metadata> .... <one-to-one name="address" fetch="LAZY" target-entity="Address"> The error lies in: org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.MappingAccessor, usesPropertyAccess() method, line 1812 return hasAccessMethods() ? true : m_classAccessor.usesPropertyAccess(); Should be: return hasAccessMethods() ? !usesVirtualAccess() : m_classAccessor.usesPropertyAccess();