-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Entity subclass with no attributes in subclass throws Excep
PostPosted: Thu Oct 31, 2013 8:46 am 
Newbie

Joined: Thu Oct 31, 2013 8:42 am
Posts: 1
I am using JPA 2.0 in my project.

I have and entity subclass
Code:
AppEntity extends AbstractEntity
.

Code:
AbstractEntity
is mapped with
Code:
@MappedSuperClass
, which has

@Id
@Column(name ="OBJID")
private String objId;

@Column
...(other entities)
along with getters and setters for objId and other attributes.
In my subclass AppEntity all the setter methods are overridden. subclass entity does not have any attributes (@Id / @Column mappings).

When I deploy this application using hibernate 4.2.6

I get ArrayIndexOutOfBoundException because org.hibernate.cfg.AnnotationBinder checks for at server startup

Code:
private static PropertyData getUniqueIdPropertyFromBaseClass(
            .....
    //Id properties are on top and there is only one
            return baseClassElements.get( 0 );
}

Since the subclass entity does not have any attributes get(0) throws Outofbound exception.

But the above code work in JPA 1.0 since hibernate 3.5 does not have above check.

In JPA 2.0 is there any restrictions on subclass entities? What logic behind checking the attributes in AnnotationBinder.java getUniqueIdPropertyFromBaseClass method.

https://github.com/hibernate/hibernate-orm/blob/4.2/hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java

Adding StackTrace for reference

Code:
AnnotationBinder.getUniqueIdPropertyFromBaseClass(PropertyData, PropertyData, AccessType, Mappings) line: 2576 
AnnotationBinder.isIdClassPkOfTheAssociatedEntity(ElementsToProcess, XClass, PropertyData, PropertyData, AccessType, Map<XClass,InheritanceState>, Mappings) line: 925 
AnnotationBinder.mapAsIdClass(Map<XClass,InheritanceState>, InheritanceState, PersistentClass, EntityBinder, PropertyHolder, ElementsToProcess, Set<String>, Mappings) line: 824   
AnnotationBinder.bindClass(XClass, Map<XClass,InheritanceState>, Mappings) line: 671   
Configuration$MetadataSourceQueue.processAnnotatedClassesQueue() line: 3533
Configuration$MetadataSourceQueue.processMetadata(List<MetadataSourceType>) line: 3487 
Configuration.secondPassCompile() line: 1376   
Configuration.buildSessionFactory(ServiceRegistry) line: 1777   
EntityManagerFactoryImpl.<init>(PersistenceUnitTransactionType, boolean, Class, Configuration, ServiceRegistry, String) line: 94   
Ejb3Configuration.buildEntityManagerFactory(BootstrapServiceRegistryBuilder) line: 920 
Ejb3Configuration.buildEntityManagerFactory() line: 904
HibernatePersistence.createContainerEntityManagerFactory(PersistenceUnitInfo, Map) line: 92
PersistenceUnitServiceImpl.createContainerEntityManagerFactory() line: 200 
PersistenceUnitServiceImpl.access$600(PersistenceUnitServiceImpl) line: 57 
PersistenceUnitServiceImpl$1.run() line: 99
ThreadPoolExecutor$Worker.runTask(Runnable) line: 886   
ThreadPoolExecutor$Worker.run() line: 908   
JBossThread(Thread).run() line: 619
JBossThread.run() line: 122


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.