【问题标题】:oracle DB sequence with Spring Boot使用 Spring Boot 的 oracle DB 序列
【发布时间】:2018-12-27 13:22:08
【问题描述】:

我正在使用spring boot,需要一个序列变量,决定使用DB序列,我想从序列中得到nextval。 HQL 查询select nextval('db_seq_name') as num 不起作用,我正在寻找其他方法。请指导我。

我的问题是:如何在 Spring Boot 中使用休眠查询语言从数据库序列中获取 Nextval。

【问题讨论】:

标签: oracle spring-boot sequence


【解决方案1】:

由于问题不明确,我会做一些疯狂的猜测。

public interface NextValRepository extends JpaRepository<YourEntity, Integer> {

    @Query(value = "select nextval('db_seq_name')", nativeQuery = true)
    public Integer nextVal();

}

并且@Autowired 这个在任何你想使用序列中的下一个值的地方。

【讨论】:

  • 我不想创建原生查询,因为它依赖于数据库,我想使用休眠查询语言,请查看我更新的问题
猜你喜欢
  • 2020-10-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-06-27
  • 2018-10-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多