aspose file tools*
The moose likes Object Relational Mapping and the fly likes PropertyAccessException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "PropertyAccessException" Watch "PropertyAccessException" New topic
Author

PropertyAccessException

MInu
Ranch Hand

Joined: Oct 09, 2003
Posts: 517
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 ???


God Gave Me Nothing I Wanted<br />He Gave Me Everything I Needed<br /> - Swami Vivekananda
Otilia Marcu
Greenhorn

Joined: Jan 19, 2006
Posts: 4
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

Joined: Apr 14, 2004
Posts: 10336

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.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: PropertyAccessException