开发者

Pull from Oracle sequence with Hibernate

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜