Module io.ebean.api

Class AbstractNamingConvention

    • Field Detail

      • databasePlatform

        protected DatabasePlatform databasePlatform
        The database platform.
      • rhsPrefixLength

        protected int rhsPrefixLength
        Used to trim off extra prefix for M2M.
      • useForeignKeyPrefix

        protected boolean useForeignKeyPrefix
    • Constructor Detail

      • AbstractNamingConvention

        public AbstractNamingConvention​(String sequenceFormat,
                                        boolean useForeignKeyPrefix)
        Construct with a sequence format and useForeignKeyPrefix setting.
      • AbstractNamingConvention

        public AbstractNamingConvention​(String sequenceFormat)
        Construct with a sequence format.
        Parameters:
        sequenceFormat - the sequence format
      • AbstractNamingConvention

        public AbstractNamingConvention()
        Construct with the default sequence format ("{table}_seq") and useForeignKeyPrefix as true.
    • Method Detail

      • setDatabasePlatform

        public void setDatabasePlatform​(DatabasePlatform databasePlatform)
        Description copied from interface: NamingConvention
        Set the associated DatabasePlaform.

        This is set after the DatabasePlatform has been associated.

        The purpose of this is to enable NamingConvention to be able to support database platform specific configuration.

        Specified by:
        setDatabasePlatform in interface NamingConvention
        Parameters:
        databasePlatform - the database platform
      • getSequenceName

        public String getSequenceName​(String rawTableName,
                                      String pkColumn)
        Description copied from interface: NamingConvention
        Return the sequence name given the table name (for DB's that use sequences).

        Typically you might append "_seq" to the table name as an example.

        Specified by:
        getSequenceName in interface NamingConvention
        Parameters:
        rawTableName - the table name
        Returns:
        the sequence name
      • getCatalog

        public String getCatalog()
        Return the catalog.
      • setCatalog

        public void setCatalog​(String catalog)
        Sets the catalog.
      • getSchema

        public String getSchema()
        Return the schema.
      • setSchema

        public void setSchema​(String schema)
        Sets the schema.
      • getSequenceFormat

        public String getSequenceFormat()
        Returns the sequence format.
      • setSequenceFormat

        public void setSequenceFormat​(String sequenceFormat)
        Set the sequence format used to generate the sequence name.

        The format should include "{table}". When generating the sequence name {table} is replaced with the actual table name.

        Parameters:
        sequenceFormat - string containing "{table}" which is replaced with the actual table name to generate the sequence name.
      • isUseForeignKeyPrefix

        public boolean isUseForeignKeyPrefix()
        Return true if a prefix should be used building a foreign key name.

        This by default is true and this works well when the primary key column names are simply "ID". In this case a prefix (such as "ORDER" and "CUSTOMER" etc) is added to the foreign key column producing "ORDER_ID" and "CUSTOMER_ID".

        This should return false when your primary key columns are the same as the foreign key columns. For example, when the primary key columns are "ORDER_ID", "CUST_ID" etc ... and they are the same as the foreign key column names.

        Specified by:
        isUseForeignKeyPrefix in interface NamingConvention
      • setUseForeignKeyPrefix

        public void setUseForeignKeyPrefix​(boolean useForeignKeyPrefix)
        Set this to false when the primary key columns matching your foreign key columns.
      • getTableNameByConvention

        protected abstract TableName getTableNameByConvention​(Class<?> beanClass)
        Return the tableName using the naming convention (rather than deployed Table annotation).
      • hasInheritance

        protected boolean hasInheritance​(Class<?> supCls)
        Return true if this class is part of entity inheritance.
      • getM2MJoinTableName

        public TableName getM2MJoinTableName​(TableName lhsTable,
                                             TableName rhsTable)
        Description copied from interface: NamingConvention
        Returns the ManyToMany join table name (aka the intersection table).
        Specified by:
        getM2MJoinTableName in interface NamingConvention
        Parameters:
        lhsTable - the left hand side bean table
        rhsTable - the right hand side bean table
        Returns:
        the many to many join table name
      • getTableNameFromAnnotation

        protected TableName getTableNameFromAnnotation​(Class<?> beanClass)
        Gets the table name from annotation.
      • quoteIdentifiers

        protected String quoteIdentifiers​(String s)
        Replace back ticks (if they are used) with database platform specific quoted identifiers.
      • isEmpty

        protected boolean isEmpty​(String s)
        Checks string is null or empty .