-->
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.  [ 5 posts ] 
Author Message
 Post subject: How do you map NUMBER(6,2)?
PostPosted: Thu Sep 04, 2008 3:49 pm 
Newbie

Joined: Wed Sep 03, 2008 4:16 pm
Posts: 2
I have a column in my Oracle10g db that is NUMBER(6,2)
Can't seem to map it to anything.

Here's the column definition

Code:
   MULTIPLIER NUMBER(6,2)


Here's the annotation on the entity class

Code:
   @Column(precision=6,scale=2,columnDefinition="NUMBER(6,2)")
   public Double getMultiplier() {
      return multiplier;
   }


Here's what the Hibernate validator says

Code:
org.hibernate.HibernateException: Wrong column type: multiplier, expected: NUMBER(6,2)


?!

Also tried mapping to Float.

What gives? How do I map a NUMBER(6,2) column?

Hibernate 3.2.4.sp1
Hibernate Annotations 3.3.1.Beta1

Oracle10gDialect


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 04, 2008 4:14 pm 
Beginner
Beginner

Joined: Wed Apr 20, 2005 9:30 am
Posts: 39
I don't use annotations a whole bunch, but I think what's happening there is that between hibernate and annotations, something is intuit-ing that the type of column should be 'multiplier'.

I just checked the source for the Oracle dialects and it appears that double would be mapped to an oracle-double. I think if you need the column type to be a 'Number', you should need to only supply 'numeric' or 'decimal' as the type to force Hibernate into using an oracle-number type - and leave out the precision bits.

Code:
@Column(precision=6,scale=2,columnDefinition="numeric")
public Double getMultiplier() {
  return multiplier;
}


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 04, 2008 5:08 pm 
Newbie

Joined: Wed Sep 03, 2008 4:16 pm
Posts: 2
Nope.

Tried columnDefinition="numeric": no luck
Tried columnDefinition="decimal": no luck
Have tried leaving out the columnDefinition: no luck

I don't think this is an annotations issue. How would you map it in xml?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 04, 2008 5:59 pm 
Beginner
Beginner

Joined: Wed Apr 20, 2005 9:30 am
Posts: 39
Sorry about the bad lead. I can answer the xml question though:

Code:
<property name="cost" type="big_decimal">
  <column name="cost" scale="2" precision="10" not-null="false" />
</property>


But to really look and see how the 'type' get's mapped, you need to look at the dialect source.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 04, 2008 6:17 pm 
Newbie

Joined: Wed Oct 31, 2007 5:36 pm
Posts: 13
We have the exact same mapping.

We use java.math.BigDecimal as the POJO datatype.

Code:
BigDecimal multiplier;

public BigDecimal getMultiplier() {
    return multiplier;
}


We use XML mapping as well.

Code:
<property name="multiplier" type="big_decimal"
    column="MULTIPLIER" />


Hope this helps.


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