-->
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: Derby sequence + Hibernate
PostPosted: Sun Sep 14, 2008 2:26 am 
Newbie

Joined: Wed Apr 06, 2005 11:41 am
Posts: 13
I am using hibernate version 3.3 to persist my class STUDENT. I am using derby as the underlying database. I want to set id using some generator when the id is not given to my Student entity class and use the existing id if its given to INSERT a record into STUDENT table.
Can any one guide me how would my annotation look like for student id property?
Does derby support sequence in the first place? If so how do I create sequence in derby?
How will my dao save method look like?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 15, 2008 1:18 am 
Newbie

Joined: Wed Apr 06, 2005 11:41 am
Posts: 13
This is how I am planning to do it as I think derby does not support sequence as of now.
1) create a sequence table to store seed and manage next val.
2) Implement IdentifierGenerator and based on whether entity id property is set or not; in the generate method return the next val or existing id.
3) For the entity the id genrator will be annotated with GenericGenerator and appropriate properties to get the table names etc are set with the parameter annotation.

Any thoughts?


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.