I use PostgreSQL. Sequences (when generated by specifying SERIAL asthe datatype) follow this pattern:
schema.tablename_columnname_seq
I have a NamingConvention to get sequence values. I have a map likeso:
HashMap seqMap = new HashMap();seqMap.put("public.roles", "roles_roleid_seq");seqMap.put("public.userroles", "userroles_userroleid_seq");seqMap.put("public.users", "users_userid_seq");seqMap.put("public.usertypes", "usertypes_usertypeid_seq");
I can generate this from the database, but I'd prefer to do this byconvention for easier maintenance. I'm wondering if we could have agetSequenceNameByConvention method. I suppose this would take theclass. I'd fish out the table name and id column name to form thesequence name.
Thanks.
/Daryl
This required a small change to the API for NamingConvention.
Specifically the pkColumn parameter was added to the getSequenceName() method.
public String getSequenceName(String tableName, String pkColumn);
NOTE: if you put into ebean.properties something like:
ebean.h2.namingConvention.sequenceFormat={table}_{column}_seq
Then the "{table}_{column}_seq" format is used to define the sequence names.
This fix didn't take into account creating a NamingConvention that is created by ServerConfig when defined in ebean.properties
i.e. this didn't work
ebean.namingConvention=com.avaje.ebean.config.MatchingNamingConventionebean.h2.namingConvention.sequenceFormat={table}_{column}_seq
Fixed that scenario now.