Class DN2IdentifierFactory
- java.lang.Object
-
- org.datanucleus.store.rdbms.identifier.AbstractIdentifierFactory
-
- org.datanucleus.store.rdbms.identifier.DNIdentifierFactory
-
- org.datanucleus.store.rdbms.identifier.DN2IdentifierFactory
-
- All Implemented Interfaces:
IdentifierFactory
public class DN2IdentifierFactory extends DNIdentifierFactory
Factory that creates immutable instances of DatastoreIdentifier for mapped datastores. Provides a more concise and consistent alternative to "jpox". Naming 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 the PK field "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"
-
-
Field Summary
-
Fields inherited from class org.datanucleus.store.rdbms.identifier.DNIdentifierFactory
tablePrefix, tableSuffix
-
Fields inherited from class org.datanucleus.store.rdbms.identifier.AbstractIdentifierFactory
candidates, CASE_LOWER, CASE_PRESERVE, CASE_UPPER, clr, columns, dba, defaultCatalogName, defaultSchemaName, foreignkeys, indexes, namingCase, namingFactory, primarykeys, quoteString, references, sequences, tables, wordSeparator
-
Fields inherited from interface org.datanucleus.store.rdbms.identifier.IdentifierFactory
PROPERTY_DEFAULT_CATALOG, PROPERTY_DEFAULT_SCHEMA, PROPERTY_NAMING_FACTORY, PROPERTY_REQUIRED_CASE, PROPERTY_TABLE_PREFIX, PROPERTY_TABLE_SUFFIX, PROPERTY_WORD_SEPARATOR
-
-
Constructor Summary
Constructors Constructor Description DN2IdentifierFactory(DatastoreAdapter dba, org.datanucleus.ClassLoaderResolver clr, Map props)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
generateIdentifierNameForJavaName(String javaName)
Generate a datastore identifier from a Java identifier.DatastoreIdentifier
newAdapterIndexFieldIdentifier()
Method to return an identifier for an adapter index column.DatastoreIdentifier
newForeignKeyFieldIdentifier(org.datanucleus.metadata.AbstractMemberMetaData ownerFmd, DatastoreIdentifier destinationId, boolean embedded, org.datanucleus.metadata.FieldRole fieldRole)
Method to generate a FK/FK-index field identifier.DatastoreIdentifier
newIndexFieldIdentifier(org.datanucleus.metadata.AbstractMemberMetaData mmd)
Method to return an identifier for an index (ordering) column.DatastoreIdentifier
newJoinTableFieldIdentifier(org.datanucleus.metadata.AbstractMemberMetaData ownerFmd, org.datanucleus.metadata.AbstractMemberMetaData relatedFmd, DatastoreIdentifier destinationId, boolean embedded, org.datanucleus.metadata.FieldRole fieldRole)
Method to generate a join-table identifier.DatastoreIdentifier
newVersionFieldIdentifier()
Method to return an identifier for a version column.-
Methods inherited from class org.datanucleus.store.rdbms.identifier.DNIdentifierFactory
getColumnIdentifierSuffix, newDiscriminatorFieldIdentifier, newForeignKeyFieldIdentifier, newReferenceFieldIdentifier, newTableIdentifier, newTableIdentifier
-
Methods inherited from class org.datanucleus.store.rdbms.identifier.AbstractIdentifierFactory
getDatastoreAdapter, getIdentifierInAdapterCase, getIdentifierNamePartsFromName, getIdentifierTruncatedToAdapterColumnLength, getNamingCase, getWordSeparator, newCandidateKeyIdentifier, newColumnIdentifier, newColumnIdentifier, newForeignKeyIdentifier, newIdentifier, newIdentifier, newIndexIdentifier, newPrimaryKeyIdentifier, newSequenceIdentifier, newTableIdentifier, newTableIdentifier, setCatalogSchemaForTable, truncate
-
-
-
-
Constructor Detail
-
DN2IdentifierFactory
public DN2IdentifierFactory(DatastoreAdapter dba, org.datanucleus.ClassLoaderResolver clr, Map props)
Constructor. The properties accepted are- RequiredCase : what case the identifiers should be in
- DefaultCatalog : default catalog to use (if any)
- DefaultSchema : default schema to use (if any)
- WordSeparator : separator character(s) between identifier words
- TablePrefix : Prefix to prepend to all table identifiers
- TableSuffix : Suffix to append to all table identifiers
- Parameters:
dba
- Database adapterclr
- ClassLoader resolverprops
- Any properties controlling identifier generation
-
-
Method Detail
-
newJoinTableFieldIdentifier
public DatastoreIdentifier newJoinTableFieldIdentifier(org.datanucleus.metadata.AbstractMemberMetaData ownerFmd, org.datanucleus.metadata.AbstractMemberMetaData relatedFmd, DatastoreIdentifier destinationId, boolean embedded, org.datanucleus.metadata.FieldRole fieldRole)
Method to generate a join-table identifier. The identifier could be for a foreign-key to another table (if the destinationId is provided), or could be for a simple column in the join table.- Specified by:
newJoinTableFieldIdentifier
in interfaceIdentifierFactory
- Overrides:
newJoinTableFieldIdentifier
in classDNIdentifierFactory
- Parameters:
ownerFmd
- MetaData for the owner fieldrelatedFmd
- MetaData for the related fielddestinationId
- Identifier for the identity field of the destination (if FK)embedded
- Whether the identifier is for a field embeddedfieldRole
- The role to be performed by this column e.g FK, collection element ?- Returns:
- The identifier.
-
newForeignKeyFieldIdentifier
public DatastoreIdentifier newForeignKeyFieldIdentifier(org.datanucleus.metadata.AbstractMemberMetaData ownerFmd, DatastoreIdentifier destinationId, boolean embedded, org.datanucleus.metadata.FieldRole fieldRole)
Method to generate a FK/FK-index field identifier. The identifier could be for the FK field itself, or for a related index for the FK.- Parameters:
ownerFmd
- MetaData for the owner fielddestinationId
- Identifier for the identity field of the destination table (if strict FK)embedded
- Whether the identifier is for a field embeddedfieldRole
- The role to be performed by this column e.g owner, index ?- Returns:
- The identifier
-
newVersionFieldIdentifier
public DatastoreIdentifier newVersionFieldIdentifier()
Method to return an identifier for a version column.- Specified by:
newVersionFieldIdentifier
in interfaceIdentifierFactory
- Overrides:
newVersionFieldIdentifier
in classDNIdentifierFactory
- Returns:
- The version column identifier
-
newIndexFieldIdentifier
public DatastoreIdentifier newIndexFieldIdentifier(org.datanucleus.metadata.AbstractMemberMetaData mmd)
Method to return an identifier for an index (ordering) column.- Specified by:
newIndexFieldIdentifier
in interfaceIdentifierFactory
- Overrides:
newIndexFieldIdentifier
in classDNIdentifierFactory
- Parameters:
mmd
- MetaData for the field/property - not used here- Returns:
- The index column identifier
-
newAdapterIndexFieldIdentifier
public DatastoreIdentifier newAdapterIndexFieldIdentifier()
Method to return an identifier for an adapter index column. An "adapter index" is a column added to be part of a primary key when some other column cant perform that role.- Specified by:
newAdapterIndexFieldIdentifier
in interfaceIdentifierFactory
- Overrides:
newAdapterIndexFieldIdentifier
in classDNIdentifierFactory
- Returns:
- The index column identifier
-
generateIdentifierNameForJavaName
public String generateIdentifierNameForJavaName(String javaName)
Generate a datastore identifier from a Java identifier.Conversion consists of breaking the identifier into words, converting each word to upper-case, and separating each one with a word separator. Words are identified by a leading upper-case character. Any leading or trailing underscores are removed.
- Overrides:
generateIdentifierNameForJavaName
in classDNIdentifierFactory
- Parameters:
javaName
- the Java identifier.- Returns:
- The datastore identifier
-
-