-->
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.  [ 6 posts ] 
Author Message
 Post subject: hibernate 3 problem with oracle null values
PostPosted: Thu Apr 06, 2006 6:27 am 
Newbie

Joined: Thu Apr 06, 2006 6:17 am
Posts: 2
Hi,
I map a Oracle NUMBER(1) column to a Java long field with

<property name="inactivityNotificationSend" type="long">
<column name="INACTIVITY_NOTIFICATION_SEND" />
</property>

If INACTIVITY_NOTIFICATION_SEND has a value in the database, everything works okay.

If the column is null in the database, the following execption appears.

org.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of Users.setInactivityNotificationSend
at org.hibernate.tuple.PojoTuplizer.setPropertyValuesWithOptimizer(PojoTuplizer.java:203)
at org.hibernate.tuple.PojoTuplizer.setPropertyValues(PojoTuplizer.java:173)

Is there a solution for this problem ?

Regards


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 06, 2006 8:07 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yes, use Long in your java class.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 06, 2006 8:09 am 
Pro
Pro

Joined: Mon Jan 24, 2005 5:39 am
Posts: 216
Location: Germany
hibernate tries to call you setter method with a Null as an argument:

setInactivityNotificationSend( long val );

This certainly does not work.
You can map it like this:

Code:
<property name="inactivityNotificationSend" type="java.lang.Long">
<column name="INACTIVITY_NOTIFICATION_SEND" />
</property>


Or you can write a property accessor which does it.
Look at org.hibernate.property.BasicPropertyAccessor.

Another possibility are UserTypes.

_________________
dont forget to rate !


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 06, 2006 8:15 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
fyi: long or java.lang.Long in the mapping files does not make any runtime difference - hibernate treat it equally. The only thing that can prevent it is if you property is actually a long and not a java.lang.Long.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: java.lang.Long does the job
PostPosted: Thu Apr 06, 2006 9:54 am 
Newbie

Joined: Thu Apr 06, 2006 6:17 am
Posts: 2
Thanks for the quick response.

Changing type="long" to type="java.lang.Long" fixed the problem.

By the way ; I used the myeclipse tool for Eclipse to generate the Hibernate mappings. After switching from "Hibernate types" to "Java types" everything works fine.

Regards


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 06, 2006 10:01 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yes, the myeclipse tools is using an (older) version of hibernate tools so this is the expected behavior.

_________________
Max
Don't forget to rate


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