-->
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.  [ 4 posts ] 
Author Message
 Post subject: Annotation for ID generated by database trigger?
PostPosted: Mon Jul 25, 2005 2:26 pm 
Newbie

Joined: Sat Apr 02, 2005 2:17 am
Posts: 11
I've been trying to work out the correct way of annotating an entity in an Oracle database so that Hibernate will let the database give it an identity, and then select it to find out what ID it's been assigned.

Caveat: we need the same annotation to work for both Oracle and SQL Server. On Oracle there's a sequence and a before-insert trigger; on SQL Server the field is an ident field which is auto-incremented.

Using the "AUTO" generator type, Hibernate selects from hibernate_sequence and then does the insert using that - the trigger overwrites the value, and everyone gets confused.

Removing the trigger is a possibility, although in that case I'd like to be able to specify the sequence to use when on Oracle, without any complaints when running on SQL Server, if possible. (It helps to have different sequences for debugging purposes - on a small test system, any ID between 17001 and 18000 always belongs to one table, etc.)

I *believe* (although I haven't tried it yet) that a generator type of "select" in the XML configuration for Hibernate would do the right thing - is there an equivalent of this in Annotations-land?

Currently we're using Annotations 3.0 preview release 2, but if that's a problem we could probably change. I've looked in the Hibernate Annotations docs and the EJB 3.0 public draft, but to no avail... apologies if I've missed the answer!

Please let me know if you need any more information.
Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 25, 2005 2:39 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I've implemented it the other night. Will be available in the next release or already in CVS

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 25, 2005 5:00 pm 
Newbie

Joined: Sat Apr 02, 2005 2:17 am
Posts: 11
Excellent - that's good to know. I'm sure we'll manage with other means for the moment. I'll try to get it working by specifying the ID generator in the XML and leaving the rest to annotations until then. Let me know if you'd like any bits testing early, or anything like that.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 26, 2005 1:34 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
testing is always good :-)
What I'd like to ear is the ease of use feeling your guys have compared to the hibernate extensions I've done so far.

_________________
Emmanuel


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