-->
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.  [ 3 posts ] 
Author Message
 Post subject: Generating Primary Key Outside Hibernate
PostPosted: Tue Aug 14, 2007 5:00 am 
Beginner
Beginner

Joined: Thu Mar 01, 2007 9:40 am
Posts: 23
Location: UK
Hi,

Hibernate version: 2.8.1

Name and version of the database you are using: Oracle 8i

I have a requirement to generate the primary key ID in my code before Hibernate is called to auto-generate it. How do I achieve this?

The way I understand, following is specified in mapping for hibernate to generate the primary key:
<id name="id" column="ID">
<generator class="uuid.hex" />
</id>

However, I don't want Hibernate to generate this. I wish to generate the primary key using VMID, and set it into the object, and Hibernate should just use it to store the data, and make related foreign keys.

Let me know if there's any way to do this.

Thanks,
--
Jikes

_________________
Sam.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 14, 2007 5:43 am 
Expert
Expert

Joined: Fri Jul 13, 2007 8:18 am
Posts: 370
Location: london
Just remove the generator element or use <generator class="assigned"/> indicating that your application will assign the IDs.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 14, 2007 6:27 am 
Beginner
Beginner

Joined: Thu Mar 01, 2007 9:40 am
Posts: 23
Location: UK
Thanks. This was what I was looking for.


thatmikewilliams wrote:
Just remove the generator element or use <generator class="assigned"/> indicating that your application will assign the IDs.

_________________
Sam.


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