Module io.ebean.api

Class UnderscoreNamingConvention

java.lang.Object
io.ebean.config.AbstractNamingConvention
io.ebean.config.UnderscoreNamingConvention
All Implemented Interfaces:
NamingConvention

public class UnderscoreNamingConvention extends AbstractNamingConvention
Converts between Camel Case and Underscore based names for both table and column names (and is the default naming convention in Ebean).
Author:
emcgreal, rbygrave
  • Constructor Details

    • UnderscoreNamingConvention

      public UnderscoreNamingConvention(String sequenceFormat)
      Create with a given sequence format.
      Parameters:
      sequenceFormat - the sequence format
    • UnderscoreNamingConvention

      public UnderscoreNamingConvention()
      Create with a sequence format of "{table}_seq".
  • Method Details

    • getTableNameByConvention

      public TableName getTableNameByConvention(Class<?> beanClass)
      Returns the last part of the class name.
      Specified by:
      getTableNameByConvention in class AbstractNamingConvention
      Parameters:
      beanClass - the bean class
      Returns:
      the table name from class
    • getColumnFromProperty

      public String getColumnFromProperty(Class<?> beanClass, String propertyName)
      Converts Camel case property name to underscore based column name.
      Returns:
      the column from property
    • isForceUpperCase

      public boolean isForceUpperCase()
      Return true if the result will be upper case.

      False if it will be lower case.

    • setForceUpperCase

      public void setForceUpperCase(boolean forceUpperCase)
      Set to true to make the result upper case.
    • isDigitsCompressed

      public boolean isDigitsCompressed()
      Returns true if digits are compressed.
    • setDigitsCompressed

      public void setDigitsCompressed(boolean digitsCompressed)
      Sets to true for digits to be compressed (without a leading underscore).
    • getForeignKey

      public String getForeignKey(String prefix, String fkProperty)
      Description copied from interface: NamingConvention
      Return the foreign key column given the local and foreign properties.
      Parameters:
      prefix - the local column used to prefix the fk column
      fkProperty - the property name of the foreign key
      Returns:
      the foreign key column
    • toUnderscoreFromCamel

      protected String toUnderscoreFromCamel(String camelCase)
      Convert and return the string to underscore from camel case.
    • toCamelFromUnderscore

      protected String toCamelFromUnderscore(String underscore)
      Convert and return the from string from underscore to camel case.