-->
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: Hibernate, Oracle 9i: decimal places get lost upon updates
PostPosted: Thu Nov 17, 2005 5:57 pm 
Beginner
Beginner

Joined: Tue Aug 17, 2004 5:06 am
Posts: 46
Hibernate version: 2.1.6

Mapping documents:
<property
name="authorizedAmount"
type="java.lang.Float"
update="true"
insert="true"
access="property"
>
<column
name="authorizedAmount"
not-null="true"
sql-type="NUMBER(15,3)"
/>

Name and version of the database you are using: Oracle 9i, thin driver

The generated SQL (show_sql=true): update fin.xxx_credit_Limit set dbversion=?, maturity=?, maturityEnd=?, text=?, remarks=?, authorizedAmount=?, fk_limit_info=?, fk_xxx_cg_member=? where id=? and dbversion=?

Debug level Hibernate log excerpt:
22:49:46,880 DEBUG EntityPersister:648 - Updating entity: [com.xxx.fi.model.hibernate.XXXCorporateGroupMemberCreditLimitHPB#11000188]
22:49:46,880 DEBUG EntityPersister:649 - Existing version: 7 -> New version: 8
22:49:46,880 DEBUG BatcherImpl:200 - about to open: 0 open PreparedStatements, 0 open ResultSets
22:49:46,900 DEBUG SQL:226 - update fin.xxx_credit_Limit set dbversion=?, maturity=?, maturityEnd=?, text=?, remarks=?, authorizedAmount=?, fk_limit_info=?, fk_xxx_cg_member=? where id=? and dbversion=?
Hibernate: update fin.xxx_credit_Limit set dbversion=?, maturity=?, maturityEnd=?, text=?, remarks=?, authorizedAmount=?, fk_limit_info=?, fk_xxx_cg_member=? where id=? and dbversion=?
22:49:46,900 DEBUG BatcherImpl:249 - preparing statement
22:49:46,900 DEBUG EntityPersister:388 - Dehydrating entity: [com.xxx.fi.model.hibernate.XXXCorporateGroupMemberCreditLimitHPB#11000188]
22:49:46,900 DEBUG IntegerType:46 - binding '8' to parameter: 1
22:49:46,900 DEBUG StringType:46 - binding '2006' to parameter: 2
22:49:46,910 DEBUG StringType:46 - binding '2008' to parameter: 3
22:49:46,910 DEBUG CharacterType:46 - binding 'S' to parameter: 4
22:49:46,910 DEBUG StringType:46 - binding 'lkh' to parameter: 5
22:49:46,910 DEBUG FloatType:46 - <b>binding '2.555' to parameter: 6</b>
22:49:46,910 DEBUG LongType:46 - binding '1920' to parameter: 7
22:49:46,920 DEBUG Cascades:396 - version unsaved-value strategy UNDEFINED
22:49:46,920 DEBUG Cascades:341 - id unsaved-value strategy NULL
22:49:46,930 DEBUG LongType:46 - binding '11' to parameter: 8
22:49:46,930 DEBUG LongType:46 - binding '11000188' to parameter: 9
22:49:46,930 DEBUG IntegerType:46 - binding '7' to parameter: 10
22:49:55,062 DEBUG BatcherImpl:207 - done closing: 0 open PreparedStatements, 0 open ResultSets
22:49:55,062 DEBUG BatcherImpl:269 - closing statement
22:49:55,062 DEBUG SessionImpl:2824 - post flush
22:49:55,062 DEBUG SessionImpl:585 - transaction completion
22:49:55,072 DEBUG JDBCTransaction:103 - re-enabling autocommit
22:49:55,072 DEBUG HibernateUtil:171 - Closing Session of this thread.
22:49:55,072 DEBUG SessionImpl:573 - closing session
22:49:55,072 DEBUG SessionImpl:3336 - disconnecting session
22:49:55,072 DEBUG SessionImpl:585 - transaction completion

We are facing a strange problem with mapping a java.lang.Float value to a NUMBER(15,3) field in Oracle (9i, thin driver). The decimal places are cut upon any update.

Hibernate clearly assigns the value 2.555 to the statement, but the database reads 2.000 after the update.

This might be a JDBC level problem, but we really don't think that we are the first ones who store a Float object into a NUMBER field, so it's kind of strange.

Does anyone know the reason for this ? Any solutions available ?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 17, 2005 6:18 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
try BigDecimal and if it doesn't work download last oracle driver (10g rel 2)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 17, 2005 7:00 pm 
Beginner
Beginner

Joined: Tue Aug 17, 2004 5:06 am
Posts: 46
Thx for the tip.

It was the JDBC driver. Why do I always have these Oracle-JDBC-nightmares ?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 17, 2005 7:44 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
oracle have perfect database stuff, but poor java


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.