Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 367544 - using getID on an entity with EmbeddedId of derived primay keys will fail with IAE
Summary: using getID on an entity with EmbeddedId of derived primay keys will fail wit...
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P2 critical with 2 votes (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 392006 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-12-25 09:49 EST by elhanan Maayan CLA
Modified: 2022-06-09 10:04 EDT (History)
2 users (show)

See Also:


Attachments
attached test project (9.68 KB, application/octet-stream)
2011-12-25 09:50 EST, elhanan Maayan CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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