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?
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?
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.