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.  [ 10 posts ] 
Author Message
 Post subject: Incorrect mapping to long. reveng.xml doesn't help
PostPosted: Tue Jun 14, 2005 8:56 am 
Newbie

Joined: Tue Jun 14, 2005 8:44 am
Posts: 4
Hibernate version:
tools.3.0.0.alpha4
Name and version of the database you are using:
Oracle 8.1.7

Hello, I've encountered the following problem trying reverse enginnering through Ant task:
jdbcconfiguration task with >hbm2java< incorrectly maps Oracle's INTEGER (NUMBER(38,0)) into java.math.BigInteger.

I've tried to solve this by adding the follwing to reveng.xml:
Code:
<type-mapping>
      <sql-type jdbc-type="DECIMAL" hibernate-type="long" />
      <sql-type jdbc-type="NUMERIC" hibernate-type="long" />
      <sql-type jdbc-type="BIGINT"  hibernate-type="long" />
      <sql-type jdbc-type="INTEGER" hibernate-type="long" />
      <sql-type jdbc-type="NUMERIC" length="38" hibernate-type="long" />
   </type-mapping>


and it doesn't help.

How can I map Oracle's INTEGER to long type in Java?
Is it <type-mapping> problem or another jdbc-type is needed?

Thanks in advance.

P.S. I've seen some threads in forum on this problem, but there were no straight answer. Had anyone found solution?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 14, 2005 10:17 am 
Expert
Expert

Joined: Wed Apr 06, 2005 5:03 pm
Posts: 273
Location: Salt Lake City, Utah, USA
It doesn't seem incorrect to me. NUMBER(38,0) is a *BIG* integer! Using BigInteger would be the only way to handle the range.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 14, 2005 10:21 am 
Newbie

Joined: Tue Jun 14, 2005 8:44 am
Posts: 4
nathanmoon wrote:
It doesn't seem incorrect to me. NUMBER(38,0) is a *BIG* integer! Using BigInteger would be the only way to handle the range.

Anyway, is there any way to force mapping of INTEGER to long in Java?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 14, 2005 11:13 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
use precision/scale for this. not length

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 16, 2005 9:39 am 
Newbie

Joined: Tue Jun 14, 2005 8:44 am
Posts: 4
max wrote:
use precision/scale for this. not length

Sadly, it doesn't help. I've looked on field's jdbc type, it equals 2 (or NUMERIC). Even more, VARCHAR custom mapping fails too (numbers instead of JDBC types too).
It seems that overrides in reveng.xml aren't applied. The reason is unclear to me, reveng.xml is definitely used, because table filtering works fine.
Now it seems that generator uses class types recommended by JDBC metadata and ignores <type-mapping> section. Why can this happen?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 16, 2005 9:42 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you will have to give me a reproducable test case.

the type overrides works in the unit tests.

best thing is probably to simply just step through with a debugger to see why it chooses that type.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 16, 2005 10:06 am 
Newbie

Joined: Tue Jun 14, 2005 8:44 am
Posts: 4
Another little problem (may be should post to JIRA) - reverse engeneering tool uses table name (even if it is from java keywords list) as a property name, in many-to-one associaton, for example. Resulting code won't compile in case table name is equal to any java keyword ('interface' for example).


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 16, 2005 10:16 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
and what name should i use instead ?

this what users must specify. right now only possibly programmatically.

But for running the first reverse engineering without problems we could probably keep a list of "bad" names that will be prefixed with something to avoid collisions.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 16, 2005 7:42 pm 
Newbie

Joined: Wed Jun 15, 2005 9:36 am
Posts: 9
Location: Mexico
Hi there !!

I'm having the very same problem as Bruzz, but I just want to discriminate every NUMERIC type in Oracle into Long or Double java Types:

Code:
   <type-mapping>
      <sql-type jdbc-type="NUMERIC" scale="0" hibernate-type="java.lang.Long"/>
      <sql-type jdbc-type="NUMERIC" hibernate-type="java.lang.Double"/>
   </type-mapping>


but I always get only java.math.BigDecimal types...

Am I doing anything wrong in my hibernate.reveng.xml file?

Thank you and best regards !!

_________________
Marcelo Torres


Top
 Profile  
 
 Post subject: For Posterity...
PostPosted: Wed Jul 30, 2008 8:04 am 
Newbie

Joined: Tue Apr 01, 2008 3:34 pm
Posts: 10
I realize the post is over 3 years old but, for the sake of posterity, if using Oracle the JDBC type will be DECIMAL. If you use DECIMAL instead of NUMERIC your config file will generate Long and Double types as desired.


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