-->
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: property-ref bug?
PostPosted: Thu Oct 20, 2005 11:33 am 
Newbie

Joined: Wed Mar 16, 2005 5:06 am
Posts: 4
Hi,
I have some problems with property-refs and composite-ids. It's rather hard to explain, but I'll give it a shot :)

I have some class A with a composite-id and another object B with a many-to-one relationship to A. The table in the database where object B is persisted into, has a foreign key to a column of the table where objects of A are persisted into. That column is a property of A but not the primary key (= a composite-id).

Now, when initializing the context I'll get an ArrayOutOfBoundsException. When I remove the many-to-one tags with the property-refs from the mapping files, everything is fine.
I spent a lot of time in debugging the app but at some point (just before the exception) the debugger shows me the following information for the ArrayHelper.slice method:
strings=String[1] [0]="myclassA_.myPropertyInAForTheForeignKey"
begin=0
length=2

length=2 is a problem since my strings array has only length=1

so... what i guess is (didn't find the time yet to check the source code).... when using property-refs, Hibernate is initializing the lenght parameter to the number of properties in the primary key of object A.

Is this true? Has anyone had the same probem


Full stack trace of any exception that occurs:
Code:
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tlSessionFactory' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.ArrayIndexOutOfBoundsException: 1
java.lang.ArrayIndexOutOfBoundsException: 1
   at org.hibernate.util.ArrayHelper.slice(ArrayHelper.java:116)
   at org.hibernate.engine.JoinHelper.getAliasedLHSColumnNames(JoinHelper.java:63)
   at org.hibernate.engine.JoinHelper.getAliasedLHSColumnNames(JoinHelper.java:29)
   at org.hibernate.loader.JoinWalker.walkEntityAssociationTree(JoinWalker.java:336)
   at org.hibernate.loader.JoinWalker.walkEntityTree(JoinWalker.java:382)
   at org.hibernate.loader.JoinWalker.walkEntityTree(JoinWalker.java:247)
   at org.hibernate.loader.AbstractEntityJoinWalker.initAll(AbstractEntityJoinWalker.java:43)
   at org.hibernate.loader.entity.EntityJoinWalker.<init>(EntityJoinWalker.java:42)
   at org.hibernate.loader.entity.EntityLoader.<init>(EntityLoader.java:65)
   at org.hibernate.loader.entity.EntityLoader.<init>(EntityLoader.java:43)
   at org.hibernate.loader.entity.EntityLoader.<init>(EntityLoader.java:33)
   at org.hibernate.loader.entity.BatchingEntityLoader.createBatchingEntityLoader(BatchingEntityLoader.java:103)
   at org.hibernate.persister.entity.AbstractEntityPersister.createEntityLoader(AbstractEntityPersister.java:1611)
   at org.hibernate.persister.entity.AbstractEntityPersister.createEntityLoader(AbstractEntityPersister.java:1615)
   at org.hibernate.persister.entity.AbstractEntityPersister.createLoaders(AbstractEntityPersister.java:2660)
   at org.hibernate.persister.entity.AbstractEntityPersister.postInstantiate(AbstractEntityPersister.java:2653)
   at org.hibernate.persister.entity.SingleTableEntityPersister.postInstantiate(SingleTableEntityPersister.java:667)
   at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:279)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1127)
   at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:777)
   at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:703)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1058)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:363)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
   at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:269)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:318)
   at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:81)
   at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:66)
   at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:57)
   at WSMain.main(WSMain.java:30)


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.