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: