-->
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.  [ 9 posts ] 
Author Message
 Post subject: DoubleType and NaN
PostPosted: Wed Feb 11, 2004 5:36 am 
Beginner
Beginner

Joined: Tue Nov 11, 2003 4:49 am
Posts: 47
Location: Florence, Italy
I'm saving result from a calculation. Sometime the result can be the Double NaN (perfectly legal in our domain problem), but then, when Hibernate try to write it to the database, the call.
Code:
st.setDouble( index, ( (Double) value ).doubleValue() );

generate an IllegalArgumentException. Do you think that DoubleType should check for this or is the domain code that must take care of NaN ?
Ciao.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 11, 2004 5:52 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
hmm....what is the exact exception ?

And can jdbc databases store NaN per default ? (I don't know actually ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 11, 2004 6:10 am 
Senior
Senior

Joined: Tue Oct 21, 2003 8:15 am
Posts: 186
Almost no jdbc drivers handle NaN properly. Check against NaN and convert to null as required (Hibernate should do this)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 11, 2004 6:14 am 
Beginner
Beginner

Joined: Tue Nov 11, 2003 4:49 am
Posts: 47
Location: Florence, Italy
You are COMPLETELY rigth, the problem is inside the Oracle Jdbc driver.
But the fact is that Hibernate write on relational DB, so, I think, should check for data not compatible with relational model.
The exact exception is inside the Oracle JDBC driver, do you want the Exception log ?
Ciao.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 11, 2004 6:26 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
don't need the exception.

The problem with making hibernate handle NaN => null is that

would make Double and double behave differently!

With Double null in db would be null in java
with double null in db would be NaN ....which is not nice.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 11, 2004 6:32 am 
Beginner
Beginner

Joined: Tue Nov 11, 2003 4:49 am
Posts: 47
Location: Florence, Italy
Sorry, but I can't follow you Max. NaN is a double, not a Double, is exactly the double representing 0x7ff8000000000000L.
So DoubleType can have the same, identical, problem, with primitive double containing NaN.
Sure putting NaN ==> null is not a solution.
Ciao.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 11, 2004 7:07 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
Yes - but a Double also can be set to a NaN....

..but if you can tell me how to store 0x7ff8000000000000L (or more precise Double.NaN) into a db - then we can make hibernate do it.....

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 11, 2004 7:24 am 
Beginner
Beginner

Joined: Tue Nov 11, 2003 4:49 am
Posts: 47
Location: Florence, Italy
Thinking about the problem........it's not as easy-solvable as I thougth initially.
The question is "Should Hibernate allow something like a Dialect to manage this kind of numbers?"
Infact, as Max let me notice, AFAIK there is not a Relational approach to this problem, so every mapping should be Database dependent, or signal an error from Hibernate (or also from JDBC driver, if you prefere).
What do you think ?

_________________
Ciao.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 11, 2004 7:58 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I would suggest a UserType for such feature.

_________________
Emmanuel


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