Class JPANamingFactory

  • All Implemented Interfaces:
    NamingFactory

    public class JPANamingFactory
    extends AbstractNamingFactory
    Naming factory following JPA specification rules. 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-identity column for class "MyClass" will be "MYCLASS_ID" (not part of JPA)
    • Join table will be named after the ownerClass and the otherClass so "MyClass" joining to "MyOtherClass" will have a join table called "MYCLASS_MYOTHERCLASS"
    • 1-N uni between "MyClass" (field="myField") and "MyElement" will have FK in "MYELEMENT" of MYFIELD_MYCLASS_ID
    • 1-N bi between "MyClass" (field="myField") and "MyElement" (field="myClassRef") will have FK in "MYELEMENT" of name "MYCLASSREF_MYCLASS_ID".
    • 1-1 uni between "MyClass" (field="myField") and "MyElement" will have FK in "MYCLASS" of name "MYFIELD_MYELEMENT_ID"
    • Discriminator field columns will, by default, be called "DTYPE"
    • Index field columns will, for field "myField", be called "MYFIELD_ORDER"
    • 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 Detail

      • JPANamingFactory

        public JPANamingFactory​(NucleusContext nucCtx)
    • Method Detail

      • 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