0

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?

robert trudel
  • 5,283
  • 17
  • 72
  • 124

1 Answers1

2

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.

crizzis
  • 9,978
  • 2
  • 28
  • 47