-->
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.  [ 4 posts ] 
Author Message
 Post subject: Error when persisting Double.MAX_VALUE with Hibernate
PostPosted: Tue Oct 18, 2016 5:40 am 
Newbie

Joined: Tue Oct 18, 2016 5:34 am
Posts: 2
Hi All,
here is the confusioning Problem I am facing now: in the code I have an Java object TestObject with field Double value, I tried to set up Double.MAX_VALUE to the field then persist the object to Oracle DB with Hibernate.

How ever I got the exception :
2016-10-18 11:20:00,159 WARN [main] org.hibernate.engine.jdbc.spi.SqlExceptionHelper: SQL Error: 17001, SQLState: 99999
2016-10-18 11:20:00,160 ERROR [main] org.hibernate.engine.jdbc.spi.SqlExceptionHelper: Interner Fehler: Overflow Exception trying to bind -1.7976931348623157E+308


After that I tried to change the type in entity object instead of Double to Decimal, but still get the same exception.
In the Oracle DB the field is with Type: BINARY_DOUBLE

Any suggestion on this will be welcomed!

thanks!


Top
 Profile  
 
 Post subject: Re: Error when persist Double.MAX_VALUE through Hibernate
PostPosted: Tue Oct 18, 2016 7:03 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1638
Location: Romania
The maximum allowed value in a BINARY_DOUBLE is:

Code:
1.79769313486231E+308


while the Java Double.MAX_VALUE seems to be higher:

Code:
1.7976931348623157E+308


Now, what business use case do you have that you need to store such a high value?

_________________
If you liked my answer, you are going to love my High-Performance Java Persistence book and my blog as well.


Top
 Profile  
 
 Post subject: Re: Error when persisting Double.MAX_VALUE with Hibernate
PostPosted: Tue Oct 18, 2016 7:19 am 
Newbie

Joined: Tue Oct 18, 2016 5:34 am
Posts: 2
thanks for your quick reply, but I have an unlucky try: still have the exception. and further more I reduce the value to 1.7E+308 still get this exception.


Top
 Profile  
 
 Post subject: Re: Error when persisting Double.MAX_VALUE with Hibernate
PostPosted: Tue Oct 18, 2016 7:57 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1638
Location: Romania
Make sure that the database column type is `BINARY_DOUBLE`. Open an Oracle SQL console and check the maximum value that you can set using plain SQL.

_________________
If you liked my answer, you are going to love my High-Performance Java Persistence book and my blog as well.


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