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