Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

PropertyAccessException

 
MInu
Ranch Hand
Posts: 517
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

When i am using one- to- one assosiation in my application the following error occured,

org.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.Student.setStudentDetails
at org.hibernate.tuple.PojoTuplizer.setPropertyValuesWithOptimizer(PojoTuplizer.java:198)
at org.hibernate.tuple.PojoTuplizer.setPropertyValues(PojoTuplizer.java:168)
at org.hibernate.persister.entity.BasicEntityPersister.setPropertyValues(BasicEntityPersister.java:2922)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:113)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:492)
at org.hibernate.loader.Loader.doQuery(Loader.java:411)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:206)
at org.hibernate.loader.Loader.doList(Loader.java:1515)
at org.hibernate.loader.Loader.list(Loader.java:1498)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:111)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1253)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:299)
at com.RunHibernate.studentList(RunHibernate.java:73)
at com.RunHibernate.main(RunHibernate.java:48)
Caused by: net.sf.cglib.beans.BulkBeanException
at com.Student$$BulkBeanByCGLIB$$d3ebec89.setPropertyValues(<generated>
at org.hibernate.tuple.PojoTuplizer.setPropertyValuesWithOptimizer(PojoTuplizer.java:195)
... 13 more
Caused by: java.lang.ClassCastException
... 15 more

In my hbm.xml file i wrote

<one-to-one name="studentDetails" class="com.Student" lazy="false" foreign-key="stu_id"/>

And my POJO as follows
public class Student
{
private int stu_id;
private int class_id;
private String class_Name;
private String class_Div;
private String Meduim;
private StudentDetails studentDetails;
}
public class StudentDetails
{
private int stu_id;
private String stu_name;
private String roll_no;
private String stu_address;
private String stu_father;
private String stu_street;
private String stu_pin;
}

CAN ANYBODY HELP ME ???
 
Otilia Marcu
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you solved this issue? I get the same error and it's urgent to get things running! Give me some clue, pls.

Chamade
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The source of minu su's original problem was a ClassCastException. The Student POJO defines a property of studentDetails which is of the type StudentDetails, but the mapping defines this property to be of the type Student.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic