Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 367544

Summary: using getID on an entity with EmbeddedId of derived primay keys will fail with IAE
Product: z_Archived Reporter: elhanan Maayan <elh.mailgate>
Component: EclipselinkAssignee: Project Inbox <eclipselink.orm-inbox>
Status: NEW --- QA Contact:
Severity: critical    
Priority: P2 CC: akochnev, tom.ware
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
attached test project none

Description elhanan Maayan CLA 2011-12-25 09:49:24 EST
assume you have book which has many to one  publisher  and many to one author

BookPK is the embeddedId which has to 2 int columns 

if i try the following:
 EntityManagerFactory emf = Persistence.createEntityManagerFactory("elTest");
    EntityManager em = emf.createEntityManager();
    Metamodel metamodel = em.getMetamodel();
    EntityType<Book> entity = metamodel.entity(Book.class);
    Type<?> idType = entity.getIdType();
    Class<?> javaType = idType.getJavaType();    
    SingularAttribute<? super Book, ?> id = entity.getId(javaType); // problem here!
    org.junit.Assert.assertNotNull(id);
   
   i will always get IAE exception no matter what java type i send in.
   this is becuase the loop inside getId tries to compare ALL idAttributes so if passes the first one, the next one will fail, the only thing that works is sending in a null or Object class
   
   this DOES work in hibernate, and an embedded id that is not mapped to derived keys
Comment 1 elhanan Maayan CLA 2011-12-25 09:50:06 EST
Created attachment 208798 [details]
attached test project
Comment 2 Tom Ware CLA 2012-02-09 10:27:11 EST
Setting target and priority.  See the following page for the meanings of these fields:

http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines

Community: Please vote for this bug if it is important to you.  Votes are one of the main criteria we use to determine which bugs to fix next.
Comment 3 Chris Delahunt CLA 2012-10-23 14:20:50 EDT
*** Bug 392006 has been marked as a duplicate of this bug. ***
Comment 4 Eclipse Webmaster CLA 2022-06-09 10:04:59 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink