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)
-
-
Field Summary
-
Fields inherited from class org.datanucleus.store.schema.naming.AbstractNamingFactory
clr, maxLengthByComponent, namingCase, nucCtx, quoteString, reservedWords, wordSeparator
-
-
Constructor Summary
Constructors Constructor Description DN2NamingFactory(NucleusContext nucCtx)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetColumnName(AbstractClassMetaData cmd, ColumnType type)Method to return the name of the column for the specified class (version, datastore-id, discriminator etc).java.lang.StringgetColumnName(AbstractMemberMetaData mmd, ColumnType type, int position)Method to return the name of the column for the position of the specified field.java.lang.StringgetTableName(AbstractMemberMetaData mmd)Method to return the name of the (join) table for the specified field.-
Methods inherited from class org.datanucleus.store.schema.naming.AbstractNamingFactory
getColumnName, getColumnName, getConstraintName, getConstraintName, getConstraintName, getMaximumLengthForComponent, getNameInRequiredCase, getSequenceName, getTableName, prepareIdentifierNameForUse, setMaximumLength, setNamingCase, setQuoteString, setReservedKeywords, setWordSeparator, truncate
-
-
-
-
Constructor Detail
-
DN2NamingFactory
public DN2NamingFactory(NucleusContext nucCtx)
-
-
Method Detail
-
getTableName
public java.lang.String getTableName(AbstractMemberMetaData mmd)
Description copied from interface:NamingFactoryMethod 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 java.lang.String getColumnName(AbstractClassMetaData cmd, ColumnType type)
Description copied from interface:NamingFactoryMethod to return the name of the column for the specified class (version, datastore-id, discriminator etc).- Parameters:
cmd- Metadata for the classtype- Column type- Returns:
- Name of the column
-
getColumnName
public java.lang.String getColumnName(AbstractMemberMetaData mmd, ColumnType type, int position)
Description copied from interface:NamingFactoryMethod 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 fieldtype- Type of columnposition- Position of the column- Returns:
- The column name
-
-