-->
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: Best way to get an arbitrary sequence value?
PostPosted: Mon Jun 27, 2005 9:49 pm 
Beginner
Beginner

Joined: Wed Jun 01, 2005 3:22 pm
Posts: 38
Location: Menlo Park, CA
The requirments state that one of my objects must have a business key that defaults to a value generated by a specific Oracle sequence.

What's the most appropriate way to do this with NHibernate?

1) Bypass NHibernate and execute and ADO.NET statement directly

2) Use ISession.CreateSQLQuery()? What should I use as the parameters?

3) Manually create and configure an NHibernate.Id.SequenceGenerator instance.

Any help would be appreciated. Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 28, 2005 3:14 pm 
Beginner
Beginner

Joined: Wed Jun 01, 2005 3:22 pm
Posts: 38
Location: Menlo Park, CA
I don't know if this is the best way, but this is how I'm doing it.


Code:
         using (IDbConnection con = _sessionFactory.ConnectionProvider.GetConnection())
         {
            IDbCommand cmd = con.CreateCommand();
            cmd.CommandText = "SELECT myschema.my_seq.NEXTVAL FROM DUAL";
            result = cmd.ExecuteScalar().ToString();
         }


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.