-->
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: Help with mapping sql type float8 and java int.
PostPosted: Thu Mar 04, 2004 11:56 am 
Newbie

Joined: Thu Mar 04, 2004 11:51 am
Posts: 1
Location: Trondheim, Norway
INFO: Hibernate 2.1.2
PostgreSQL: 7.3.4

Hi,

I'm having trouble with a db column that is of type float8 that can contain null.
The problem is described in the faq *) and happens when running a Criteria.list() request.

The question is; how do I use a Hibernate custom type to do as described in the FAQ ? I've not found any .bhm.xml and/or .java examples
that illustrates this.

*)
From the Hibernate Users FAQ - Common Problems

Hibernate throws a PropertyAccessException or NullPointerException when I load or query an object!
If your object has a primitive-type property mapped to a nullable database column then you will need to use a Hibernate custom type to assign a sensible default (primitive) value for the case of a null column value. A better solution is usually to use a wrapper type for the Java property.


With regards,
Ken A. Rederg


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 04, 2004 3:03 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Um, define the java type as Integer instead of int, and map the property as type="java.lang.Integer"...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 20, 2004 2:42 pm 
Newbie

Joined: Tue Jul 20, 2004 2:35 pm
Posts: 6
I have a similar issue. We don't want to use "primitive Objects" like Double and Integer etc and at the same time we dont control the schema either.
Can we specify rules when mapping to handle such scenario. Like replace this by null by some default value.


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.