robert trudel
robert trudel

Reputation: 5749

Reset sequence in jpa

I use spring boot 2 with spring data jpa, hibernate and posgres. I need to reset a sequence every 1 day of the year, because we use current + ''+ sequence id.

Is there a way to reset a sequence with jpa?

Upvotes: 0

Views: 4780

Answers (1)

crizzis
crizzis

Reputation: 10716

A pure JPA way to reset a sequence does not exist, and resetting sequences is not even supported by all databases. That being said, you could try this solution with a native query (em.createNativeQuery(...).executeUpdate()) or the stored procedure API if you absolutely must use JPA for the job.

Upvotes: 2

Related Questions