| Summary: | Extend the policy to support relationships to non-primary key columns in derived identies | ||||||
|---|---|---|---|---|---|---|---|
| Product: | z_Archived | Reporter: | Karsten Wutzke <kwutzke> | ||||
| Component: | Eclipselink | Assignee: | Nobody - feel free to take it <nobody> | ||||
| Status: | NEW --- | QA Contact: | |||||
| Severity: | enhancement | ||||||
| Priority: | P3 | ||||||
| Version: | unspecified | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | All | ||||||
| OS: | All | ||||||
| URL: | http://www.eclipse.org/forums/index.php/m/669746/ | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
|
Description
Karsten Wutzke
The stack trace when using
EntityManagerFactory emf = Persistence.createEntityManagerFactory("geoareas");
em = emf.createEntityManager();
System.out.println();
System.out.println("Entity manager created!");
System.out.println();
Country co = em.find(Country.class, 1);
System.out.println("Loaded country = " + co);
Zip zi = em.find(Zip.class, new ZipId("DE", "64846"));
System.out.println("Loaded zip = " + zi);
is:
Loaded country = tld.geoareas.model.Country@60cbf9bd[id=1,isoCode=AF]
Exception in thread "main" java.lang.IllegalArgumentException: You have provided an instance of an incorrect PK class for this find operation. Class expected : class java.lang.Integer, Class received : class java.lang.String.
at org.eclipse.persistence.internal.jpa.CMP3Policy.createPrimaryKeyFromId(CMP3Policy.java:239)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.findInternal(EntityManagerImpl.java:699)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.find(EntityManagerImpl.java:621)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.find(EntityManagerImpl.java:500)
at tld.geoareas.Main.main(Main.java:38)
Tested with EL 2.2.0 nightly (R8626) and EL 2.3.0 M7 (R9282) with the same exception. (2.3.0 not yet selectable from dropdown) Created attachment 195661 [details]
Test case: JavaSE, EclipseLink 2.3.0 M7, HSQLDB 2
eclipselink.jar and javax.persistence_2.0.3.v201010191057.jar must be copied to the project's lib dir manually.
For more information about relationships to non-PK columns see: http://www.kawoolutions.com/Technology/JPA,_Hibernate,_and_Co./Relationships_to_Non-Primary_Key_Columns The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |