-->
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: key-property bigdecimal length setting problem
PostPosted: Thu Apr 27, 2006 5:35 am 
Newbie

Joined: Wed Mar 29, 2006 4:05 am
Posts: 2
I defined
<key-property name="O1ORD" type="java.math.BigDecimal" precision="9" scale="0"/>

but Hibernate is nagging that I have to use precision and scale.
When I omit them it creates a table with o1ord as 19,2 numeric

How to solve??


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 28, 2006 1:50 am 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Well.. what's the problem? I don't actually see anything that needs solving here. What would you like to see, or to have happen?

As a matter of interest, if you have scale="0", why are you using BigDecimal? Why not BigInteger? Also, it's usually nicer to use the hibernate names for types, so you could change java.math.BigDecimal to big_decimal (or big_integer, if you change to using java.math.BigInteger in java).

_________________
Code tags are your friend. Know them and use them.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 30, 2006 12:22 pm 
Newbie

Joined: Wed Mar 29, 2006 4:05 am
Posts: 2
well your are right. but this is a legacy database which is approaced by hibernate

if i definie a key as bigdecimal hibernate does not do what i expect
I want to define the size of the key fields

for example
ordernumber 9.4 and not always the default value 19.2

can you help me on this?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 30, 2006 6:39 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Unfortunately key-property doesn't allow precision and scale attributes. The workaround is to create a UserType that does the same thing as org.hibernate.type.BigDecimalType, but accepts parameters for scale and precision. Then create typedefs for each precision/scale combination you'll need. See ref docs, section 5.2.3 for more info.

_________________
Code tags are your friend. Know them and use them.


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.