-->
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.  [ 15 posts ] 
Author Message
 Post subject: BigDecimal and int support when reverse engineering
PostPosted: Fri Dec 30, 2005 7:06 pm 
Beginner
Beginner

Joined: Mon Jun 06, 2005 6:48 pm
Posts: 45
Hi All,

Anyone know how to change a datatype for a column for a hibernate class during generation and not modify any of the other settings in the hbm?

I need to change a long to a BigDecimal or a long to a int for some of the java files generated by hibernate tools. I am concerned to do that I may have to type in all the settings like many to many ect in the reverse engineering xml file. The reveng.xml example I have seen on this site does not answer that question clearly for me.

Thanks,
-Tony


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 31, 2005 4:16 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
no - you just need to put in a <type-mapping> for the column type if you want it to be a common thing for a specific jdbc type.

And if it is just for a specific column you just need to specify a <table> with a <column> in it.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: BigDecimal conversion reply
PostPosted: Mon Jan 02, 2006 2:03 am 
Beginner
Beginner

Joined: Mon Jun 06, 2005 6:48 pm
Posts: 45
Hi Max,

Thanks for the again. Now in return I wanted to let you know something interesting I found out this weekend.

When trying to convert a Column to the type mentioned in this message I learned something interesting. The column type in the database is NUMBER with precision 10 but no scale set as far as I can tell. I believe because of this when trying to reverse engineer to BigDecimal Hibernate Tools fails to convert and does not give an error message. Why you ask? Because when NUMBER is specified with a precision but not a scale you can not set the value to the right of the decimal point according to a Oracle DBA friend of mine and some googling I did. Now maybe somewhere deep in the source code for Hibernate Tools someone coded it so you can not specify a BigDecimal for a NUMBER data type where there is no scale set.

I noticed some messages on this forum about data types not being set and perhaps this might be a clue that might help you and the Hibernate Team.

Thanks Again,
-Tony


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 02, 2006 3:07 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
could you please show the DDL for what you are trying to explain - the literal text is not making too much sense too me. thanks.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: BigDecimal Support
PostPosted: Tue Jan 03, 2006 1:13 pm 
Beginner
Beginner

Joined: Mon Jun 06, 2005 6:48 pm
Posts: 45
Hi Max,

Thanks again for the reply. The databse ddl is very large since there are over 100 tables involved. I did verify with the DBA my i was correct about the NUMBER type with the scale of 0.

Understanding that I was trying to overide the long conversion so I get Integer instead of long but seem to not be able to do that.

My question now is what is the correct sql-type that hibernate tools expect for me to overide? Should it be long or LONG or BIGINT? Here is an example of from my reveng.xml that hopefully you can tell me what I am doing wrong. I get no error from the tools during creation of the hbm pr java files yet hibernate tools still puts in the java type long for a Oracle NUMBER type precision 10 and scale of 0.


<type-mapping>
<sql-type jdbc-type="BIGINT" precision="10" scale="0" hibernate-type="java.lang.Integer" />
</type-mapping>


Thanks for the help.
-Tony


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 03, 2006 1:35 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
the type you need to override is the jdbc type that the driver reports for your column.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: NUMERIC CONVERSION
PostPosted: Tue Jan 03, 2006 6:36 pm 
Beginner
Beginner

Joined: Mon Jun 06, 2005 6:48 pm
Posts: 45
Hi Max,

I tried and figured out it was NUMERIC. I tried overiding to java.lang.Integer but did not work either.

I did get logging working but no indication of what the problem is.

I will try some more but may have to take different route to solve problem.

Thanks,
-Tony


Top
 Profile  
 
 Post subject: Re: NUMERIC CONVERSION
PostPosted: Wed Jan 04, 2006 11:41 am 
Beginner
Beginner

Joined: Mon Jun 06, 2005 6:48 pm
Posts: 45
Hi Max,

Yes, I tried DEBUG, WARN & ERROR logger levels and did not see any indication of a message indicating that hibernate tools was attempting to use my overides in the reveng.xml file.

What would be the key word I should look for in the log output for DEBUG level?

Thanks,
-Tony


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 05, 2006 11:48 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
i'll update the docs on this tomorrow - read that when it gets online and let me know if that helps you out...if not come back ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: BigDecimal & int support
PostPosted: Thu Jan 05, 2006 12:55 pm 
Beginner
Beginner

Joined: Mon Jun 06, 2005 6:48 pm
Posts: 45
Hi Max,

I look forward to the document update today. I changed my reveng.xml to update specific table column and same response (no change in the hbm file from long or Integer) as using the global way of changing the data type.

I will probably take the brute approach to replace the long with Integer in the hbm file using ant replacetoken task since my time with trying to get the type change in the reveng.xml has exceeding what I have available.

Thanks,
-Tony


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 05, 2006 1:01 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
and we are sure this is not a simple case sensitive error ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Problem Resolved
PostPosted: Fri Jan 06, 2006 2:31 pm 
Beginner
Beginner

Joined: Mon Jun 06, 2005 6:48 pm
Posts: 45
Hi Max after trying many combinations of attributes I was able to change the type.

For e using Oracle 9i the settings that worked are:

<table name="TEST" >
<column name="SOME_NUM" property="someNum" type="java.math.BigDecimal" />
</table>


I removed the schema attribute and added the property attribute.


Did not find the update to the Tools Documentation yesterday and still interested in it.


Thanks,
-Tony


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 07, 2006 3:31 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
I found 2 stupid bugs that needed fixing which will be released early next week together with updated docs.

You can get the docs from cvs or read them in the eclipse help (if you have updated to the hibernatetools that were released with jbosside last week)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 07, 2006 11:12 am 
Beginner
Beginner

Joined: Mon Jun 06, 2005 6:48 pm
Posts: 45
Hi Max,

Were the bugs related to my problems with getting types to work through type-mapping? Is the fix in the nightly build? I am working on a project ad can use the fixes and updated documentation as soon as possible.

How to I get to the CVS repository where the updated documentation is located?

Thanks
-Tony


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 07, 2006 11:45 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
no the 2 bugs were HBX-530 and HBX-531; not related to the type things.

you can get info on nightly builds and how to Build & Contribute from tools.hibernate.org

_________________
Max
Don't forget to rate


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