[hibernate-dev] AnnotationBinder throws ArrayIndexOutOfBoundException

Surendran D surendran.d at gmail.com
Wed Nov 6 08:07:42 EST 2013


Hello All,
I am implementing an Entity class as below


@Entity at Table(name=*"Employee"*)@IdClass(EmployeeEntityPK.*class*)*public
class *EmployeeEntity *extends *AbstractEntity {

//with no attributes only getter / setter


My AbstractEntity is a @MappedSuperClass with one @Id, at Column and other
@Columns defined

Also I have EmployeeEntityPK which has

@Id at Column(name = *"empId"*)*private *Integer *empId*;



When I deploy my application I get exception as

Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:547) [rt.jar:1.6.0_17]
at java.util.ArrayList.get(ArrayList.java:322) [rt.jar:1.6.0_17]
at
org.hibernate.cfg.AnnotationBinder.getUniqueIdPropertyFromBaseClass(AnnotationBinder.java:2576)
at
org.hibernate.cfg.AnnotationBinder.isIdClassPkOfTheAssociatedEntity(AnnotationBinder.java:925)
at
org.hibernate.cfg.AnnotationBinder.mapAsIdClass(AnnotationBinder.java:824)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:671)

AnnotationBinder.getUniqueIdPropertyFromBaseClass has a check as follows

*if *( elementsToProcess.getIdPropertyCount() == 1 ) {


which checks if my Entity has only one ID attribute, if so then
getsUniqueId from base class.

In my case I dont have any ID attribute in my EmployeeEntity so the I get
ArrayIndexOutOfBoundException.

Ideally in getUniqueIdPropertyFromBaseClass, baseClassElements should be
processed from AbstractEntity. Why its processing elements from
EmployeeEntity? Is this expected behaviour

I have added my source code to
https://github.com/surendrand/hibernate-entity-mapping for further reference


More information about the hibernate-dev mailing list