-->
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.  [ 2 posts ] 
Author Message
 Post subject: Hibernate PropertyAccessException in m:n Mapping Class
PostPosted: Sun Nov 06, 2005 6:11 am 
Newbie

Joined: Sun May 01, 2005 12:04 pm
Posts: 6
Location: Munich, Germany
Hi there,

I tried everything from criteri to sql queries but still i get this exception when I try to extract ALL objects from a m:n mapping table.

I got the class Product and Accessory, they are m:n combined in ProductAccessory with the additional property amount (int).

Caused by: org.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of de.flavor.suevia.web.om.ProductAccessory.setAmount
at org.hibernate.tuple.PojoTuplizer.setPropertyValuesWithOptimizer(PojoTuplizer.java:203)
at org.hibernate.tuple.PojoTuplizer.setPropertyValues(PojoTuplizer.java:173)
at org.hibernate.persister.entity.BasicEntityPersister.setPropertyValues(BasicEntityPersister.java:2919)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:113)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:530)
at org.hibernate.loader.Loader.doQuery(Loader.java:436)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
at org.hibernate.loader.Loader.doList(Loader.java:1593)
at org.hibernate.loader.Loader.list(Loader.java:1577)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.jav

Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

This is my query:

Session session = HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();

List elements = session.createCriteria(ProductAccessory.class)
.list();
log.debug("ProductAccessories found: " + elements.size());

tx.commit();
HibernateUtil.closeSession();

Hibernate version: 3.0.5

Mapping documents:
this is for ProductAccessory:

<hibernate-mapping
package="de.flavor.suevia.web.om">

<class name="ProductAccessory" table="ProductAccessory">

<id name="id" type="string" unsaved-value="null" >
<column name="productAccessoryId" sql-type="char(32)" not-null="true"/>
<generator class="uuid.hex"/>
</id>

<property name="amount"/>

<many-to-one name="product" column="productId" not-null="true"/>
<many-to-one name="accessory" column="accessoryId" not-null="true"/>

</class>


</hibernate-mapping>



Code between sessionFactory.openSession() and session.close():
List elements = session.createCriteria(ProductAccessory.class)
.list();
log.debug("ProductAccessories found: " + elements.size());

Full stack trace of any exception that occurs:
I am running in in a web container tomcat5.5.7 with myfaces 1.1

Caused by: javax.faces.el.EvaluationException: Exception while invoking expression #{adminProductBean.editProduct}
at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:153)
at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63)
... 24 more
Caused by: org.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of de.flavor.suevia.web.om.ProductAccessory.setAmount
at org.hibernate.tuple.PojoTuplizer.setPropertyValuesWithOptimizer(PojoTuplizer.java:203)
at org.hibernate.tuple.PojoTuplizer.setPropertyValues(PojoTuplizer.java:173)
at org.hibernate.persister.entity.BasicEntityPersister.setPropertyValues(BasicEntityPersister.java:2919)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:113)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:530)
at org.hibernate.loader.Loader.doQuery(Loader.java:436)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
at org.hibernate.loader.Loader.doList(Loader.java:1593)
at org.hibernate.loader.Loader.list(Loader.java:1577)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:111)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1322)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:300)
at de.flavor.suevia.web.delegate.DatabaseDelegateImpl.getAllProductAccessoriesForProduct(Unknown Source)
at de.flavor.suevia.web.beans.admin.ProductBean.editProduct(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:129)
... 25 more
Caused by: net.sf.cglib.beans.BulkBeanException
at de.flavor.suevia.web.om.ProductAccessory$$BulkBeanByCGLIB$$e04a5752.setPropertyValues(<generated>)
at org.hibernate.tuple.PojoTuplizer.setPropertyValuesWithOptimizer(PojoTuplizer.java:200)
... 43 more
Caused by: java.lang.NullPointerException
... 45 more

Name and version of the database you are using:
mysql 4.1.11

The generated SQL (show_sql=true):


Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 06, 2005 6:55 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
did you read the exception and tried to do what the message suggests ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.