Here is the code I used to set the sequence name.
First, the SequenceGenerator:
package com.foo; import java.util.Properties; import org.hibernate.MappingException; import org.hibernate.dialect.Dialect; import org.hibernate.id.SequenceGenerator; import org.hibernate.type.Type; public class TableNameSequenceGenerator extends SequenceGenerator { public static final String CUSTOM_SEQUENCE_NAME = "MYAPP_SEQUENCE" public void configure(Type type, Properties params, Dialect dialect) throws MappingException { if(params.getProperty(SEQUENCE) == null || params.getProperty(SEQUENCE).length() == 0) { String seqName = CUSTOM_SEQUENCE_NAME; params.setProperty(SEQUENCE, seqName); } super.configure(type, params, dialect); } }
Next, the OracleDialect:
package com.foo; import org.hibernate.dialect.Oracle10gDialect; public class MyAppOracleDialect extends Oracle10gDialect { public Class getNativeIdentifierGeneratorClass() { return TableNameSequenceGenerator.class; } }
Last, DataSource.groovy needs to know about the dialect:
dataSource { pooled = true driverClassName = "oracle.jdbc.OracleDriver" // username, password.... dialect='com.foo.MyAppOracleDialect' }