Interface IdentifierFactory
-
- All Known Implementing Classes:
AbstractIdentifierFactory
,DN2IdentifierFactory
,DNIdentifierFactory
,JPAIdentifierFactory
,JPOXIdentifierFactory
public interface IdentifierFactory
Factory that creates immutable instances of DatastoreIdentifier. Identifiers are of a particular type. Each datastore could invent its own particular types as required, just that the ones here should be the principal types required.
-
-
Field Summary
Fields Modifier and Type Field Description static String
PROPERTY_DEFAULT_CATALOG
static String
PROPERTY_DEFAULT_SCHEMA
static String
PROPERTY_NAMING_FACTORY
static String
PROPERTY_REQUIRED_CASE
static String
PROPERTY_TABLE_PREFIX
static String
PROPERTY_TABLE_SUFFIX
static String
PROPERTY_WORD_SEPARATOR
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description DatastoreAdapter
getDatastoreAdapter()
Accessor for the datastore adapter that we are creating identifiers for.String
getIdentifierInAdapterCase(String identifier)
Accessor for an identifier for use in the datastore adapterString
getIdentifierTruncatedToAdapterColumnLength(String identifier)
Method to truncate the provided identifier as required to the datastore adapter column length (if required)org.datanucleus.store.schema.naming.NamingCase
getNamingCase()
Accessor for the identifier case being used.DatastoreIdentifier
newAdapterIndexFieldIdentifier()
Method to return an identifier for an adapter index column.DatastoreIdentifier
newCandidateKeyIdentifier(Table table, int seq)
Method to generate an identifier for a candidate key.DatastoreIdentifier
newColumnIdentifier(String identifierName)
Method to use to generate an identifier for a column with the supplied name.DatastoreIdentifier
newColumnIdentifier(String javaName, boolean embedded, org.datanucleus.metadata.FieldRole fieldRole, boolean custom)
Method to create an identifier for a column where we want the name based on the supplied java name, and the field has a particular role (and so could have its naming set according to the role).DatastoreIdentifier
newDiscriminatorFieldIdentifier()
Method to return an identifier for a discriminator column.DatastoreIdentifier
newForeignKeyFieldIdentifier(org.datanucleus.metadata.AbstractMemberMetaData ownerFmd, org.datanucleus.metadata.AbstractMemberMetaData relatedFmd, DatastoreIdentifier destinationId, boolean embedded, org.datanucleus.metadata.FieldRole fieldRole)
Method to generate a FK/FK-index field identifier.DatastoreIdentifier
newForeignKeyIdentifier(Table table, int seq)
Method to create an identifier for a foreign key.DatastoreIdentifier
newIdentifier(DatastoreIdentifier identifier, String suffix)
Method to return a new Identifier based on the passed identifier, but adding on the passed suffixDatastoreIdentifier
newIdentifier(IdentifierType identifierType, String identifierName)
To be called when we want an identifier name creating based on the identifier.DatastoreIdentifier
newIndexFieldIdentifier(org.datanucleus.metadata.AbstractMemberMetaData mmd)
Method to return an identifier for an index (ordering) column.DatastoreIdentifier
newIndexIdentifier(Table table, boolean isUnique, int seq)
Method to generate an identifier for an index.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
newPrimaryKeyIdentifier(Table table)
Method to generate an identifier for a primary key.DatastoreIdentifier
newReferenceFieldIdentifier(org.datanucleus.metadata.AbstractMemberMetaData refMetaData, org.datanucleus.metadata.AbstractClassMetaData implMetaData, DatastoreIdentifier implIdentifier, boolean embedded, org.datanucleus.metadata.FieldRole fieldRole)
Method to generate an identifier name for reference field, based on the metadata for the field, and the ClassMetaData for the implementation.DatastoreIdentifier
newSequenceIdentifier(String sequenceName)
Method to generate an identifier for a sequence using the passed name.DatastoreIdentifier
newTableIdentifier(String identifierName)
Method to use to generate an identifier for a table with the supplied name in the default catalog/schema.DatastoreIdentifier
newTableIdentifier(String identifierName, String catalogName, String schemaName)
Method to use to generate an identifier for a table with the supplied name.DatastoreIdentifier
newTableIdentifier(org.datanucleus.metadata.AbstractClassMetaData md)
Method to return a Table identifier for the specified class.DatastoreIdentifier
newTableIdentifier(org.datanucleus.metadata.AbstractMemberMetaData fmd)
Method to return a Table identifier for the specified field.DatastoreIdentifier
newVersionFieldIdentifier()
Method to return an identifier for a version column.
-
-
-
Field Detail
-
PROPERTY_DEFAULT_CATALOG
static final String PROPERTY_DEFAULT_CATALOG
- See Also:
- Constant Field Values
-
PROPERTY_DEFAULT_SCHEMA
static final String PROPERTY_DEFAULT_SCHEMA
- See Also:
- Constant Field Values
-
PROPERTY_REQUIRED_CASE
static final String PROPERTY_REQUIRED_CASE
- See Also:
- Constant Field Values
-
PROPERTY_TABLE_PREFIX
static final String PROPERTY_TABLE_PREFIX
- See Also:
- Constant Field Values
-
PROPERTY_TABLE_SUFFIX
static final String PROPERTY_TABLE_SUFFIX
- See Also:
- Constant Field Values
-
PROPERTY_WORD_SEPARATOR
static final String PROPERTY_WORD_SEPARATOR
- See Also:
- Constant Field Values
-
PROPERTY_NAMING_FACTORY
static final String PROPERTY_NAMING_FACTORY
- See Also:
- Constant Field Values
-
-
Method Detail
-
getDatastoreAdapter
DatastoreAdapter getDatastoreAdapter()
Accessor for the datastore adapter that we are creating identifiers for.- Returns:
- The datastore adapter
-
getNamingCase
org.datanucleus.store.schema.naming.NamingCase getNamingCase()
Accessor for the identifier case being used.- Returns:
- The identifier case
-
getIdentifierInAdapterCase
String getIdentifierInAdapterCase(String identifier)
Accessor for an identifier for use in the datastore adapter- Parameters:
identifier
- The identifier name- Returns:
- Identifier name for use with the datastore adapter
-
getIdentifierTruncatedToAdapterColumnLength
String getIdentifierTruncatedToAdapterColumnLength(String identifier)
Method to truncate the provided identifier as required to the datastore adapter column length (if required)- Parameters:
identifier
- The identifier- Returns:
- The truncated variant (if the length was longer than the max column identifier length);
-
newIdentifier
DatastoreIdentifier newIdentifier(IdentifierType identifierType, String identifierName)
To be called when we want an identifier name creating based on the identifier. Creates identifier for COLUMN, FOREIGN KEY, INDEX and TABLE- Parameters:
identifierType
- the type of identifier to be createdidentifierName
- The identifier name- Returns:
- The DatastoreIdentifier
-
newTableIdentifier
DatastoreIdentifier newTableIdentifier(String identifierName)
Method to use to generate an identifier for a table with the supplied name in the default catalog/schema. The passed name will not be changed (other than in its case) although it may be truncated to fit the maximum length permitted for a table identifier.- Parameters:
identifierName
- The identifier name- Returns:
- The DatastoreIdentifier for the table
-
newTableIdentifier
DatastoreIdentifier newTableIdentifier(String identifierName, String catalogName, String schemaName)
Method to use to generate an identifier for a table with the supplied name. The passed name will not be changed (other than in its case) although it may be truncated to fit the maximum length permitted for a table identifier.- Parameters:
identifierName
- The identifier name for the tablecatalogName
- Optional catalog nameschemaName
- Optional schema name- Returns:
- The DatastoreIdentifier for the table
-
newTableIdentifier
DatastoreIdentifier newTableIdentifier(org.datanucleus.metadata.AbstractClassMetaData md)
Method to return a Table identifier for the specified class.- Parameters:
md
- Meta data for the class- Returns:
- The identifier for the table
-
newTableIdentifier
DatastoreIdentifier newTableIdentifier(org.datanucleus.metadata.AbstractMemberMetaData fmd)
Method to return a Table identifier for the specified field.- Parameters:
fmd
- Meta data for the field- Returns:
- The identifier for the table
-
newColumnIdentifier
DatastoreIdentifier newColumnIdentifier(String identifierName)
Method to use to generate an identifier for a column with the supplied name. The passed name will not be changed (other than in its case) although it may be truncated to fit the maximum length permitted for a column identifier.- Parameters:
identifierName
- The identifier name- Returns:
- The DatastoreIdentifier
-
newColumnIdentifier
DatastoreIdentifier newColumnIdentifier(String javaName, boolean embedded, org.datanucleus.metadata.FieldRole fieldRole, boolean custom)
Method to create an identifier for a column where we want the name based on the supplied java name, and the field has a particular role (and so could have its naming set according to the role).- Parameters:
javaName
- The java field nameembedded
- Whether the identifier is for a field embeddedfieldRole
- The role to be performed by this column e.g FK, Index ?custom
- Whether this has a user-defined name- Returns:
- The DatastoreIdentifier
-
newReferenceFieldIdentifier
DatastoreIdentifier newReferenceFieldIdentifier(org.datanucleus.metadata.AbstractMemberMetaData refMetaData, org.datanucleus.metadata.AbstractClassMetaData implMetaData, DatastoreIdentifier implIdentifier, boolean embedded, org.datanucleus.metadata.FieldRole fieldRole)
Method to generate an identifier name for reference field, based on the metadata for the field, and the ClassMetaData for the implementation.- Parameters:
refMetaData
- the MetaData for the reference fieldimplMetaData
- the AbstractClassMetaData for this implementationimplIdentifier
- PK identifier for the implementationembedded
- Whether the identifier is for a field embeddedfieldRole
- The role to be performed by this column e.g FK, collection element ?- Returns:
- The DatastoreIdentifier
-
newDiscriminatorFieldIdentifier
DatastoreIdentifier newDiscriminatorFieldIdentifier()
Method to return an identifier for a discriminator column.- Returns:
- The discriminator column identifier
-
newVersionFieldIdentifier
DatastoreIdentifier newVersionFieldIdentifier()
Method to return an identifier for a version column.- Returns:
- The version column identifier
-
newIdentifier
DatastoreIdentifier newIdentifier(DatastoreIdentifier identifier, String suffix)
Method to return a new Identifier based on the passed identifier, but adding on the passed suffix- Parameters:
identifier
- The current identifiersuffix
- The suffix- Returns:
- The new identifier
-
newJoinTableFieldIdentifier
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.- Parameters:
ownerFmd
- MetaData for the owner fieldrelatedFmd
- MetaData for the related field (if bidirectional)destinationId
- Identifier for the identity field of the destination tableembedded
- 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
DatastoreIdentifier newForeignKeyFieldIdentifier(org.datanucleus.metadata.AbstractMemberMetaData ownerFmd, org.datanucleus.metadata.AbstractMemberMetaData relatedFmd, 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 fieldrelatedFmd
- MetaData for the related field (if bidirectional)destinationId
- 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
-
newIndexFieldIdentifier
DatastoreIdentifier newIndexFieldIdentifier(org.datanucleus.metadata.AbstractMemberMetaData mmd)
Method to return an identifier for an index (ordering) column.- Parameters:
mmd
- Metadata for the field/property that we require to add an index(order) column for- Returns:
- The index column identifier
-
newAdapterIndexFieldIdentifier
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.- Returns:
- The index column identifier
-
newSequenceIdentifier
DatastoreIdentifier newSequenceIdentifier(String sequenceName)
Method to generate an identifier for a sequence using the passed name.- Parameters:
sequenceName
- the name of the sequence to use- Returns:
- The DatastoreIdentifier
-
newPrimaryKeyIdentifier
DatastoreIdentifier newPrimaryKeyIdentifier(Table table)
Method to generate an identifier for a primary key.- Parameters:
table
- the table- Returns:
- The DatastoreIdentifier
-
newIndexIdentifier
DatastoreIdentifier newIndexIdentifier(Table table, boolean isUnique, int seq)
Method to generate an identifier for an index.- Parameters:
table
- the tableisUnique
- if the index is uniqueseq
- the sequential number- Returns:
- The DatastoreIdentifier
-
newCandidateKeyIdentifier
DatastoreIdentifier newCandidateKeyIdentifier(Table table, int seq)
Method to generate an identifier for a candidate key.- Parameters:
table
- the tableseq
- Sequence number- Returns:
- The DatastoreIdentifier
-
newForeignKeyIdentifier
DatastoreIdentifier newForeignKeyIdentifier(Table table, int seq)
Method to create an identifier for a foreign key.- Parameters:
table
- the tableseq
- the sequential number- Returns:
- The DatastoreIdentifier
-
-