public class ClassMapping extends ClassMetaData implements ClassStrategy
Modifier and Type | Field and Description |
---|---|
static ClassMapping[] |
EMPTY_MAPPINGS |
ACCESS_EXPLICIT, ACCESS_FIELD, ACCESS_PROPERTY, ACCESS_UNKNOWN, DEFAULT_STRING, ID_APPLICATION, ID_DATASTORE, ID_UNKNOWN, SYNTHETIC
OPENJPA
SRC_ANNOTATIONS, SRC_OTHER, SRC_XML
MODE_ALL, MODE_ANN_MAPPING, MODE_MAPPING, MODE_MAPPING_INIT, MODE_META, MODE_NONE, MODE_QUERY
EMPTY_COMMENTS
Modifier | Constructor and Description |
---|---|
protected |
ClassMapping(Class type,
MappingRepository repos)
Constructor.
|
protected |
ClassMapping(ValueMetaData vmd)
Embedded constructor.
|
Modifier and Type | Method and Description |
---|---|
FieldMapping |
addDeclaredFieldMapping(String name,
Class type)
Convenience method to perform cast from
ClassMetaData.addDeclaredField(java.lang.String, java.lang.Class<?>) . |
Joinable |
assertJoinable(Column col)
Return the joinable for the given column, or throw an exception if
none is available.
|
protected void |
clearDefinedFieldCache()
Clear defined field data.
|
void |
clearMapping()
Clear mapping information, including strategy.
|
protected void |
clearSubclassCache()
Clear cached subclass data.
|
void |
copy(ClassMetaData cls)
Copy the metadata from the given instance to this one.
|
void |
customDelete(OpenJPAStateManager sm,
JDBCStore store)
Override this method to customize flushing this mapping.
|
void |
customInsert(OpenJPAStateManager sm,
JDBCStore store)
Override this method to customize flushing this mapping.
|
ResultObjectProvider |
customLoad(JDBCStore store,
boolean subclasses,
JDBCFetchConfiguration fetch,
long startIdx,
long endIdx)
Implement this method to customize obtaining a result containing all
instances of this class.
|
boolean |
customLoad(OpenJPAStateManager sm,
JDBCStore store,
JDBCFetchConfiguration fetch,
Result result)
Implement this method to customize loading from a
Result
into an instance. |
boolean |
customLoad(OpenJPAStateManager sm,
JDBCStore store,
PCState state,
JDBCFetchConfiguration fetch)
Implement this method to load the state of a given object, without
a previous
Result . |
void |
customUpdate(OpenJPAStateManager sm,
JDBCStore store)
Override this method to customize flushing this mapping.
|
void |
delete(OpenJPAStateManager sm,
JDBCStore store,
RowManager rm)
Set the where values appropriately to delete the proper instance,
and set all relations on non-secondary tables as updates.
|
String |
getAlias()
Return the alias of this strategy.
|
ColumnIO |
getColumnIO()
I/O information on the key columns / join key.
|
FieldMapping |
getDeclaredFieldMapping(int index)
Convenience method to perform cast from
ClassMetaData.getDeclaredField(int) . |
FieldMapping |
getDeclaredFieldMapping(String name)
Convenience method to perform cast from
ClassMetaData.getDeclaredField(int) . |
FieldMapping[] |
getDeclaredFieldMappings()
Convenience method to perform cast from
ClassMetaData.getDeclaredFields() . |
FieldMapping[] |
getDeclaredUnmanagedFieldMappings()
Convenience method to perform cast from
ClassMetaData.getDeclaredUnmanagedFields() . |
FieldMapping[] |
getDefaultFetchGroupFieldMappings()
Convenience method to perform cast from
ClassMetaData.getDefaultFetchGroupFields() . |
FieldMapping[] |
getDefinedFieldMappings()
Convenience method to perform cast from
ClassMetaData.getDefinedFields() . |
FieldMapping[] |
getDefinedFieldMappingsInListingOrder()
Convenience method to perform cast from
ClassMetaData.getDefinedFieldsInListingOrder() . |
Discriminator |
getDiscriminator()
The class discriminator.
|
ValueMapping |
getEmbeddingMapping()
Convenience method to perform cast from
ClassMetaData.getEmbeddingMetaData() |
FieldMapping |
getFieldMapping(int index)
Convenience method to perform cast from
ClassMetaData.getField(int) . |
FieldMapping |
getFieldMapping(String name)
Convenience method to perform cast from
ClassMetaData.getField(int) . |
FieldMapping[] |
getFieldMappings()
Convenience method to perform cast from
ClassMetaData.getFields() . |
FieldMapping[] |
getFieldMappingsInListingOrder()
Convenience method to perform cast from
ClassMetaData.getFieldsInListingOrder() . |
ClassMapping[] |
getIndependentAssignableMappings()
Returns the closest-derived list of non-inter-joinable mapped types
assignable to this type.
|
Joinable |
getJoinable(Column col)
Return the
Joinable for the given column. |
ClassMapping[] |
getJoinablePCSubclassMappings()
Return mapped subclasses that are reachable via joins.
|
ClassMapping |
getJoinablePCSuperclassMapping()
Return the nearest mapped superclass that can join to this class.
|
ForeignKey |
getJoinForeignKey()
Foreign key linking the primary key columns to the superclass table,
or null if none.
|
ClassMapping[] |
getMappedPCSubclassMappings()
Convenience method to perform cast from
ClassMetaData.getMappedPCSubclassMetaDatas() . |
ClassMapping |
getMappedPCSuperclassMapping()
Convenience method to perform cast from
ClassMetaData.getMappedPCSuperclassMetaData() . |
ClassMappingInfo |
getMappingInfo()
Raw mapping data.
|
MappingRepository |
getMappingRepository()
Convenience method to perform cast from
ClassMetaData.getRepository() . |
Object |
getObjectId(JDBCStore store,
Result res,
ForeignKey fk,
boolean subs,
Joins joins)
Return the oid value stored in the result.
|
ClassMapping[] |
getPCSubclassMappings()
Convenience method to perform cast from
ClassMetaData.getPCSubclassMetaDatas() . |
ClassMapping |
getPCSuperclassMapping()
Convenience method to perform cast from
ClassMetaData.getPCSuperclassMetaData() . |
Column[] |
getPrimaryKeyColumns()
The columns this mapping uses to uniquely identify an object.
|
FieldMapping[] |
getPrimaryKeyFieldMappings()
Convenience method to perform cast from
ClassMetaData.getPrimaryKeyFields() . |
ClassStrategy |
getStrategy()
The strategy used to map this mapping.
|
int |
getSubclassFetchMode()
The subclass fetch mode, as one of the eager constants in
JDBCFetchConfiguration . |
Table |
getTable()
The mapping's primary table.
|
Version |
getVersion()
The version indicator.
|
FieldMapping |
getVersionFieldMapping()
Convenience method to perform cast from
ClassMetaData.getVersionField() . |
void |
initialize()
Perform caching and other initialization operations.
|
protected void |
initializeMapping()
Initialize mapping.
|
void |
insert(OpenJPAStateManager sm,
JDBCStore store,
RowManager rm)
Set values for the mapping into the proper rows.
|
Boolean |
isCustomDelete(OpenJPAStateManager sm,
JDBCStore store)
Return
Boolean.FALSE if this mapping does not customize the
delete process, Boolean.TRUE if it does, or null if it does
customize the delete, but also relies on the standard delete method
being called. |
Boolean |
isCustomInsert(OpenJPAStateManager sm,
JDBCStore store)
Return
Boolean.FALSE if this mapping does not customize the
insert process, Boolean.TRUE if it does, or null if it does
customize the insert, but also relies on the standard insert method
being called. |
Boolean |
isCustomUpdate(OpenJPAStateManager sm,
JDBCStore store)
Return
Boolean.FALSE if this mapping does not customize the
update process, Boolean.TRUE if it does, or null if it does
customize the update, but also relies on the standard update method
being called. |
Boolean |
isForeignKeyObjectId(ForeignKey fk)
Return whether the columns of the given foreign key to this mapping
can be used to construct an object id for this type.
|
boolean |
isMapped()
Returns true if this class does not use the "none" strategy (including
if it has a null strategy, and therefore is probably in the process of
being mapped).
|
boolean |
isPrimaryKeyObjectId(boolean hasAll)
Return true if the this class' primary key columns correspond to the
base class' primary key columns used to construct oid values.
|
boolean |
isVerticalStrategy() |
Joins |
joinSuperclass(Joins joins,
boolean toThis)
Join the mapping and its superclass.
|
void |
map(boolean adapt)
Map the owning mapping using this strategy.
|
void |
refSchemaComponents() |
protected void |
resolveMapping(boolean runtime)
Resolve mapping data.
|
void |
setClassMapping(ClassMapping owner)
Set the class mapping using this strategy.
|
void |
setColumnIO(ColumnIO io)
I/O information on the key columns / join key.
|
protected void |
setDescribedType(Class type)
Set the class described by this metadata.
|
void |
setJoinable(Column col,
Joinable joinable)
Add the given column-to-joinable mapping.
|
void |
setJoinForeignKey(ForeignKey fk)
Foreign key linking the primary key columns to the superclass table,
or null if none.
|
void |
setPrimaryKeyColumns(Column[] cols)
The columns this mapping uses to uniquely identify an object.
|
void |
setStrategy(ClassStrategy strategy,
Boolean adapt)
The strategy used to map this mapping.
|
void |
setSubclassFetchMode(int mode)
The subclass fetch mode, as one of the eager constants in
JDBCFetchConfiguration . |
void |
setTable(Table table)
The mapping's primary table.
|
boolean |
supportsEagerSelect(Select sel,
OpenJPAStateManager sm,
JDBCStore store,
ClassMapping base,
JDBCFetchConfiguration fetch)
Return true if this strategy can perform the given select from
the given
base mapping. |
void |
syncMappingInfo()
Update
MappingInfo with our current mapping information. |
Object |
toDataStoreValue(Object obj,
Column[] cols,
JDBCStore store)
Return the given column value(s) for the given object.
|
void |
update(OpenJPAStateManager sm,
JDBCStore store,
RowManager rm)
Set values for the mapping into the proper rows.
|
protected boolean |
validateDataStoreExtensionPrefix(String prefix)
Return true if extensions starting with the given official datastore
prefix should be validated for this runtime.
|
addDeclaredFetchGroup, addDeclaredField, addDeclaredInterface, addDefinedSuperclassField, addExtensionKeys, clearAllFieldCache, clearFieldCache, compareTo, defineSuperclassFields, equals, getAccessType, getCacheEnabled, getColNumber, getComments, getCustomFetchGroups, getDataCache, getDataCacheEnabled, getDataCacheName, getDataCacheTimeout, getDeclaredFetchGroups, getDeclaredField, getDeclaredField, getDeclaredFieldNames, getDeclaredFields, getDeclaredInterfaces, getDeclaredUnmanagedFields, getDefaultFetchGroupFields, getDefinedFields, getDefinedFieldsInListingOrder, getDefinedSuperclassField, getDescribedType, getDescribedTypeString, getDetachedState, getDetachedStateField, getEmbeddingMetaData, getEnvClassLoader, getExtraFieldDataIndex, getExtraFieldDataLength, getFetchGroup, getField, getField, getFieldNames, getFields, getFieldsInListingOrder, getIdClass, getIdentitySequenceMetaData, getIdentitySequenceName, getIdentityStrategy, getIdentityType, getInterfaceAliasedProperties, getInterfaceImpl, getInterfacePropertyAlias, getLifecycleMetaData, getLineNumber, getListingIndex, getLrsFields, getMappedPCSubclassMetaDatas, getMappedPCSuperclassMetaData, getMappyedByIdFields, getObjectIdType, getPCSubclasses, getPCSubclassMetaDatas, getPCSuperclass, getPCSuperclassMetaData, getPkAndNonPersistentManagedFmdIndexes, getPrimaryKeyFields, getProxyFields, getRepository, getRequiresExtent, getResolve, getResourceName, getSourceFile, getSourceMode, getSourceName, getSourceScope, getSourceType, getSuperclassField, getTypeAlias, getUseSchemaElement, getVersionField, hasAbstractPKField, hashCode, hasInverseManagedFields, hasPKFieldsFromAbstractClass, isAbstract, isAccessibleField, isDetachable, isEmbeddable, isEmbeddedOnly, isExplicitAccess, isIntercepting, isManagedInterface, isMixedAccess, isObjectIdTypeShared, isOpenJPAIdentity, registerForValueUpdate, removeDeclaredFetchGroup, removeDeclaredField, removeDeclaredInterface, removeDefinedSuperclassField, resolve, resolveMeta, setAbstract, setAccessType, setCacheEnabled, setColNumber, setComments, setDataCacheName, setDataCacheTimeout, setDetachable, setDetachedState, setEmbeddable, setEmbeddedOnly, setEnvClassLoader, setIdentitySequenceName, setIdentityStrategy, setIdentityType, setIntercepting, setInterfaceImpl, setInterfacePropertyAlias, setLineNumber, setListingIndex, setManagedInterface, setObjectIdType, setPCSuperclass, setPCSuperclassMetaData, setRequiresExtent, setResolve, setResolve, setSource, setSourceMode, setSourceMode, setTypeAlias, setUseSchemaElement, toString, useIdClassFromParent, usesDetachedState, validateMapping, validateMeta, valueChanged
addExtension, addExtension, copy, getBooleanExtension, getBooleanExtension, getDoubleExtension, getDoubleExtension, getEmbeddedExtensions, getEmbeddedExtensions, getExtensionKeys, getExtensionKeys, getExtensionVendors, getIntExtension, getIntExtension, getObjectExtension, getObjectExtension, getStringExtension, getStringExtension, hasExtension, hasExtension, isEmpty, removeEmbeddedExtensions, removeEmbeddedExtensions, removeExtension, removeExtension, validateExtensionKeys
public static final ClassMapping[] EMPTY_MAPPINGS
protected ClassMapping(Class type, MappingRepository repos)
protected ClassMapping(ValueMetaData vmd)
public Discriminator getDiscriminator()
public Version getVersion()
public Object getObjectId(JDBCStore store, Result res, ForeignKey fk, boolean subs, Joins joins) throws SQLException
fk
- if non-null, use the local columns of the given foreign
key in place of this class' primary key columnsSQLException
isPrimaryKeyObjectId(boolean)
public Object toDataStoreValue(Object obj, Column[] cols, JDBCStore store)
public Joinable assertJoinable(Column col)
public Joinable getJoinable(Column col)
Joinable
for the given column. Any column that
another mapping joins to must be controlled by a joinable.public void setJoinable(Column col, Joinable joinable)
public Boolean isForeignKeyObjectId(ForeignKey fk)
Boolean.TRUE
if the foreign key contains all oid
columns, null
if it contains only some columns,
or Boolean.FALSE
if it contains non-oid columnspublic ClassMappingInfo getMappingInfo()
public ClassStrategy getStrategy()
public void setStrategy(ClassStrategy strategy, Boolean adapt)
adapt
parameter determines whether to adapt when mapping the strategy;
use null if the strategy should not be mapped.public Table getTable()
public void setTable(Table table)
public Column[] getPrimaryKeyColumns()
public void setPrimaryKeyColumns(Column[] cols)
public ColumnIO getColumnIO()
public void setColumnIO(ColumnIO io)
public ForeignKey getJoinForeignKey()
public void setJoinForeignKey(ForeignKey fk)
public void refSchemaComponents()
public void clearMapping()
public void syncMappingInfo()
MappingInfo
with our current mapping information.protected void setDescribedType(Class type)
ClassMetaData
setDescribedType
in class ClassMetaData
public int getSubclassFetchMode()
JDBCFetchConfiguration
.public void setSubclassFetchMode(int mode)
JDBCFetchConfiguration
.public MappingRepository getMappingRepository()
ClassMetaData.getRepository()
.public ValueMapping getEmbeddingMapping()
ClassMetaData.getEmbeddingMetaData()
public boolean isMapped()
isMapped
in class ClassMetaData
public ClassMapping getPCSuperclassMapping()
ClassMetaData.getPCSuperclassMetaData()
.public ClassMapping getMappedPCSuperclassMapping()
ClassMetaData.getMappedPCSuperclassMetaData()
.public ClassMapping getJoinablePCSuperclassMapping()
public ClassMapping[] getPCSubclassMappings()
ClassMetaData.getPCSubclassMetaDatas()
.public ClassMapping[] getMappedPCSubclassMappings()
ClassMetaData.getMappedPCSubclassMetaDatas()
.public ClassMapping[] getJoinablePCSubclassMappings()
public ClassMapping[] getIndependentAssignableMappings()
public FieldMapping[] getFieldMappings()
ClassMetaData.getFields()
.public FieldMapping[] getDeclaredFieldMappings()
ClassMetaData.getDeclaredFields()
.public FieldMapping[] getPrimaryKeyFieldMappings()
ClassMetaData.getPrimaryKeyFields()
.public FieldMapping getVersionFieldMapping()
ClassMetaData.getVersionField()
.public FieldMapping[] getDefaultFetchGroupFieldMappings()
ClassMetaData.getDefaultFetchGroupFields()
.public FieldMapping[] getDefinedFieldMappings()
ClassMetaData.getDefinedFields()
.public FieldMapping[] getFieldMappingsInListingOrder()
ClassMetaData.getFieldsInListingOrder()
.public FieldMapping[] getDefinedFieldMappingsInListingOrder()
ClassMetaData.getDefinedFieldsInListingOrder()
.public FieldMapping getFieldMapping(int index)
ClassMetaData.getField(int)
.public FieldMapping getDeclaredFieldMapping(int index)
ClassMetaData.getDeclaredField(int)
.public FieldMapping getFieldMapping(String name)
ClassMetaData.getField(int)
.public FieldMapping getDeclaredFieldMapping(String name)
ClassMetaData.getDeclaredField(int)
.public FieldMapping[] getDeclaredUnmanagedFieldMappings()
ClassMetaData.getDeclaredUnmanagedFields()
.public FieldMapping addDeclaredFieldMapping(String name, Class type)
ClassMetaData.addDeclaredField(java.lang.String, java.lang.Class<?>)
.protected void resolveMapping(boolean runtime)
ClassMetaData
resolveMapping
in class ClassMetaData
protected void initializeMapping()
ClassMetaData
initializeMapping
in class ClassMetaData
protected void clearDefinedFieldCache()
ClassMetaData
clearDefinedFieldCache
in class ClassMetaData
protected void clearSubclassCache()
ClassMetaData
clearSubclassCache
in class ClassMetaData
public void copy(ClassMetaData cls)
ClassMetaData
copy
in class ClassMetaData
protected boolean validateDataStoreExtensionPrefix(String prefix)
Extensions
validateDataStoreExtensionPrefix
in class Extensions
public String getAlias()
Strategy
public void map(boolean adapt)
Strategy
public void initialize()
Strategy
Strategy.map(boolean)
, and after all related components have been
mapped as well.initialize
in interface Strategy
public void insert(OpenJPAStateManager sm, JDBCStore store, RowManager rm) throws SQLException
Strategy
insert
in interface Strategy
SQLException
public void update(OpenJPAStateManager sm, JDBCStore store, RowManager rm) throws SQLException
Strategy
update
in interface Strategy
SQLException
Strategy.insert(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.jdbc.kernel.JDBCStore, org.apache.openjpa.jdbc.sql.RowManager)
public void delete(OpenJPAStateManager sm, JDBCStore store, RowManager rm) throws SQLException
Strategy
delete
in interface Strategy
SQLException
Strategy.insert(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.jdbc.kernel.JDBCStore, org.apache.openjpa.jdbc.sql.RowManager)
public Boolean isCustomInsert(OpenJPAStateManager sm, JDBCStore store)
Strategy
Boolean.FALSE
if this mapping does not customize the
insert process, Boolean.TRUE
if it does, or null if it does
customize the insert, but also relies on the standard insert method
being called. Implement the Strategy.customInsert(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.jdbc.kernel.JDBCStore)
method
to implement the custom insertion behavior.isCustomInsert
in interface Strategy
public Boolean isCustomUpdate(OpenJPAStateManager sm, JDBCStore store)
Strategy
Boolean.FALSE
if this mapping does not customize the
update process, Boolean.TRUE
if it does, or null if it does
customize the update, but also relies on the standard update method
being called. Implement the Strategy.customUpdate(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.jdbc.kernel.JDBCStore)
method
to override the default update behavior.isCustomUpdate
in interface Strategy
public Boolean isCustomDelete(OpenJPAStateManager sm, JDBCStore store)
Strategy
Boolean.FALSE
if this mapping does not customize the
delete process, Boolean.TRUE
if it does, or null if it does
customize the delete, but also relies on the standard delete method
being called. Implement the Strategy.customDelete(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.jdbc.kernel.JDBCStore)
method
to override the default deletion behavior.isCustomDelete
in interface Strategy
public void customInsert(OpenJPAStateManager sm, JDBCStore store) throws SQLException
Strategy
customInsert
in interface Strategy
SQLException
public void customUpdate(OpenJPAStateManager sm, JDBCStore store) throws SQLException
Strategy
customUpdate
in interface Strategy
SQLException
public void customDelete(OpenJPAStateManager sm, JDBCStore store) throws SQLException
Strategy
customDelete
in interface Strategy
SQLException
public void setClassMapping(ClassMapping owner)
ClassStrategy
setClassMapping
in interface ClassStrategy
public boolean isPrimaryKeyObjectId(boolean hasAll)
ClassStrategy
isPrimaryKeyObjectId
in interface ClassStrategy
hasAll
- if true, there must be a primary key column for every
base class primary key column; if false the primary key
must only match a subset of the base class primary key columnspublic Joins joinSuperclass(Joins joins, boolean toThis)
ClassStrategy
joinSuperclass
in interface ClassStrategy
toThis
- if false, inner join to the superclass table; if
true, outer join from the superclass table to this tablepublic boolean supportsEagerSelect(Select sel, OpenJPAStateManager sm, JDBCStore store, ClassMapping base, JDBCFetchConfiguration fetch)
ClassStrategy
base
mapping.
The given state manager may be null if selecting multiple instances.supportsEagerSelect
in interface ClassStrategy
public ResultObjectProvider customLoad(JDBCStore store, boolean subclasses, JDBCFetchConfiguration fetch, long startIdx, long endIdx) throws SQLException
ClassStrategy
customLoad
in interface ClassStrategy
SQLException
public boolean customLoad(OpenJPAStateManager sm, JDBCStore store, PCState state, JDBCFetchConfiguration fetch) throws SQLException, ClassNotFoundException
ClassStrategy
Result
. Return true if this method handles the
load. If the object does not exist in the data store, simply take no
action on it (but still return true). Return false to use default
loading.customLoad
in interface ClassStrategy
state
- if non-null, then you must initialize the state
and persistent object of the given state manager
(after determining the actual class of the object
from the database, if there are possible persistent
subclasses); initialization looks like this:
sm.initialize (pcClass, state)
SQLException
ClassNotFoundException
public boolean customLoad(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Result result) throws SQLException
ClassStrategy
Result
into an instance. Return true if this mapping handles the
load; false if normal loading should proceed after calling this method.customLoad
in interface ClassStrategy
SQLException
public boolean isVerticalStrategy()
Copyright © 2006–2019 Apache Software Foundation. All rights reserved.