-->
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.  [ 9 posts ] 
Author Message
 Post subject: Reverse engineering and key-column types
PostPosted: Fri Feb 02, 2007 12:56 pm 
Newbie

Joined: Fri Feb 02, 2007 10:42 am
Posts: 5
Hello,

I have a problem in reverse engineering with 3.2.0beta9a. A hibernate.reveng.xml file with a "key-column" like this:

<key-column name="IDCONTA" type="integer"/>

generates, Java code:

private Integer idconta; //wrapper type

and hbm.xml file with:

<id name="idconta" type="integer">

but, when i switch de type to "long" the behavior is diferent:

<key-column name="IDCONTA" type="long"/>

generates, Java code:

private long idconta; //primitive type

and hbm.xml file with:

<id name="idconta" type="long">

There's a way to choose between primitive and wrapper types? This behavior is not homogeneous.

Thanks for your response and suggestions.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 02, 2007 1:46 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
if you want the primitive type then use the "int" name; not "integer" nor "java.lang.Integer"

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 02, 2007 2:03 pm 
Newbie

Joined: Fri Feb 02, 2007 10:42 am
Posts: 5
How to get Long (wrapper) in Java and "long" type in hbm?

I use this code in hibernate.reveng.xml and it don't work.

<key-column name="IDCONTA" type="Long"/>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 02, 2007 2:07 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
java.lang.Long

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 02, 2007 2:10 pm 
Newbie

Joined: Fri Feb 02, 2007 10:42 am
Posts: 5
If I use "int" name, hbm is generated with "int" as a Hibernate type. "int" is not a Hibernate type.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 02, 2007 2:13 pm 
Newbie

Joined: Fri Feb 02, 2007 10:42 am
Posts: 5
Thanks for the response Max. But i still have problems... If a use "java.lang.Long" a get this hbm:

<id name="idconta" type="java.lang.Long">

Seems wrong to me.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 02, 2007 2:28 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
make a choice - either you want primitives or you want wrappers....

How should hbm2java know that when you use "long" you want it to be "java.lang.Long" ? It would require more options/settings so it is much simpler to just say "if you want long then write long, if you want java.lang.Long then write java.lang.Long" .....and that is what the tooling does.

for hibernate internally there are no difference between long and java.lang.Long so it does not affect the core mechanics at all.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 02, 2007 2:29 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
oh and if you really want an option for it you can do

Code:
   <id name="id" type="long">
       <meta attribute="property-type">java.lang.Long</meta>
   </id>



...see *that* looks wrong! :)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 02, 2007 2:39 pm 
Newbie

Joined: Fri Feb 02, 2007 10:42 am
Posts: 5
Thanks Max. I didn't knew that Hibernate mapping supports Java types in "hibernate type" properties. I use java.lang.Long or java.lang.Integer and that works.


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