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 -
Method Summary
Modifier and TypeMethodDescriptionAccessor for the datastore adapter that we are creating identifiers for.getIdentifierInAdapterCase
(String identifier) Accessor for an identifier for use in the datastore adaptergetIdentifierTruncatedToAdapterColumnLength
(String identifier) Method to truncate the provided identifier as required to the datastore adapter column length (if required)org.datanucleus.store.schema.naming.NamingCase
Accessor for the identifier case being used.Method to return an identifier for an adapter index column.newCandidateKeyIdentifier
(Table table, int seq) Method to generate an identifier for a candidate key.newColumnIdentifier
(String identifierName) Method to use to generate an identifier for a column with the supplied name.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).Method to return an identifier for a discriminator column.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.newForeignKeyIdentifier
(Table table, int seq) Method to create an identifier for a foreign key.newIdentifier
(DatastoreIdentifier identifier, String suffix) Method to return a new Identifier based on the passed identifier, but adding on the passed suffixnewIdentifier
(IdentifierType identifierType, String identifierName) To be called when we want an identifier name creating based on the identifier.newIndexFieldIdentifier
(org.datanucleus.metadata.AbstractMemberMetaData mmd) Method to return an identifier for an index (ordering) column.newIndexIdentifier
(Table table, boolean isUnique, int seq) Method to generate an identifier for an index.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.newPrimaryKeyIdentifier
(Table table) Method to generate an identifier for a primary key.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.newSequenceIdentifier
(String sequenceName) Method to generate an identifier for a sequence using the passed name.newTableIdentifier
(String identifierName) Method to use to generate an identifier for a table with the supplied name in the default catalog/schema.newTableIdentifier
(String identifierName, String catalogName, String schemaName) Method to use to generate an identifier for a table with the supplied name.newTableIdentifier
(org.datanucleus.metadata.AbstractClassMetaData md) Method to return a Table identifier for the specified class.newTableIdentifier
(org.datanucleus.metadata.AbstractMemberMetaData fmd) Method to return a Table identifier for the specified field.Method to return an identifier for a version column.
-
Field Details
-
PROPERTY_DEFAULT_CATALOG
- See Also:
-
PROPERTY_DEFAULT_SCHEMA
- See Also:
-
PROPERTY_REQUIRED_CASE
- See Also:
-
PROPERTY_TABLE_PREFIX
- See Also:
-
PROPERTY_TABLE_SUFFIX
- See Also:
-
PROPERTY_WORD_SEPARATOR
- See Also:
-
PROPERTY_NAMING_FACTORY
- See Also:
-
-
Method Details
-
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
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
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
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
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
Method to return a Table identifier for the specified class.- Parameters:
md
- Meta data for the class- Returns:
- The identifier for the table
-
newTableIdentifier
Method to return a Table identifier for the specified field.- Parameters:
fmd
- Meta data for the field- Returns:
- The identifier for the table
-
newColumnIdentifier
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
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
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
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
Method to generate an identifier for a primary key.- Parameters:
table
- the table- Returns:
- The DatastoreIdentifier
-
newIndexIdentifier
Method to generate an identifier for an index.- Parameters:
table
- the tableisUnique
- if the index is uniqueseq
- the sequential number- Returns:
- The DatastoreIdentifier
-
newCandidateKeyIdentifier
Method to generate an identifier for a candidate key.- Parameters:
table
- the tableseq
- Sequence number- Returns:
- The DatastoreIdentifier
-
newForeignKeyIdentifier
Method to create an identifier for a foreign key.- Parameters:
table
- the tableseq
- the sequential number- Returns:
- The DatastoreIdentifier
-