-->
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.  [ 4 posts ] 
Author Message
 Post subject: PropertyAccessException
PostPosted: Tue May 30, 2006 3:00 am 
Newbie

Joined: Tue May 30, 2006 2:49 am
Posts: 7
Hi

I am getting an exception in my Hibernate application. The database I am using is Mysql 5.1

Below is the partial stack trace of my exception.

he following exception was logged org.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.javacertificate.data.table.Exam.setField1
at org.hibernate.tuple.PojoEntityTuplizer.setPropertyValuesWithOptimizer(PojoEntityTuplizer.java:215)
at org.hibernate.tuple.PojoEntityTuplizer.setPropertyValues(PojoEntityTuplizer.java:185)
at org.hibernate.persister.entity.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:3232)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:129)

..............................

This is my database details for this field.

+---------------+--------------+------+
| Field | Type | Null |
+---------------+--------------+------+
| FIELD1 | bigint(20) | YES |
+---------------+--------------+------+

my mapping is

<property name="field1" type="long">
<column name="FIELD1" />
</property>

and following is my java class.

private long field1;

public long getField1() {
return field1;
}

public void setField1(long field1) {
this.field1 = field1;
}


How can I resolve this problem. Please help me


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 30, 2006 4:35 am 
Expert
Expert

Joined: Tue Dec 07, 2004 6:57 am
Posts: 285
Location: Nürnberg, Germany
Maybe the content of field1 in the database is null and you try to set null to a long. change the property type in your class to Long

_________________
Please don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 30, 2006 4:51 am 
Newbie

Joined: Mon May 29, 2006 12:57 am
Posts: 11
Location: india
Hi,

It is always advisable to use Object wrappers instead of primitive types in Hibernate classes.

More better way of doing it is to not write the hbm file urself but feeding the Db to an Hibernate-Supported IDE such as eclipse 3.0 and then get it to generate the hbm file for you.

Any comments??


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 30, 2006 7:39 am 
Newbie

Joined: Tue May 30, 2006 2:49 am
Posts: 7
Thanks for your help.

When I changed 'long' to 'java.lang.Long' it worked.


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