1

I am working with hibernate, and a oracle 10 db. I need to get the next sequence value from a table, and want to know how. I saw this article, and asking: is there a better way the get the value, without defining a query?

Thanks!

1 Answer 1

2

No. Getting the next (nextval) or current (currval) value from a sequence is typically done using a select. Even in PLSQL, SELECT INTO is used, like this:

SELECT YourSequence.NextVal INTO :new.ID FROM DUAL;

Simple assignment like this won't work:

:new.ID := YourSeqence.NextVal;
Sign up to request clarification or add additional context in comments.

6 Comments

So there is no way of doing this in hibernate?
I have question here if you have some inputs then it would be really helpful...stackoverflow.com/q/11313854/164299
Sounds like the same question, isn't it?
Yes but is there a way to do this in hbm file?
@GolezTrol can you explain this docs.jboss.org/hibernate/core/3.6/reference/en-US/html_single/… and what are those annotations for? I thought that was an alternative
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.