Class DN2NamingFactory

java.lang.Object
org.datanucleus.store.schema.naming.AbstractNamingFactory
org.datanucleus.store.schema.naming.DN2NamingFactory
All Implemented Interfaces:
NamingFactory

public class DN2NamingFactory extends AbstractNamingFactory
Naming factory used by DataNucleus v3.x onwards. Refer to DataNucleus docs, but the rules are as follows
  • Class called "MyClass" will generate table name of "MYCLASS"
  • Field called "myField" will generate column name of "MYFIELD"
  • Datastore id field for class "MyClass" will have be "MYCLASS_ID"
  • Join table will be named after the class and field, so "MyClass" with field "myField" will become a table with name "MYCLASS_MYFIELD".
  • Columns of a join table will be named after the PK fields of the owner and element. So something like "MYCLASS_ID_OID" and "MYELEMENT_ID_EID"
  • Discriminator field columns will, by default, be called "DISCRIMINATOR"
  • Index field columns will, by default, be called "IDX"
  • Version field columns will, by default, be called "VERSION"
  • Adapter index field columns will, by default, be called "IDX"
  • Index names will, by default, be called "{class}_{field}_IDX" or "{class}_{position}_IDX"
  • Sequence names will default to being called "{seqName}_SEQ" where seqName is the 'name' of the SequenceMetaData

Note that in addition to the above rules,

  • if there are limitations on length of name for a particular component then the name will be truncated.
  • the name will be changed to match any specified "case" (see setNamingCase)
  • Constructor Details

  • Method Details

    • getTableName

      public String getTableName(AbstractMemberMetaData mmd)
      Description copied from interface: NamingFactory
      Method to return the name of the (join) table for the specified field.
      Parameters:
      mmd - Metadata for the field/property needing a join table
      Returns:
      Name of the table
    • getColumnName

      public String getColumnName(AbstractClassMetaData cmd, ColumnType type)
      Description copied from interface: NamingFactory
      Method to return the name of the column for the specified class (version, datastore-id, discriminator etc).
      Parameters:
      cmd - Metadata for the class
      type - Column type
      Returns:
      Name of the column
    • getColumnName

      public String getColumnName(AbstractMemberMetaData mmd, ColumnType type, int position)
      Description copied from interface: NamingFactory
      Method to return the name of the column for the position of the specified field. Normally the position will be 0 since most fields map to a single column, but where you have a FK to an object with composite id, or where the Java type maps to multiple columns then the position is used.
      Parameters:
      mmd - Metadata for the field
      type - Type of column
      position - Position of the column
      Returns:
      The column name