Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Override default sequence name in Grails

Tags:

grails

How can I rename HIBERNATE_SEQUENCE? Methods for generating one sequence per table (and giving specific names to those sequences) are well-documented, but that's not what I'm looking for.

I don't mind having one sequence shared by all domain classes. I just need to give it an application-specific name.

like image 388
Jim Norman Avatar asked Sep 06 '25 22:09

Jim Norman


1 Answers

There appears to be an open feature / enhancement request in the Hibernate JIRA to make this globally configurable: Make the default sequence name globally configurable. I believe, as a workaround, you would have to set the 'generator' attribute to the same name for all domain classes (defaults to hibernate_sequence) for every @Id field. See oracle sequence created.

As you hinted in your question, there might be a way to do this by subclassing your database dialect - as many have suggested for a sequence-per-table approach.

See id generator and DRY principle

like image 161
mikesalera Avatar answered Sep 10 '25 21:09

mikesalera