• Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting a sequence value?  RSS feed

 
A Harry
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is there a better way of returning a value from an Oracle sequence than using something like session.createSQLQuery("select myseq.nextval from dual")

thanks

harry
 
Mark Spritzler
ranger
Sheriff
Posts: 17309
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use curval instead of nextval if you don't want to waste a number. Also when you insert with Hibernate remember that that method call returns an object with its ID in it.

Basically, the ways to get the nextval from a sequence is the exact same with or without Hibernate. If I was in a stored procedure directory on Oracle, I would still need to do the exact same SQL from dual to get it without an actual insert statement.

Mark
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!