-->
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.  [ 2 posts ] 
Author Message
 Post subject: Hibernate sequence question
PostPosted: Thu Apr 15, 2010 8:33 am 
Newbie

Joined: Fri Mar 12, 2010 8:51 am
Posts: 2
I'm currently using the following annotations for my primairy key:

@Id
@SequenceGenerator(name = "S912_PRO_SEQ",
sequenceName = "S912_PRO_SEQ",
allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE,
generator = "S912_PRO_SEQ")
@Column(name = "PRO_ID", unique = true,
nullable = false, precision = 9,
scale = 0)

Now I would like that hibernate only calls the sequence (generator) when the object has no ID set. (<=0)
Is there anny way to achieve this?

Thanks in advance!

Tim


Top
 Profile  
 
 Post subject: Re: Hibernate sequence question
PostPosted: Thu Apr 15, 2010 10:35 am 
Regular
Regular

Joined: Tue Feb 24, 2004 11:42 am
Posts: 56
if the type of the ID is object like Long or Integer as opposed to long and int Hibernate will automatically detect .Hope this helps
Please do not 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.  [ 2 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.