Class ClassTable
java.lang.Object
org.datanucleus.store.rdbms.table.AbstractTable
org.datanucleus.store.rdbms.table.TableImpl
org.datanucleus.store.rdbms.table.AbstractClassTable
org.datanucleus.store.rdbms.table.ClassTable
- All Implemented Interfaces:
DatastoreClass
,Table
,org.datanucleus.store.schema.table.Table
Table representing a Java class (or classes) as a first class object (FCO).
Uses the inheritance strategy to control whether this represents multiple classes or just the one class.
Mappings
This class adds some additional mappings over what the superclass provides. Here we add- externalFkMappings - any mappings for Collections that have no associated field in this class, providing the foreign key column(s)
- externalOrderMappings - mappings for any ordering column used by Lists for ordering elements of this class
- externalFkDiscriminatorMappings - mappings for any discriminator column used when sharing external foreign keys to distinguish the element owner field
Classes
A table can represent multiple classes. It has a nominal owner which is the class that has an inheritance strategy of "new-table". All classes that utilise this table have their MetaData stored in this object.Secondary Tables
This class represents a "primary" table. That is, the main table where objects of a class are persisted. It can have several "secondary" tables where some of the classes fields are stored at persistence.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Map
<String, Collection<org.datanucleus.metadata.AbstractMemberMetaData>> Callbacks that have been applied keyed by the managed class.(package private) Map
<org.datanucleus.metadata.AbstractMemberMetaData, CandidateKey> private final org.datanucleus.metadata.ClassMetaData
MetaData for the principal class being stored here.private String
DDL statement for creating the table, if using user defined table schema.private Map
<org.datanucleus.metadata.AbstractMemberMetaData, JavaTypeMapping> Mappings for FK Collections/Lists relation discriminators not managed by this class (1-N unidirectional).private Map
<org.datanucleus.metadata.AbstractMemberMetaData, JavaTypeMapping> Mappings for FK Collections/Lists not managed by this class (1-N unidirectional).private Map
<org.datanucleus.metadata.AbstractMemberMetaData, JavaTypeMapping> Mappings for FK Lists order columns not managed by this class (1-N unidirectional).private final Collection
<org.datanucleus.metadata.AbstractClassMetaData> MetaData for all classes being managed here.protected String
Name of class currently being processed in manageClass (if any).protected boolean
Flag to run the callbacks after the current class is managed fully.private Map
<String, SecondaryTable> Secondary tables for this table (if any).private ClassTable
Table above this table storing superclass information (if any).private org.datanucleus.util.MacroString
User defined table schemaSet of unmapped "Column" objects that have no associated field (and hence ColumnMapping).Fields inherited from class org.datanucleus.store.rdbms.table.AbstractClassTable
createTimestampMapping, createUserMapping, datastoreIdMapping, discriminatorMapping, discriminatorMetaData, highestMemberNumber, idMapping, memberMappingsMap, multitenancyMapping, pkMappings, softDeleteMapping, updateTimestampMapping, updateUserMapping, versionMapping, versionMetaData
Fields inherited from class org.datanucleus.store.rdbms.table.AbstractTable
columns, columnsByIdentifier, dba, existsInDatastore, identifier, state, storeMgr, TABLE_STATE_INITIALIZED, TABLE_STATE_INITIALIZED_MODIFIED, TABLE_STATE_NEW, TABLE_STATE_PK_INITIALIZED, TABLE_STATE_VALIDATED
-
Constructor Summary
ConstructorsConstructorDescriptionClassTable
(DatastoreIdentifier tableName, RDBMSStoreManager storeMgr, org.datanucleus.metadata.ClassMetaData cmd) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
addExpectedForeignKeysForEmbeddedPCField
(List<ForeignKey> foreignKeys, boolean autoMode, org.datanucleus.ClassLoaderResolver clr, EmbeddedPCMapping embeddedMapping) Convenience method to add the expected FKs for an embedded PC field.private JavaTypeMapping
addOrderColumn
(org.datanucleus.metadata.AbstractMemberMetaData mmd, org.datanucleus.ClassLoaderResolver clr) Adds an ordering column to the element table (this) in FK list relationships.private JavaTypeMapping
addOrderMapping
(org.datanucleus.metadata.AbstractMemberMetaData mmd, JavaTypeMapping orderMapping, org.datanucleus.ClassLoaderResolver clr) Convenience method to add an order mapping to the table.Accessor for the base datastore class.getBaseDatastoreClassWithMember
(org.datanucleus.metadata.AbstractMemberMetaData mmd) Convenience accessor for the base table for this table which has the specified member.private CandidateKey
getCandidateKeyForUniqueMetaData
(org.datanucleus.metadata.UniqueMetaData umd) Convenience method to convert a UniqueMetaData into a CandidateKey.org.datanucleus.metadata.ClassMetaData
Accessor for the (primary) class MetaData.private org.datanucleus.metadata.AbstractClassMetaData
getClassWithPrimaryKeyForClass
(org.datanucleus.metadata.AbstractClassMetaData cmd, org.datanucleus.ClassLoaderResolver clr) Utility to navigate the inheritance hierarchy to find the base class that defines the primary keys for this tree.final org.datanucleus.metadata.DiscriminatorMetaData
Accessor for Discriminator MetaDataprotected List
<CandidateKey> Accessor for the expected candidate keys for this table.getExpectedForeignKeys
(org.datanucleus.ClassLoaderResolver clr) Accessor for the expected foreign keys for this table.getExpectedIndices
(org.datanucleus.ClassLoaderResolver clr) Accessor for the indices for this table.private Map
<org.datanucleus.metadata.AbstractMemberMetaData, JavaTypeMapping> Accessor for all of the external FK discriminator mappings.private Map
<org.datanucleus.metadata.AbstractMemberMetaData, JavaTypeMapping> Accessor for all of the external FK mappings.getExternalMapping
(org.datanucleus.metadata.AbstractMemberMetaData mmd, MappingType mappingType) Accessor for an external mapping for the specified field of the required type.private Map
<org.datanucleus.metadata.AbstractMemberMetaData, JavaTypeMapping> Accessor for all of the order mappings (used by FK Lists, Collections, Arrays)private ForeignKey
getForeignKeyForForeignKeyMetaData
(org.datanucleus.metadata.ForeignKeyMetaData fkmd) Convenience method to create a FK for the specified ForeignKeyMetaData.org.datanucleus.metadata.IdentityType
Accessor for the identity-type.Accessor for a mapping for the ID (persistable) for this table.private Index
getIndexForIndexMetaData
(org.datanucleus.metadata.IndexMetaData imd) Convenience method to convert an IndexMetaData into an Index.private Index
getIndexForIndexMetaDataAndMapping
(org.datanucleus.metadata.IndexMetaData imd, JavaTypeMapping mapping) Convenience method to convert an IndexMetaData and a mapping into an Index.String[]
Accessor for the names of all classes managed by this table.getMemberMapping
(String memberName) Accessor for the java mapping for the named member.getMemberMapping
(org.datanucleus.metadata.AbstractMemberMetaData mmd) Accessor for the field mapping for the specified field.getMemberMappingInDatastoreClass
(org.datanucleus.metadata.AbstractMemberMetaData mmd) Accessor for the mapping for the specified field only in this datastore class.org.datanucleus.metadata.AbstractMemberMetaData
getMetaDataForExternalMapping
(JavaTypeMapping mapping, MappingType mappingType) Accessor for the MetaData for the (owner) field that an external mapping corresponds to.(package private) org.datanucleus.metadata.AbstractMemberMetaData
getMetaDataForMember
(String memberName) Acessor for the MetaData for the member with the specified name.Accessor for the primary key for this table.Collection
<? extends SecondaryDatastoreClass> Accessor for any secondary tables for this table.getSQLCreateStatements
(Properties props) Accessor for the CREATE statements for this table.Accessor for the DROP statements for this table.Accessor for the supertable for this table.private ClassTable
getSupertable
(org.datanucleus.metadata.AbstractClassMetaData theCmd, org.datanucleus.ClassLoaderResolver clr) Utility to find the table above this one.getSurrogateMapping
(org.datanucleus.store.schema.table.SurrogateColumnType colType, boolean allowSuperclasses) Accessor for the mapping for the specified surrogate type.getTableManagingMapping
(JavaTypeMapping mapping) final ClassTable
Convenience method to return the root table with a discriminator in this inheritance tree.getType()
Accessor for the main class represented.final org.datanucleus.metadata.VersionMetaData
Accessor for versionMetaDataboolean
void
initialize
(org.datanucleus.ClassLoaderResolver clr) Method to initialise the table.private void
initializeFKMapUniqueConstraints
(org.datanucleus.metadata.AbstractMemberMetaData ownerMmd) Method to initialise unique constraints for 1-N Map using FK.private void
initializeForClass
(org.datanucleus.metadata.AbstractClassMetaData theCmd, org.datanucleus.ClassLoaderResolver clr) Method to initialise this table to include all fields in the specified class.private void
Initialize the ID Mapping.protected void
initializePK
(org.datanucleus.ClassLoaderResolver clr) Method to initialise the table primary key field(s).boolean
Whether this table is the base table in the inheritance hierarchy.boolean
Whether this table or super table has id (primary key) attributed by the datastoreboolean
Accessor whether the supplied DatastoreClass is a supertable of this table.void
manageClass
(org.datanucleus.metadata.AbstractClassMetaData theCmd, org.datanucleus.ClassLoaderResolver clr) Method that adds the specified class to be managed by this table.private void
manageMembers
(org.datanucleus.metadata.AbstractClassMetaData theCmd, org.datanucleus.ClassLoaderResolver clr, org.datanucleus.metadata.AbstractMemberMetaData[] mmds) Goes through all specified members for the specified class and adds a mapping for each.boolean
managesClass
(String className) Accessor for whether this table manages the specified class.private void
manageUnmappedColumns
(org.datanucleus.metadata.AbstractClassMetaData theCmd, org.datanucleus.ClassLoaderResolver clr) Adds on management of the columns in the defined MetaData that are "unmapped" (have no field associated).void
postInitialize
(org.datanucleus.ClassLoaderResolver clr) Post initilize.void
preInitialize
(org.datanucleus.ClassLoaderResolver clr) Pre-initialize.final void
provideExternalMappings
(MappingConsumer consumer, MappingType mappingType) Provide the mappings to the consumer for all external fields mapped to this table of the specified typevoid
provideMappingsForMembers
(MappingConsumer consumer, org.datanucleus.metadata.AbstractMemberMetaData[] fieldMetaData, boolean includeSecondaryTables) Provide the mappings to the consumer for all absolute field Numbers in this table that are container in the fieldNumbers parameter.void
providePrimaryKeyMappings
(MappingConsumer consumer) Provide the mappings to the consumer for all primary-key fields mapped to this table.void
provideUnmappedColumns
(MappingConsumer consumer) Method to provide all unmapped columns to the consumer.private void
runCallBacks
(org.datanucleus.ClassLoaderResolver clr) Execute the callbacks for the classes that this table maps to.boolean
validateConstraints
(Connection conn, boolean autoCreate, Collection<Throwable> autoCreateErrors, org.datanucleus.ClassLoaderResolver clr) Method to validate the constraints of this table.Methods inherited from class org.datanucleus.store.rdbms.table.AbstractClassTable
addApplicationIdUsingClassTableId, addDatastoreId, addMemberMapping, getMappingForMemberName, getPrimaryTable, getSurrogateColumn, managesMapping, managesMember, provideNonPrimaryKeyMappings, provideSurrogateMapping
Methods inherited from class org.datanucleus.store.rdbms.table.TableImpl
createConstraints, dropConstraints, getSQLAddCandidateKeyStatements, getSQLAddFKStatements, getSQLCreateIndexStatements, initializeColumnInfoForPrimaryKeyColumns, initializeColumnInfoFromDatastore, logMapping, validate, validateColumns, validatePrimaryKey
Methods inherited from class org.datanucleus.store.rdbms.table.AbstractTable
addColumn, addColumnInternal, allowDDLOutput, assertIsInitialized, assertIsInitializedModified, assertIsPKInitialized, assertIsPKUninitialized, assertIsUninitialized, assertIsValidated, create, drop, equals, executeDdlStatement, executeDdlStatementList, exists, getCatalogName, getColumn, getColumnForName, getColumnForPosition, getColumns, getDatastoreIdentifierFullyQualified, getIdentifier, getMemberColumnMappingForEmbeddedMember, getMemberColumnMappingForMember, getMemberColumnMappings, getName, getNumberOfColumns, getSchemaName, getStoreManager, hasColumn, hasColumnName, hashCode, isInitialized, isInitializedModified, isPKInitialized, isValidated, tableExistsInDatastore, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.datanucleus.store.rdbms.table.DatastoreClass
managesMapping, provideNonPrimaryKeyMappings, provideSurrogateMapping, toString
Methods inherited from interface org.datanucleus.store.rdbms.table.Table
addColumn, create, drop, exists, getColumn, getIdentifier, getStoreManager, hasColumn, isInitialized, isInitializedModified, isValidated, validate
Methods inherited from interface org.datanucleus.store.schema.table.Table
getCatalogName, getColumnForName, getColumnForPosition, getColumns, getMemberColumnMappingForEmbeddedMember, getMemberColumnMappingForMember, getMemberColumnMappings, getName, getNumberOfColumns, getSchemaName, getSurrogateColumn
-
Field Details
-
cmd
private final org.datanucleus.metadata.ClassMetaData cmdMetaData for the principal class being stored here. In inheritance situations where multiple classes share the same table, this will be the class which uses "new-table" strategy. -
managedClassMetaData
MetaData for all classes being managed here. -
callbacksAppliedForManagedClass
private final Map<String,Collection<org.datanucleus.metadata.AbstractMemberMetaData>> callbacksAppliedForManagedClassCallbacks that have been applied keyed by the managed class. -
supertable
Table above this table storing superclass information (if any). -
secondaryTables
Secondary tables for this table (if any). -
externalFkMappings
Mappings for FK Collections/Lists not managed by this class (1-N unidirectional). Keyed by the metadata of the owner field/property. -
externalFkDiscriminatorMappings
private Map<org.datanucleus.metadata.AbstractMemberMetaData,JavaTypeMapping> externalFkDiscriminatorMappingsMappings for FK Collections/Lists relation discriminators not managed by this class (1-N unidirectional). Keyed by the metadata of the owner field/property. -
externalOrderMappings
Mappings for FK Lists order columns not managed by this class (1-N unidirectional). Keyed by the metadata of the owner field/property. -
tableDef
private org.datanucleus.util.MacroString tableDefUser defined table schema -
createStatementDDL
DDL statement for creating the table, if using user defined table schema. -
candidateKeysByMapField
Map<org.datanucleus.metadata.AbstractMemberMetaData,CandidateKey> candidateKeysByMapField -
unmappedColumns
Set of unmapped "Column" objects that have no associated field (and hence ColumnMapping). -
managingClassCurrent
Name of class currently being processed in manageClass (if any). -
runCallbacksAfterManageClass
protected boolean runCallbacksAfterManageClassFlag to run the callbacks after the current class is managed fully.
-
-
Constructor Details
-
ClassTable
public ClassTable(DatastoreIdentifier tableName, RDBMSStoreManager storeMgr, org.datanucleus.metadata.ClassMetaData cmd) Constructor.- Parameters:
tableName
- Table name SQL identifierstoreMgr
- Store Manager to manage this tablecmd
- MetaData for the class.
-
-
Method Details
-
preInitialize
public void preInitialize(org.datanucleus.ClassLoaderResolver clr) Pre-initialize. We require any supertable, and the PK to be ready before we start initialisation.- Specified by:
preInitialize
in interfaceTable
- Overrides:
preInitialize
in classAbstractTable
- Parameters:
clr
- the ClassLoaderResolver
-
initialize
public void initialize(org.datanucleus.ClassLoaderResolver clr) Method to initialise the table. This adds the columns based on the MetaData representation for the class being represented by this table.- Specified by:
initialize
in interfaceTable
- Parameters:
clr
- The ClassLoaderResolver
-
postInitialize
public void postInitialize(org.datanucleus.ClassLoaderResolver clr) Post initilize. For things that must be set after all classes have been initialized before- Specified by:
postInitialize
in interfaceTable
- Overrides:
postInitialize
in classAbstractTable
- Parameters:
clr
- the ClassLoaderResolver
-
manageClass
public void manageClass(org.datanucleus.metadata.AbstractClassMetaData theCmd, org.datanucleus.ClassLoaderResolver clr) Method that adds the specified class to be managed by this table. Will provide mapping of all persistent fields to their underlying columns, map all necessary identity fields, and manage all "unmapped" columns that have no associated field.- Parameters:
theCmd
- ClassMetaData for the class to be managedclr
- The ClassLoaderResolver
-
getManagedClasses
Accessor for the names of all classes managed by this table.- Specified by:
getManagedClasses
in interfaceDatastoreClass
- Returns:
- Names of the classes managed (stored) here
-
manageMembers
private void manageMembers(org.datanucleus.metadata.AbstractClassMetaData theCmd, org.datanucleus.ClassLoaderResolver clr, org.datanucleus.metadata.AbstractMemberMetaData[] mmds) Goes through all specified members for the specified class and adds a mapping for each. Ignores primary-key fields which are added elsewhere.- Parameters:
theCmd
- ClassMetaData for the class to be managedclr
- The ClassLoaderResolvermmds
- the fields/properties to manage
-
manageUnmappedColumns
private void manageUnmappedColumns(org.datanucleus.metadata.AbstractClassMetaData theCmd, org.datanucleus.ClassLoaderResolver clr) Adds on management of the columns in the defined MetaData that are "unmapped" (have no field associated).- Parameters:
theCmd
- ClassMetaData for the class to be managedclr
- The ClassLoaderResolver
-
managesClass
Accessor for whether this table manages the specified class.- Specified by:
managesClass
in interfaceDatastoreClass
- Parameters:
className
- Name of the class- Returns:
- Whether it is managed by this table
-
initializePK
protected void initializePK(org.datanucleus.ClassLoaderResolver clr) Method to initialise the table primary key field(s).- Specified by:
initializePK
in classAbstractClassTable
- Parameters:
clr
- The ClassLoaderResolver
-
getClassWithPrimaryKeyForClass
private org.datanucleus.metadata.AbstractClassMetaData getClassWithPrimaryKeyForClass(org.datanucleus.metadata.AbstractClassMetaData cmd, org.datanucleus.ClassLoaderResolver clr) Utility to navigate the inheritance hierarchy to find the base class that defines the primary keys for this tree. This has the assumption that there is no supertable, and will go up until it finds the superclass which has PK fields but no classes above.- Parameters:
cmd
- AbstractClassMetaData for this classclr
- The ClassLoaderResolver- Returns:
- The AbstractClassMetaData for the class defining the primary keys
-
initializeForClass
private void initializeForClass(org.datanucleus.metadata.AbstractClassMetaData theCmd, org.datanucleus.ClassLoaderResolver clr) Method to initialise this table to include all fields in the specified class. This is used to recurse up the hierarchy so that we include all immediate superclasses that have "subclass-table" specified as their inheritance strategy. If we encounter the parent of this class with other than "subclass-table" we stop the process.- Parameters:
theCmd
- The ClassMetaData for the class
-
runCallBacks
private void runCallBacks(org.datanucleus.ClassLoaderResolver clr) Execute the callbacks for the classes that this table maps to.- Parameters:
clr
- ClassLoader resolver
-
addOrderMapping
private JavaTypeMapping addOrderMapping(org.datanucleus.metadata.AbstractMemberMetaData mmd, JavaTypeMapping orderMapping, org.datanucleus.ClassLoaderResolver clr) Convenience method to add an order mapping to the table. Used with 1-N FK "indexed List"/array relations.- Parameters:
mmd
- Owner field MetaDataorderMapping
- The order mapping (maybe already set and just needs adding)clr
- ClassLoader resolver- Returns:
- The order mapping (if updated)
-
getType
Accessor for the main class represented.- Specified by:
getType
in interfaceDatastoreClass
- Returns:
- The name of the class
-
getIdentityType
public org.datanucleus.metadata.IdentityType getIdentityType()Accessor for the identity-type.- Specified by:
getIdentityType
in interfaceDatastoreClass
- Specified by:
getIdentityType
in classAbstractClassTable
- Returns:
- identity-type tag value
-
getVersionMetaData
public final org.datanucleus.metadata.VersionMetaData getVersionMetaData()Accessor for versionMetaData- Specified by:
getVersionMetaData
in interfaceTable
- Overrides:
getVersionMetaData
in classAbstractTable
- Returns:
- Returns the versionMetaData.
-
getDiscriminatorMetaData
public final org.datanucleus.metadata.DiscriminatorMetaData getDiscriminatorMetaData()Accessor for Discriminator MetaData- Specified by:
getDiscriminatorMetaData
in interfaceTable
- Overrides:
getDiscriminatorMetaData
in classAbstractTable
- Returns:
- Returns the Discriminator MetaData.
-
getTableWithDiscriminator
Convenience method to return the root table with a discriminator in this inheritance tree.- Returns:
- The root table which has the discriminator in this inheritance tree
-
isObjectIdDatastoreAttributed
public boolean isObjectIdDatastoreAttributed()Whether this table or super table has id (primary key) attributed by the datastore- Specified by:
isObjectIdDatastoreAttributed
in interfaceDatastoreClass
- Specified by:
isObjectIdDatastoreAttributed
in classAbstractClassTable
- Returns:
- true if the id attributed by the datastore
-
isBaseDatastoreClass
public boolean isBaseDatastoreClass()Whether this table is the base table in the inheritance hierarchy.- Specified by:
isBaseDatastoreClass
in interfaceDatastoreClass
- Returns:
- true if this table is a root table
-
getBaseDatastoreClass
Description copied from interface:DatastoreClass
Accessor for the base datastore class. Returns this object if it has no superclass table, otherwise goes up to the superclass etc.- Specified by:
getBaseDatastoreClass
in interfaceDatastoreClass
- Returns:
- The base datastore class
-
getSuperDatastoreClass
Accessor for the supertable for this table.- Specified by:
getSuperDatastoreClass
in interfaceDatastoreClass
- Returns:
- The supertable
-
isSuperDatastoreClass
Accessor whether the supplied DatastoreClass is a supertable of this table.- Specified by:
isSuperDatastoreClass
in interfaceDatastoreClass
- Parameters:
table
- The DatastoreClass to check- Returns:
- Whether it is a supertable (somewhere up the inheritance tree)
-
getSecondaryDatastoreClasses
Description copied from interface:DatastoreClass
Accessor for any secondary tables for this table.- Specified by:
getSecondaryDatastoreClasses
in interfaceDatastoreClass
- Returns:
- Collection of secondary tables (if any)
-
getSurrogateMapping
public JavaTypeMapping getSurrogateMapping(org.datanucleus.store.schema.table.SurrogateColumnType colType, boolean allowSuperclasses) Description copied from interface:Table
Accessor for the mapping for the specified surrogate type.- Specified by:
getSurrogateMapping
in interfaceTable
- Overrides:
getSurrogateMapping
in classAbstractClassTable
- Parameters:
colType
- Column type for the surrogateallowSuperclasses
- Whether to allow searching superclasses when not specified in this table.- Returns:
- The mapping
-
getTableManagingMapping
-
getSupertable
private ClassTable getSupertable(org.datanucleus.metadata.AbstractClassMetaData theCmd, org.datanucleus.ClassLoaderResolver clr) Utility to find the table above this one. Will recurse to cater for inheritance strategies where fields are handed up to the super class, or down to this class.- Parameters:
theCmd
- ClassMetaData of the class to find the supertable for.- Returns:
- The table above this one in any inheritance hierarchy
-
getBaseDatastoreClassWithMember
public DatastoreClass getBaseDatastoreClassWithMember(org.datanucleus.metadata.AbstractMemberMetaData mmd) Convenience accessor for the base table for this table which has the specified member.- Specified by:
getBaseDatastoreClassWithMember
in interfaceDatastoreClass
- Parameters:
mmd
- Member MetaData for this field- Returns:
- The base table which has the field specified
-
getClassMetaData
public org.datanucleus.metadata.ClassMetaData getClassMetaData()Accessor for the (primary) class MetaData. Package-level access to restrict to other table types only.- Specified by:
getClassMetaData
in interfaceorg.datanucleus.store.schema.table.Table
- Overrides:
getClassMetaData
in classAbstractTable
- Returns:
- The (primary) class MetaData
-
getExpectedIndices
Accessor for the indices for this table. This includes both the user-defined indices (via MetaData), and the ones required by foreign keys (required by relationships).- Overrides:
getExpectedIndices
in classTableImpl
- Parameters:
clr
- The ClassLoaderResolver- Returns:
- The indices
-
getIndexForIndexMetaDataAndMapping
private Index getIndexForIndexMetaDataAndMapping(org.datanucleus.metadata.IndexMetaData imd, JavaTypeMapping mapping) Convenience method to convert an IndexMetaData and a mapping into an Index.- Parameters:
imd
- The Index MetaDatamapping
- The mapping- Returns:
- The Index
-
getIndexForIndexMetaData
Convenience method to convert an IndexMetaData into an Index.- Parameters:
imd
- The Index MetaData- Returns:
- The Index
-
getExpectedForeignKeys
Accessor for the expected foreign keys for this table.- Overrides:
getExpectedForeignKeys
in classTableImpl
- Parameters:
clr
- The ClassLoaderResolver- Returns:
- The expected foreign keys.
-
addExpectedForeignKeysForEmbeddedPCField
private void addExpectedForeignKeysForEmbeddedPCField(List<ForeignKey> foreignKeys, boolean autoMode, org.datanucleus.ClassLoaderResolver clr, EmbeddedPCMapping embeddedMapping) Convenience method to add the expected FKs for an embedded PC field.- Parameters:
foreignKeys
- The list of FKs to add the FKs toautoMode
- Whether operating in "auto-mode" where DataNucleus can create its own FKsclr
- ClassLoader resolverembeddedMapping
- The embedded PC mapping
-
getForeignKeyForForeignKeyMetaData
private ForeignKey getForeignKeyForForeignKeyMetaData(org.datanucleus.metadata.ForeignKeyMetaData fkmd) Convenience method to create a FK for the specified ForeignKeyMetaData. Used for foreign-keys specified at <class> level.- Parameters:
fkmd
- ForeignKey MetaData- Returns:
- The ForeignKey
-
getExpectedCandidateKeys
Accessor for the expected candidate keys for this table.- Overrides:
getExpectedCandidateKeys
in classTableImpl
- Returns:
- The expected candidate keys.
-
getCandidateKeyForUniqueMetaData
Convenience method to convert a UniqueMetaData into a CandidateKey.- Parameters:
umd
- The Unique MetaData- Returns:
- The Candidate Key
-
getPrimaryKey
Accessor for the primary key for this table. Overrides the method in TableImpl to add on any specification of PK name in the metadata.- Overrides:
getPrimaryKey
in classTableImpl
- Returns:
- The primary key.
-
getSQLCreateStatements
Accessor for the CREATE statements for this table. Creates this table followed by all secondary tables (if any).- Overrides:
getSQLCreateStatements
in classTableImpl
- Parameters:
props
- Properties for creating the table- Returns:
- the SQL statements to be executed for creation
-
getSQLDropStatements
Accessor for the DROP statements for this table. Drops all secondary tables (if any) followed by the table itself.- Overrides:
getSQLDropStatements
in classTableImpl
- Returns:
- List of statements
-
initializeFKMapUniqueConstraints
private void initializeFKMapUniqueConstraints(org.datanucleus.metadata.AbstractMemberMetaData ownerMmd) Method to initialise unique constraints for 1-N Map using FK.- Parameters:
ownerMmd
- metadata for the field/property with the map in the owner class
-
initializeIDMapping
private void initializeIDMapping()Initialize the ID Mapping. For datastore identity this will be a PCMapping that contains the DatastoreIdMapping. For application identity this will be a PCMapping that contains the PK mapping(s). -
getIdMapping
Accessor for a mapping for the ID (persistable) for this table.- Specified by:
getIdMapping
in interfaceTable
- Returns:
- The (persistable) ID mapping.
-
getExternalOrderMappings
private Map<org.datanucleus.metadata.AbstractMemberMetaData,JavaTypeMapping> getExternalOrderMappings()Accessor for all of the order mappings (used by FK Lists, Collections, Arrays)- Returns:
- The mappings for the order columns.
-
hasExternalFkMappings
public boolean hasExternalFkMappings() -
getExternalFkMappings
private Map<org.datanucleus.metadata.AbstractMemberMetaData,JavaTypeMapping> getExternalFkMappings()Accessor for all of the external FK mappings.- Returns:
- The mappings for external FKs
-
getExternalMapping
public JavaTypeMapping getExternalMapping(org.datanucleus.metadata.AbstractMemberMetaData mmd, MappingType mappingType) Accessor for an external mapping for the specified field of the required type.- Specified by:
getExternalMapping
in interfaceDatastoreClass
- Parameters:
mmd
- MetaData for the field/propertymappingType
- Type of mapping- Returns:
- The (external) mapping
-
getMetaDataForExternalMapping
public org.datanucleus.metadata.AbstractMemberMetaData getMetaDataForExternalMapping(JavaTypeMapping mapping, MappingType mappingType) Accessor for the MetaData for the (owner) field that an external mapping corresponds to.- Specified by:
getMetaDataForExternalMapping
in interfaceDatastoreClass
- Parameters:
mapping
- The mappingmappingType
- The mapping type- Returns:
- metadata for the external mapping
-
getExternalFkDiscriminatorMappings
private Map<org.datanucleus.metadata.AbstractMemberMetaData,JavaTypeMapping> getExternalFkDiscriminatorMappings()Accessor for all of the external FK discriminator mappings.- Returns:
- The mappings for external FKs
-
getMemberMapping
Accessor for the field mapping for the specified field. The field can be managed by a supertable of this table.- Specified by:
getMemberMapping
in interfaceDatastoreClass
- Specified by:
getMemberMapping
in interfaceTable
- Parameters:
mmd
- MetaData for this field/property- Returns:
- the Mapping for the field/property
-
getMemberMappingInDatastoreClass
public JavaTypeMapping getMemberMappingInDatastoreClass(org.datanucleus.metadata.AbstractMemberMetaData mmd) Accessor for the mapping for the specified field only in this datastore class.- Specified by:
getMemberMappingInDatastoreClass
in interfaceDatastoreClass
- Parameters:
mmd
- Metadata of the field/property- Returns:
- The Mapping for the field/property (or null if not present here)
-
getMemberMapping
Accessor for the java mapping for the named member. The member may exist in a parent table or a secondary table. Throws a NoSuchPersistentFieldException if the member name is not found. TODO Use of this is discouraged since the memberName is not fully qualified and if a superclass-table inheritance is used we could have 2 members of that name here.- Specified by:
getMemberMapping
in interfaceDatastoreClass
- Parameters:
memberName
- Name of member- Returns:
- The mapping
- Throws:
NoSuchPersistentFieldException
- Thrown when the field/property is not found
-
getMetaDataForMember
Acessor for the MetaData for the member with the specified name. Searches the MetaData of all classes managed by this table. Doesn't allow for cases where the table manages subclasses with the same member name, in that case you should use the equivalent method passing metaData. TODO Support subclasses with members of the same name TODO Use of this is discouraged since the memberName is not fully qualified and if a superclass-table inheritance is used we could have 2 members of that name here.- Parameters:
memberName
- the member name- Returns:
- metadata for the member
-
addOrderColumn
private JavaTypeMapping addOrderColumn(org.datanucleus.metadata.AbstractMemberMetaData mmd, org.datanucleus.ClassLoaderResolver clr) Adds an ordering column to the element table (this) in FK list relationships. Used to store the position of the element in the List. If the <order> provides a mapped-by, this will return the existing column mapping.- Parameters:
mmd
- The MetaData of the field/property with the list for the column to map to- Returns:
- The Mapping for the order column
-
providePrimaryKeyMappings
Provide the mappings to the consumer for all primary-key fields mapped to this table.- Specified by:
providePrimaryKeyMappings
in interfaceDatastoreClass
- Specified by:
providePrimaryKeyMappings
in classAbstractClassTable
- Parameters:
consumer
- Consumer for the mappings
-
provideExternalMappings
Provide the mappings to the consumer for all external fields mapped to this table of the specified type- Specified by:
provideExternalMappings
in interfaceDatastoreClass
- Parameters:
consumer
- Consumer for the mappingsmappingType
- Type of external mapping
-
provideMappingsForMembers
public void provideMappingsForMembers(MappingConsumer consumer, org.datanucleus.metadata.AbstractMemberMetaData[] fieldMetaData, boolean includeSecondaryTables) Provide the mappings to the consumer for all absolute field Numbers in this table that are container in the fieldNumbers parameter.- Specified by:
provideMappingsForMembers
in interfaceDatastoreClass
- Overrides:
provideMappingsForMembers
in classAbstractClassTable
- Parameters:
consumer
- Consumer for the mappingsfieldMetaData
- MetaData for the fields to provide mappings forincludeSecondaryTables
- Whether to provide fields in secondary tables
-
provideUnmappedColumns
Method to provide all unmapped columns to the consumer.- Specified by:
provideUnmappedColumns
in interfaceDatastoreClass
- Parameters:
consumer
- Consumer of information
-
validateConstraints
public boolean validateConstraints(Connection conn, boolean autoCreate, Collection<Throwable> autoCreateErrors, org.datanucleus.ClassLoaderResolver clr) throws SQLException Method to validate the constraints of this table.- Overrides:
validateConstraints
in classTableImpl
- Parameters:
conn
- Connection to use in validationautoCreate
- Whether to auto create the constraintsautoCreateErrors
- Whether to log a warning only on errors during "auto create"clr
- The ClassLoaderResolver- Returns:
- Whether the DB was modified
- Throws:
SQLException
- Thrown when an error occurs in validation
-