-->
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.  [ 6 posts ] 
Author Message
 Post subject: How to mapping Long to oracle NUMBER ?
PostPosted: Fri Aug 17, 2007 2:46 pm 
Newbie

Joined: Fri Aug 17, 2007 2:24 pm
Posts: 6
java.lang.Long TO NUMBER(20,4) ? I used oracle 10g
I used this:

<property name="macThreshold" type="java.lang.Long">
<column name="MAC_THRESHOLD" precision="20" scale="5" />
</property>

It doesn't work. I get column MAC_THRESHOLD in table, but it is NUMBER(19), NOT NUMBER(20,5).

I used this:

<property name="macThreshold" type="java.lang.Long">
<column name="MAC_THRESHOLD" sql-type="NUMBER(20,5)" />
</property>

It works. I get column MAC_THRESHOLD in table is NUMBER(20,5), but this way isn't portable.

Any comments would be appreciate.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 17, 2007 3:55 pm 
Newbie

Joined: Thu Aug 16, 2007 2:03 pm
Posts: 6
NUMBER(20,5) in Oracle seems to be a 20-digits number with up to 5 of these 20 being a fractional part.

Having fractional part in DB how do you plan to map it to Long?

So the first thing is to change java.lang.Long to Float or BigDecimal (if you really want the scale part).

I didn't have time (sorry) to check this by running, but my first guess is that not all built-in types support precision and scale attributes, and changing to appropriate java type will fix the situation.

Looking at hibernate's sources might also help - there's a lot of stuff that I failed to find in docs and had to dig from the sources (they are pretty easy to read, thankfully).

BTW, which Dialect are you using fpr oracle 10g?


Top
 Profile  
 
 Post subject: Thank you so much.
PostPosted: Fri Aug 17, 2007 5:26 pm 
Newbie

Joined: Fri Aug 17, 2007 2:24 pm
Posts: 6
I used this dialect:

<prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>

Is it correct? Thanks again.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 17, 2007 5:56 pm 
Newbie

Joined: Thu Aug 16, 2007 2:03 pm
Posts: 6
Try changing your java type to BigDecimal (leaving presicion and scale in your mapping file) and dialect to Oracle9Dialect.

I don't have Oracle10 dialect in my hibernate package, may be it is already updated on the site.


Top
 Profile  
 
 Post subject: Thanks. It works.
PostPosted: Mon Aug 20, 2007 10:14 am 
Newbie

Joined: Fri Aug 17, 2007 2:24 pm
Posts: 6
kavdeev wrote:
Try changing your java type to BigDecimal (leaving presicion and scale in your mapping file) and dialect to Oracle9Dialect.

I don't have Oracle10 dialect in my hibernate package, may be it is already updated on the site.


But why I cannot mapping double type like this?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 21, 2007 7:12 am 
Newbie

Joined: Thu Aug 16, 2007 2:03 pm
Posts: 6
I don't know why exactly. My best guess is that the Dialect class is written this way.

BigDecimal generates number(x,y) ok. I've just checked.


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