-->
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: winforms+oracle sequence query
PostPosted: Sun Sep 17, 2006 3:53 pm 
Newbie

Joined: Sun Sep 17, 2006 3:32 pm
Posts: 3
Hi!

I've a form on which I'd like to insert new data into an Oracle table. The table gets it's primary key values from a sequence defined in the Oracle database too. So I want that when the form is shown, the value which will be the primary key value of the new data, to be displayed automatically! What is the best way to query the value?

Thanks in advance!


Top
 Profile  
 
 Post subject: Re: winforms+oracle sequence query
PostPosted: Mon Sep 18, 2006 3:10 am 
Beginner
Beginner

Joined: Wed Aug 03, 2005 8:06 am
Posts: 40
Location: Netherlands
ISession.Save(object) generates a new Id by getting the next value of the Oracle sequence. So you will have to prepare new objects and Save() them, without flushing the session yet (so you can do a rollback if necessary).

BTW I have bad experiences with meaningful primary keys. If this key has any meaning (which it probably does if you want to show it), I would prefer using an alternate key for it and have your data access get a nextvalue of another sequence. You won't have to Save() your objects then.


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.