-->
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: Problem with yes_no property
PostPosted: Tue Aug 01, 2006 12:27 pm 
Newbie

Joined: Tue Aug 01, 2006 12:14 pm
Posts: 2
Hi all,

I have a column in a table which can have values Y, N or null. I tried to map it to a Hibernate yes_no type, but I am getting an exception when reading a null value. Does anybody know if it is possible for a yes_no property to be mapped by default to false in its corresponding POJO field when reading a null value for the column?

The exception is:

exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.vinoteca.concilia.Cuenta.setIndPrimaria; nested exception is org.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.vinoteca.concilia.Cuenta.setIndPrimaria

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 01, 2006 2:32 pm 
Newbie

Joined: Wed May 31, 2006 11:51 am
Posts: 3
First, I would recommend that you take the error's advice and set hibernate.cglib.use_reflection_optimizer=false so that you can see what the actual error is. Most likely the problem is that you have a not-null="false" field (since the database supports null on the column) mapped to a primitive boolean. If this is the case, you really only have two good options.
  • Switch your Java type to a java.lang.Boolean
  • or set all the null fields in the database to be false (which is what you are suggesting is your default) and set the database field to default to false with a not null restriction.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 08, 2006 2:49 pm 
Newbie

Joined: Wed Jul 26, 2006 8:00 am
Posts: 3
Location: Cary, NC
I just posted a NullSafeNumericUserType class for use with possible <NULL> numeric database column values. This could be enhanced to handle your needs.


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.