使用 Hibernate 从 Oracle 序列中提取数据

发布于 2024-10-07 11:58:06 字数 134 浏览 0 评论 0原文

我在 Oracle 数据库中定义了一个序列。 我可以使用 Hibernate 提取该序列吗?我不想使用该序列为我的对象生成 id,因此 @GenerateValue@Id 不是我正在寻找的东西。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

仲春光 2024-10-14 11:58:06

像这样的东西:

  <sql-query name="sequenceValue">  
     <return alias="mySeq" class="MySequences"/>  
       select my_schema.seq_myid.nextval as mySeq from dual  
  </sql-query> 

Something like this:

  <sql-query name="sequenceValue">  
     <return alias="mySeq" class="MySequences"/>  
       select my_schema.seq_myid.nextval as mySeq from dual  
  </sql-query> 
流星番茄 2024-10-14 11:58:06

您是否尝试过:

select my_schema.seq_myid.nextval from dual;

这将返回一个记录结果集,其中包含序列中的下一个值。然后您可以使用

select my_schema.seq_myid.currval from dual;

来获取序列的当前值。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文