javahibernatespring-data-jpahqlsequence-sql

Manage sequences using HQL


TLDR: There is a way to manage sequences in relational database using pure Hibernate or Spring?

I am writing a library in java That need to create and get the next value of a sequence. I can't use native sql because the database can be Oracle , H2 or Postgresql. In my opinion hql will be the best answer because it's not depend on the database type.

Thanks For any kind of help!!


Solution

  • I'm pretty confident nothing like this exists in JPA nor in Spring (or Spring Data). There might be something useful internally in Hibernate and other JPA implementations but it is most certainly not intended for direct use.

    If you want something ready-made jOOQ has support for this.