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

Bug 372092

Summary: Exceptions using generics, embedded key and entity inheritance
Product: z_Archived Reporter: David Morer <david.morer>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: andrei.ilitchev, badr.elhouari, eclipselink.orm-inbox, guy.pelletier, odrotbohm, tom.ware
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Sources to reproduce
none
Test case to reproduice the bug
none
Proposed changes
none
Submitted patch to 2.4.1 and trunk none

Description David Morer CLA 2012-02-21 04:47:14 EST
Build Identifier: 2.3.2.v20111125-r10461

When I have a entity hierarchy with generics and embedded key, exceptions are raised when the persistence.xml file is processed.

1st error case (two level of parents) :
----------------------------------------
 *  
 *  Classes :
 *  
 *  @Embeddable
 *  public class MyPK
 *       private int key;
 *  
 *  @Entity
 *  public class MyEntity extends AbstractMiddleEntity<MyPK>
 *  
 *  @MappedSuperclass
 *  public abstract class AbstractMiddleEntity<PK> extends AbstractBaseEntity<PK>
 *  
 *  @MappedSuperclass
 *  public abstract class AbstractBaseEntity<PK>
 *      @EmbeddedId
 *      private PK id;
 *  

Exception raised :

java.lang.IndexOutOfBoundsException: Index: 8, Size: 8
 *   at java.util.ArrayList.RangeCheck(ArrayList.java:547)
 *   at java.util.ArrayList.get(ArrayList.java:322)
 *   at org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAsmFactory.resolveGenericTypes(MetadataAsmFactory.java:165)   at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.ClassAccessor.resolveGenericTypes(ClassAccessor.java:1611)
 *  at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.discoverMappedSuperclassesAndInheritanceParents(EntityAccessor.java:282)

2nd error case (one level of parent) :
-------------------------------------
 * 
 *  Classes :
 *  
 *  @Embeddable
 *  public class MyPK
 *       private int key;
 *       
 *  @Entity
 *  public class MyEntity extends AbstractBaseEntity<MyPK>
 *  
 *  @MappedSuperclass
 *  public abstract class AbstractBaseEntity<PK>
 *      @EmbeddedId
 *      private PK id;
 *

Exception raised :

org.eclipse.persistence.exceptions.ValidationException
Exception Description: The Entity class [class be.smals.eclipselinktestcase.AbstractBaseEntity] has an embedded attribute [id] of type [class java.lang.String] which is NOT an Embeddable class. Probable reason: missing @Embeddable or missing <embeddable> in orm.xml if metadata-complete = true
  at org.eclipse.persistence.exceptions.ValidationException.invalidEmbeddedAttribute(ValidationException.java:2417)
   at org.eclipse.persistence.internal.jpa.metadata.MetadataDescriptor.processMappingAccessors(MetadataDescriptor.java:1403)
   at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.ClassAccessor.processMappingAccessors(ClassAccessor.java:1482)





Reproducible: Always
Comment 1 David Morer CLA 2012-02-21 04:50:28 EST
Created attachment 211316 [details]
Sources to reproduce

Use the attached entity sources and persistence.xml files to reproduce
(package eclipselinktestcase.error1 for classes of error case 1 and eclipselinktestcase.error2 for classes of error case 2)
Comment 2 Tom Ware CLA 2012-03-15 13:39:30 EDT
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 Andrei Ilitchev CLA 2012-05-03 12:07:35 EDT
Cannot use "Sources to reproduce" to reproduce the problem because some referenced classes (be.smals.eclipselinktestcase.MyPK, be.smals.eclipselinktestcase.AbstractBaseEntity) are missing.

Please provide a simple persistence unit that reproduces the problem.
Comment 4 Andrei Ilitchev CLA 2012-05-30 10:45:06 EDT
Need more information.
Retargeting for 2.4 and closing.
Please reopen if more information is available.
Comment 5 Badr Elhouari CLA 2012-07-27 09:40:28 EDT
Created attachment 219268 [details]
Test case to reproduice the bug

Attached "testcase-372092.zip" a Test cases showing the bug.
Comment 6 Badr Elhouari CLA 2012-07-27 09:41:30 EDT
See the attachement "Test case to reproduice the bug"
Comment 7 Tom Ware CLA 2012-07-27 09:57:33 EDT
Reopening and retargetting so we can look at the new test case
Comment 8 Guy Pelletier CLA 2012-09-05 14:57:54 EDT
Created attachment 220745 [details]
Proposed changes
Comment 9 Guy Pelletier CLA 2012-09-06 13:06:12 EDT
Created attachment 220798 [details]
Submitted patch to 2.4.1 and trunk
Comment 10 Guy Pelletier CLA 2012-09-06 13:08:25 EDT
Changes have been submitted to 2.4.1 and trunk

Reviewed: James Sutherland.

Existing Inherited model using single letter generics modified to expose error (metadata processing). With fix in place, error goes away and all tests (FullRegressionTestSuite and ExtendedJPATests) pass successfully.
Comment 11 Guy Pelletier CLA 2012-09-06 13:09:16 EDT
*** Bug 336140 has been marked as a duplicate of this bug. ***
Comment 12 Eclipse Webmaster CLA 2022-06-09 10:20:16 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink