I've a sequence defined in my Oracle database.
Can I pull from this sequence using Hibernate? I don't want to use the sequence for generating ids开发者_运维技巧 for my objects, so @GeneratedValue
and @Id
are not the things I am looking for.
Something like this:
<sql-query name="sequenceValue">
<return alias="mySeq" class="MySequences"/>
select my_schema.seq_myid.nextval as mySeq from dual
</sql-query>
Have you tried:
select my_schema.seq_myid.nextval from dual;
This will return a one record result set with the next value in your sequence. You can then use
select my_schema.seq_myid.currval from dual;
To get the current value of the sequence.
精彩评论