Ron Badur
Ron Badur

Reputation: 1973

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!!

Upvotes: 0

Views: 325

Answers (2)

Jens Schauder
Jens Schauder

Reputation: 81988

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.

Upvotes: 1

i.karayel
i.karayel

Reputation: 4885

There are many different id generation options in hibernate. You can choose one of these strategies:
The Auto Strategy
The Identity Strategy
The Sequence Strategy
The Table Strategy

http://www.objectdb.com/java/jpa/entity/generated

Upvotes: 0

Related Questions