-->
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.  [ 3 posts ] 
Author Message
 Post subject: List collection problem: CGLIB exception
PostPosted: Fri May 13, 2005 3:07 am 
Beginner
Beginner

Joined: Thu Mar 03, 2005 9:19 pm
Posts: 22
Hibernate version:
3.0

I am having an issue using List collection:

Class Junk{
...

ArrayList junkUsers = new ArrayList();
/**
* @return Returns the junkUsers.
*
* @hibernate.list
* lazy="false"
* table="junkuser"
* cascade="all-delete-orphan"
* @hibernate.collection-key
* column="id"
* @hibernate.collection-index
* column="position"
* @hibernate.collection-element
* column="userName"
* type="string"
* length="256"
*/
public ArrayList getJunkUsers() {
return junkUsers;
}
public void addJunkUser(String junkUser) {
this.junkUsers.add(junkUser);
}
public void setJunkUsers(ArrayList junkUsers) {
this.junkUsers = junkUsers;
}
...
}

I am trying to persist a Junk instance:

junk.addJunkUser("testUser");
dao.saveJunk(junk);

I am getting this error when doing unit test:

[junit] Testcase: testGetJunk(com.amazand.dao.JunkDAOTest): Caused an ERROR
[junit] exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.amazand.model.Junk.setJunkUsers; nested exception is org.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.amazand.model.Junk.setJunkUsers
[junit] org.springframework.orm.hibernate3.HibernateSystemException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.amazand.model.Junk.setJunkUsers; nested exception is org.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.amazand.model.Junk.setJunkUsers
[junit] org.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.amazand.model.Junk.setJunkUsers
[junit] at org.hibernate.tuple.PojoTuplizer.setPropertyValuesWithOptimizer(PojoTuplizer.java:203)
[junit] at org.hibernate.tuple.PojoTuplizer.setPropertyValues(PojoTuplizer.java:173)
[junit] at org.hibernate.persister.entity.BasicEntityPersister.setPropertyValues(BasicEntityPersister.java:2900)
[junit] at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:113)
[junit] at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:506)
[junit] at org.hibernate.loader.Loader.doQuery(Loader.java:415)
[junit] at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:210)
[junit] at org.hibernate.loader.Loader.loadEntity(Loader.java:1307)
[junit] at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:141)
[junit] at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:126)
[junit] at org.hibernate.persister.entity.BasicEntityPersister.load(BasicEntityPersister.java:2461)
[junit] at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:392)
[junit] at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:373)
[junit] at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:155)
[junit] at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:209)
[junit] at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:121)
[junit] at org.hibernate.impl.SessionImpl.get(SessionImpl.java:577)
[junit] at org.hibernate.impl.SessionImpl.get(SessionImpl.java:572)
[junit] at org.springframework.orm.hibernate3.HibernateTemplate$1.doInHibernate(HibernateTemplate.java:386)
[junit] at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:310)
[junit] at org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.java:380)
[junit] at org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.java:375)
[junit] at com.amazand.dao.hibernate.JunkDAOHibernate.getJunk(JunkDAOHibernate.java:41)
[junit] at com.amazand.dao.JunkDAOTest.testGetJunk(JunkDAOTest.java:53)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[junit] Caused by: net.sf.cglib.beans.BulkBeanException: org.hibernate.collection.PersistentList
[junit] at com.amazand.model.Junk$$BulkBeanByCGLIB$$82ec866e.setPropertyValues(<generated>)
[junit] at org.hibernate.tuple.PojoTuplizer.setPropertyValuesWithOptimizer(PojoTuplizer.java:200)
[junit] ... 38 more
[junit] Caused by: java.lang.ClassCastException: org.hibernate.collection.PersistentList
[junit] ... 40 more


Any idea? I set hibernate.cglib.use_reflection_optimizer=false but it did not give me more info.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 13, 2005 4:42 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Please read the reference guide. You must use a List in your getter setter dignature, not an ArrayList

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 13, 2005 7:50 am 
Beginner
Beginner

Joined: Thu Mar 03, 2005 9:19 pm
Posts: 22
Thanks. That's the reason.


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

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.