-->
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.  [ 3 posts ] 
Author Message
 Post subject: exception setting property value with CGLIB
PostPosted: Wed Jun 09, 2004 12:38 pm 
Newbie

Joined: Thu Jun 03, 2004 10:29 am
Posts: 13
While using version 2.1.3

I have a POJO that has an int property with the proper setters and getters:

int riskScore

The field in the DB is nullable so I mapped it as such:

<property name="riskScore" column="risk_score" not-null="false" update="false" type="java.lang.Integer"/>

I tried to get more information by making this setting in hibernate.cfg.xml:

<property name="hibernate.cglib.use_reflection_optimizer">false</property>

When I do all of this I get an exception:

net.sf.hibernate.PropertyAccessException: exception setting property value with
CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter
of com.tracfone.max.Alarm.setRiskScore
at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(
AbstractEntityPersister.java:212)
at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:2
199)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:240)


etc....

If I change the property type to Integer in the POJO, everything works out correctly. But I don't want to adjust all of the current code to change the type of the property from int to Integer.

I thought I could map a nullable primative by specifying it's coresponding object type in the mapping XML. Am I wrong? Where do I find a way to solve this issue?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 09, 2004 8:26 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Use a custom UserType to convert the null values to some other value. primitive types can't be null.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 15, 2004 4:38 pm 
Newbie

Joined: Tue Jun 15, 2004 4:34 pm
Posts: 1
change your getter and setter for that property to String, and
<property
name="batchId"
type="java.lang.String"
column="batch_id"
length="4"
/>


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