【发布时间】:2019-10-31 13:37:58
【问题描述】:
我正在尝试使用 jpaRepository 从 oracle 数据库中获取序列号。
主要问题是因为我在 JpaRepository 中没有任何对象,所以我真的不知道如何解决它。序列号将是一个 Long,我只需要在我的存储库中返回这个数字。
我的代码:
@Repository
public interface InsuranceRepository extends JpaRepository<Long, Long> {
@Query(value = "SELECT INSURANCE_VOUCHER_SEQ.nextval FROM dual", nativeQuery = true)
Long findInsuranceVoucher();
}
我知道是错的,但我不知道我应该如何实现它。
谢谢大家。
【问题讨论】:
-
只使用 JDBC。你为什么想要它?
-
在没有实体的情况下,为什么要使用 Spring Data JPA?为什么还要 JPA?
标签: oracle spring-boot spring-data-jpa