File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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


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(
at org.hibernate.tuple.PojoTuplizer.setPropertyValues(
at org.hibernate.persister.entity.BasicEntityPersister.setPropertyValues(
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(
at org.hibernate.loader.Loader.doQuery(
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(
at org.hibernate.loader.Loader.doList(
at org.hibernate.loader.Loader.list(
at org.hibernate.loader.criteria.CriteriaLoader.list(
at org.hibernate.impl.SessionImpl.list(
at org.hibernate.impl.CriteriaImpl.list(
at com.RunHibernate.studentList(
at com.RunHibernate.main(
Caused by: net.sf.cglib.beans.BulkBeanException
at com.Student$$BulkBeanByCGLIB$$d3ebec89.setPropertyValues(<generated>
at org.hibernate.tuple.PojoTuplizer.setPropertyValuesWithOptimizer(
... 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;


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

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.

Paul Sturrock

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
I agree. Here's the link:
subject: PropertyAccessException
It's not a secret anymore!