• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Getting a sequence value?

 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic