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.ClassMetaDataMetaData for the principal class being stored here.private StringDDL 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 StringName of class currently being processed in manageClass (if any).protected booleanFlag to run the callbacks after the current class is managed fully.private Map<String, SecondaryTable> Secondary tables for this table (if any).private ClassTableTable above this table storing superclass information (if any).private org.datanucleus.util.MacroStringUser defined table schemaSet of unmapped "Column" objects that have no associated field (and hence ColumnMapping).Fields inherited from class AbstractClassTable
createTimestampMapping, createUserMapping, datastoreIdMapping, discriminatorMapping, discriminatorMetaData, highestMemberNumber, idMapping, memberMappingsMap, multitenancyMapping, pkMappings, softDeleteMapping, updateTimestampMapping, updateUserMapping, versionMapping, versionMetaDataFields inherited from class 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 voidaddExpectedForeignKeysForEmbeddedPCField(List<ForeignKey> foreignKeys, boolean autoMode, org.datanucleus.ClassLoaderResolver clr, EmbeddedPCMapping embeddedMapping) Convenience method to add the expected FKs for an embedded PC field.private JavaTypeMappingaddOrderColumn(org.datanucleus.metadata.AbstractMemberMetaData mmd, org.datanucleus.ClassLoaderResolver clr) Adds an ordering column to the element table (this) in FK list relationships.private JavaTypeMappingaddOrderMapping(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 CandidateKeygetCandidateKeyForUniqueMetaData(org.datanucleus.metadata.UniqueMetaData umd) Convenience method to convert a UniqueMetaData into a CandidateKey.org.datanucleus.metadata.ClassMetaDataAccessor for the (primary) class MetaData.private org.datanucleus.metadata.AbstractClassMetaDatagetClassWithPrimaryKeyForClass(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.DiscriminatorMetaDataAccessor 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 ForeignKeygetForeignKeyForForeignKeyMetaData(org.datanucleus.metadata.ForeignKeyMetaData fkmd) Convenience method to create a FK for the specified ForeignKeyMetaData.org.datanucleus.metadata.IdentityTypeAccessor for the identity-type.Accessor for a mapping for the ID (persistable) for this table.private IndexgetIndexForIndexMetaData(org.datanucleus.metadata.IndexMetaData imd) Convenience method to convert an IndexMetaData into an Index.private IndexgetIndexForIndexMetaDataAndMapping(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.AbstractMemberMetaDatagetMetaDataForExternalMapping(JavaTypeMapping mapping, MappingType mappingType) Accessor for the MetaData for the (owner) field that an external mapping corresponds to.(package private) org.datanucleus.metadata.AbstractMemberMetaDatagetMetaDataForMember(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 ClassTablegetSupertable(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 ClassTableConvenience method to return the root table with a discriminator in this inheritance tree.getType()Accessor for the main class represented.final org.datanucleus.metadata.VersionMetaDataAccessor for versionMetaDatabooleanvoidinitialize(org.datanucleus.ClassLoaderResolver clr) Method to initialise the table.private voidinitializeFKMapUniqueConstraints(org.datanucleus.metadata.AbstractMemberMetaData ownerMmd) Method to initialise unique constraints for 1-N Map using FK.private voidinitializeForClass(org.datanucleus.metadata.AbstractClassMetaData theCmd, org.datanucleus.ClassLoaderResolver clr) Method to initialise this table to include all fields in the specified class.private voidInitialize the ID Mapping.protected voidinitializePK(org.datanucleus.ClassLoaderResolver clr) Method to initialise the table primary key field(s).booleanWhether this table is the base table in the inheritance hierarchy.booleanWhether this table or super table has id (primary key) attributed by the datastorebooleanAccessor whether the supplied DatastoreClass is a supertable of this table.voidmanageClass(org.datanucleus.metadata.AbstractClassMetaData theCmd, org.datanucleus.ClassLoaderResolver clr) Method that adds the specified class to be managed by this table.private voidmanageMembers(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.booleanmanagesClass(String className) Accessor for whether this table manages the specified class.private voidmanageUnmappedColumns(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).voidpostInitialize(org.datanucleus.ClassLoaderResolver clr) Post initilize.voidpreInitialize(org.datanucleus.ClassLoaderResolver clr) Pre-initialize.final voidprovideExternalMappings(MappingConsumer consumer, MappingType mappingType) Provide the mappings to the consumer for all external fields mapped to this table of the specified typevoidprovideMappingsForMembers(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.voidprovidePrimaryKeyMappings(MappingConsumer consumer) Provide the mappings to the consumer for all primary-key fields mapped to this table.voidprovideUnmappedColumns(MappingConsumer consumer) Method to provide all unmapped columns to the consumer.private voidrunCallBacks(org.datanucleus.ClassLoaderResolver clr) Execute the callbacks for the classes that this table maps to.booleanvalidateConstraints(Connection conn, boolean autoCreate, Collection<Throwable> autoCreateErrors, org.datanucleus.ClassLoaderResolver clr) Method to validate the constraints of this table.Methods inherited from class AbstractClassTable
addApplicationIdUsingClassTableId, addDatastoreId, addMemberMapping, getMappingForMemberName, getPrimaryTable, getSurrogateColumn, managesMapping, managesMember, provideNonPrimaryKeyMappings, provideSurrogateMappingMethods inherited from class TableImpl
createConstraints, dropConstraints, getSQLAddCandidateKeyStatements, getSQLAddFKStatements, getSQLCreateIndexStatements, initializeColumnInfoForPrimaryKeyColumns, initializeColumnInfoFromDatastore, logMapping, validate, validateColumns, validatePrimaryKeyMethods inherited from class 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, toStringMethods inherited from interface DatastoreClass
managesMapping, provideNonPrimaryKeyMappings, provideSurrogateMapping, toStringMethods inherited from interface Table
addColumn, create, drop, exists, getColumn, getIdentifier, getStoreManager, hasColumn, isInitialized, isInitializedModified, isValidated, validateMethods 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
-
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:
preInitializein interfaceTable- Overrides:
preInitializein 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:
initializein 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:
postInitializein interfaceTable- Overrides:
postInitializein 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:
getManagedClassesin 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:
managesClassin 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:
initializePKin 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:
getTypein interfaceDatastoreClass- Returns:
- The name of the class
-
getIdentityType
public org.datanucleus.metadata.IdentityType getIdentityType()Accessor for the identity-type.- Specified by:
getIdentityTypein interfaceDatastoreClass- Specified by:
getIdentityTypein classAbstractClassTable- Returns:
- identity-type tag value
-
getVersionMetaData
public final org.datanucleus.metadata.VersionMetaData getVersionMetaData()Accessor for versionMetaData- Specified by:
getVersionMetaDatain interfaceTable- Overrides:
getVersionMetaDatain classAbstractTable- Returns:
- Returns the versionMetaData.
-
getDiscriminatorMetaData
public final org.datanucleus.metadata.DiscriminatorMetaData getDiscriminatorMetaData()Accessor for Discriminator MetaData- Specified by:
getDiscriminatorMetaDatain interfaceTable- Overrides:
getDiscriminatorMetaDatain 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:
isObjectIdDatastoreAttributedin interfaceDatastoreClass- Specified by:
isObjectIdDatastoreAttributedin 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:
isBaseDatastoreClassin interfaceDatastoreClass- Returns:
- true if this table is a root table
-
getBaseDatastoreClass
Description copied from interface:DatastoreClassAccessor for the base datastore class. Returns this object if it has no superclass table, otherwise goes up to the superclass etc.- Specified by:
getBaseDatastoreClassin interfaceDatastoreClass- Returns:
- The base datastore class
-
getSuperDatastoreClass
Accessor for the supertable for this table.- Specified by:
getSuperDatastoreClassin interfaceDatastoreClass- Returns:
- The supertable
-
isSuperDatastoreClass
Accessor whether the supplied DatastoreClass is a supertable of this table.- Specified by:
isSuperDatastoreClassin interfaceDatastoreClass- Parameters:
table- The DatastoreClass to check- Returns:
- Whether it is a supertable (somewhere up the inheritance tree)
-
getSecondaryDatastoreClasses
Description copied from interface:DatastoreClassAccessor for any secondary tables for this table.- Specified by:
getSecondaryDatastoreClassesin 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:TableAccessor for the mapping for the specified surrogate type.- Specified by:
getSurrogateMappingin interfaceTable- Overrides:
getSurrogateMappingin 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:
getBaseDatastoreClassWithMemberin 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:
getClassMetaDatain interfaceorg.datanucleus.store.schema.table.Table- Overrides:
getClassMetaDatain 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:
getExpectedIndicesin 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:
getExpectedForeignKeysin 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:
getExpectedCandidateKeysin 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:
getPrimaryKeyin 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:
getSQLCreateStatementsin 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:
getSQLDropStatementsin 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:
getIdMappingin 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:
getExternalMappingin 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:
getMetaDataForExternalMappingin 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:
getMemberMappingin interfaceDatastoreClass- Specified by:
getMemberMappingin 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:
getMemberMappingInDatastoreClassin 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:
getMemberMappingin 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:
providePrimaryKeyMappingsin interfaceDatastoreClass- Specified by:
providePrimaryKeyMappingsin 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:
provideExternalMappingsin 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:
provideMappingsForMembersin interfaceDatastoreClass- Overrides:
provideMappingsForMembersin 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:
provideUnmappedColumnsin 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:
validateConstraintsin 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
-