-->
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: can 'hbm2hbmxml' generate <generator class="identity
PostPosted: Tue Nov 15, 2005 6:59 pm 
Newbie

Joined: Sun Oct 23, 2005 7:03 pm
Posts: 12
Hi, I have a database table with PK as a 'identity' (SQL2000Server),
and I'm using hbm2hbmxml to generate my *.hbm.xml files.
My question is the hbm.xml genrated have:

Code:
<id name="fileId" type="long">
            <column name="FILE_ID" />
            <generator class="assigned" />
  </id>


What I want is <generator class="identity" />

can I make hbm2hbmxml do this? Or I have to manually change the hbm.xml file?

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 16, 2005 5:06 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
that is controllable via a reveng.xml

please not that hbm2hbmxml has nothing to do with the reverse engineering - it is the jdbcconfiguration that does this.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 16, 2005 1:11 pm 
Newbie

Joined: Sun Oct 23, 2005 7:03 pm
Posts: 12
But when my application tried to insert a record into DB, the A.hbm.xml will instruct Hibernate how to do the insertion, right?

In my table A, I have a PK A_ID as is a 'identity' PK, which means the PK should be generated by DB, not specified by the application.

So if in my A.hbm.xml, I have
<id name="fileId" type="long">
<column name="A_ID" />
<generator class="assigned"/>
</id>

Hibernate will complain about that I'm trying to insert a PK with a explicit value.
what I want is that make hbm2hbmxml to generate A.hbm.xml as:

<id name="fileId" type="long">
<column name="A_ID" />
<generator class="identity"/>
</id>
So Hibernate will not complain when I insert.

Please advice, thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 16, 2005 11:01 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Quoting Max.
Quote:
that is controllable via a reveng.xml


hbm2hbmxml does not do the reverse engineering of the database.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 16, 2005 11:53 pm 
Newbie

Joined: Sun Oct 23, 2005 7:03 pm
Posts: 12
David:
Thank you for your reply, but I'm not trying to do reverse engineering here, am I?
I'm trying to insert data using Hibernate, and A.hbm.xml is guiding the insertion, right? but my A.hbm.xml is not instructing the insertion correctly because the 'identity' problem. I can manually change my A.hbm.xml, and it works. My question is, I want the A.hbm.xml to be generated correctly, so I do not have to manually change it after it is generated, is there a way to do this? Or I have to fix my A.hbm.xml manually?

Thanks,


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 17, 2005 12:19 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you are talking about "generating hbm.xml" that definitly sounds like you are doing some kind of reverse engineering....

_________________
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.  [ 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.