Class DN2NamingFactory
java.lang.Object
org.datanucleus.store.schema.naming.AbstractNamingFactory
org.datanucleus.store.schema.naming.DN2NamingFactory
- All Implemented Interfaces:
NamingFactory
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 -
Method Summary
Modifier and TypeMethodDescriptiongetColumnName
(AbstractClassMetaData cmd, ColumnType type) Method to return the name of the column for the specified class (version, datastore-id, discriminator etc).getColumnName
(AbstractMemberMetaData mmd, ColumnType type, int position) Method to return the name of the column for the position of the specified field.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 Details
-
DN2NamingFactory
-
-
Method Details
-
getTableName
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
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 classtype
- Column type- Returns:
- Name of the column
-
getColumnName
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 fieldtype
- Type of columnposition
- Position of the column- Returns:
- The column name
-