Package org.apache.cayenne.map
Class DataMap
java.lang.Object
org.apache.cayenne.map.DataMap
- All Implemented Interfaces:
- Serializable,- Comparable<DataMap>,- EventListener,- ConfigurationNode,- DbEntityListener,- ObjEntityListener,- MappingNamespace,- XMLSerializable
public class DataMap extends Object implements Serializable, ConfigurationNode, XMLSerializable, MappingNamespace, DbEntityListener, ObjEntityListener, Comparable<DataMap>
Stores a collection of related mapping objects that describe database and
 object layers of an application. DataMap contains DbEntities mapping database
 tables, ObjEntities - mapping persistent Java classes, Procedures - mapping
 database stored procedures.
- See Also:
- Serialized Form
- 
Field SummaryFields Modifier and Type Field Description static StringCLIENT_SUPPORTED_PROPERTYDefines whether a DataMap supports client entities.protected booleanclientSupportedprotected ResourceconfigurationSourceprotected DataChannelDescriptordataChannelDescriptorstatic StringDEFAULT_CATALOG_PROPERTYDefines the name of the property for default DB catalog.static StringDEFAULT_CLIENT_PACKAGE_PROPERTYDefines the name of the property for default client Java class package.static StringDEFAULT_CLIENT_SUPERCLASS_PROPERTYDefines the name of the property for default client Java superclass.static StringDEFAULT_LOCK_TYPE_PROPERTYDefines the name of the property for default DB schema.static StringDEFAULT_PACKAGE_PROPERTYDefines the name of the property for default Java class package.static StringDEFAULT_QUOTE_SQL_IDENTIFIERS_PROPERTYstatic StringDEFAULT_SCHEMA_PROPERTYDefines the name of the property for default DB schema.static StringDEFAULT_SUPERCLASS_PROPERTYDefines the name of the property for default Java superclass.protected StringdefaultCatalogprotected StringdefaultClientPackageprotected StringdefaultClientSuperclassprotected intdefaultLockTypeprotected StringdefaultPackageprotected StringdefaultSchemaprotected StringdefaultSuperclassprotected Stringlocationprotected Stringnameprotected MappingNamespacenamespaceprotected BooleanquotingSQLIdentifiersstatic StringSCHEMA_XSDThe namespace in which the data map XML file will be created.static StringSCHEMA_XSD_LOCATION
- 
Constructor Summary
- 
Method SummaryModifier and Type Method Description <T> TacceptVisitor(ConfigurationNodeVisitor<T> visitor)voidaddDbEntity(DbEntity entity)Adds a new DbEntity to this DataMap.voidaddEmbeddable(Embeddable embeddable)Adds an embeddable object to the DataMap.voidaddObjEntity(ObjEntity entity)Adds a new ObjEntity to this DataMap.voidaddProcedure(Procedure procedure)Adds stored procedure to the list of procedures.voidaddQueryDescriptor(QueryDescriptor queryDescriptor)Stores a query descriptor under its name.voidaddResult(SQLResult result)Adds a named SQLResultSet to the DataMap.voidclear()voidclearDbEntities()voidclearEmbeddables()Removes all stored embeddable objects from the map.voidclearObjEntities()voidclearProcedures()voidclearQueries()voidclearResultSets()intcompareTo(DataMap o)voiddbEntityAdded(EntityEvent e)New entity has been created/added.voiddbEntityChanged(EntityEvent e)DbEntity property changed.voiddbEntityRemoved(EntityEvent e)Entity has been removed.voidencodeAsXML(XMLEncoder encoder, ConfigurationNodeVisitor delegate)Prints itself as XML to the provided PrintWriter.DataMapgetClientDataMap(EntityResolver serverResolver)Returns a DataMap stripped of any server-side information, such as DbEntity mapping, or ObjEntities that are not allowed in the client tier.ResourcegetConfigurationSource()DataChannelDescriptorgetDataChannelDescriptor()Collection<DbEntity>getDbEntities()Returns all DbEntities in this DataMap.DbEntitygetDbEntity(String dbEntityName)Returns DbEntity matching thenameparameter.Map<String,DbEntity>getDbEntityMap()Returns a unmodifiable map of DbEntities contained in this DataMap, keyed by DbEntity name.StringgetDefaultCatalog()StringgetDefaultClientPackage()Returns default client package.StringgetDefaultClientSuperclass()Returns default client superclass.intgetDefaultLockType()StringgetDefaultPackage()StringgetDefaultSchema()StringgetDefaultSuperclass()EmbeddablegetEmbeddable(String className)Returns anEmbeddablematching class name or null if such Embeddable is not mapped.Map<String,Embeddable>getEmbeddableMap()Collection<Embeddable>getEmbeddables()Returns a collection ofEmbeddablemappings stored in the DataMap.EntityInheritanceTreegetInheritanceTree(String entityName)StringgetLocation()Returns "location" property value.Collection<ObjEntity>getMappedEntities(DbEntity dbEntity)Returns all ObjEntities mapped to the given DbEntity.StringgetName()Returns the name of this DataMap.MappingNamespacegetNamespace()Returns a parent namespace where this DataMap resides.StringgetNameWithDefaultClientPackage(String name)StringgetNameWithDefaultPackage(String name)static StringgetNameWithPackage(String pack, String name)Collection<ObjEntity>getObjEntities()Returns an unmodifiable collection of ObjEntities stored in this DataMap.ObjEntitygetObjEntity(Class<?> entityClass)ObjEntitygetObjEntity(String objEntityName)Returns an ObjEntity for a given name.ObjEntitygetObjEntity(Persistent object)ObjEntitygetObjEntityForJavaClass(String javaClassName)Returns an ObjEntity for a DataObject class name.Map<String,ObjEntity>getObjEntityMap()Returns a unmodifiable map of ObjEntities contained in this DataMap, keyed by ObjEntity name.ProceduregetProcedure(String procedureName)Returns a Procedure for a given name or null if no such procedure exists.Map<String,Procedure>getProcedureMap()Returns a sorted unmodifiable map of Procedures in this DataMap keyed by name.Collection<Procedure>getProcedures()Returns stored procedures associated with this DataMap.QueryDescriptorgetQueryDescriptor(String queryName)Returns a named query associated with this DataMap.Map<String,QueryDescriptor>getQueryDescriptorMap()Collection<QueryDescriptor>getQueryDescriptors()Returns an unmodifiable collection of mapped queries.SQLResultgetResult(String name)Returns a named result set mapping.Collection<SQLResult>getResults()Map<String,SQLResult>getResultsMap()Map<String,ObjEntity>getSubclassesForObjEntity(ObjEntity superEntity)voidinitWithProperties(Map<String,Object> properties)Performs DataMap initialization from a set of properties, using defaults for the missing properties.booleanisClientSupported()booleanisQuotingSQLIdentifiers()voidmergeWithDataMap(DataMap map)Adds all Object and DB entities and Queries from another map to this map.voidobjEntityAdded(EntityEvent e)New entity has been created/added.voidobjEntityChanged(EntityEvent e)ObjEntity property changed.voidobjEntityRemoved(EntityEvent e)Entity has been removed.voidremoveDbEntity(String dbEntityName)"Dirty" remove of the DbEntity from the data map.voidremoveDbEntity(String dbEntityName, boolean clearDependencies)Removes DbEntity from the DataMap.voidremoveEmbeddable(String className)Removes anEmbeddabledescriptor with matching class name.voidremoveObjEntity(String objEntityName)"Dirty" remove of the ObjEntity from the data map.voidremoveObjEntity(String objEntityName, boolean clearDependencies)Removes ObjEntity from the DataMap.voidremoveProcedure(String name)voidremoveQueryDescriptor(String queryName)Removes a named query from the DataMap.voidremoveResult(String name)voidsetClientSupported(boolean clientSupport)voidsetConfigurationSource(Resource configurationSource)voidsetDataChannelDescriptor(DataChannelDescriptor dataChannelDescriptor)voidsetDefaultCatalog(String defaultCatalog)voidsetDefaultClientPackage(String defaultClientPackage)voidsetDefaultClientSuperclass(String defaultClientSuperclass)voidsetDefaultLockType(int defaultLockType)voidsetDefaultPackage(String defaultPackage)voidsetDefaultSchema(String defaultSchema)voidsetDefaultSuperclass(String defaultSuperclass)voidsetLocation(String location)Sets "location" property.voidsetName(String name)Set the name of this DataMap.voidsetNamespace(MappingNamespace namespace)Sets a parent namespace where this DataMap resides.voidsetQuotingSQLIdentifiers(boolean quotingSqlIdentifiers)StringtoString()
- 
Field Details- 
CLIENT_SUPPORTED_PROPERTYDefines whether a DataMap supports client entities.- Since:
- 1.2
- See Also:
- Constant Field Values
 
- 
DEFAULT_CLIENT_PACKAGE_PROPERTYDefines the name of the property for default client Java class package.- Since:
- 1.2
- See Also:
- Constant Field Values
 
- 
DEFAULT_CLIENT_SUPERCLASS_PROPERTYDefines the name of the property for default client Java superclass.- Since:
- 3.0
- See Also:
- Constant Field Values
 
- 
DEFAULT_CATALOG_PROPERTYDefines the name of the property for default DB catalog.- Since:
- 4.0
- See Also:
- Constant Field Values
 
- 
DEFAULT_SCHEMA_PROPERTYDefines the name of the property for default DB schema.- Since:
- 1.1
- See Also:
- Constant Field Values
 
- 
DEFAULT_PACKAGE_PROPERTYDefines the name of the property for default Java class package.- Since:
- 1.1
- See Also:
- Constant Field Values
 
- 
DEFAULT_SUPERCLASS_PROPERTYDefines the name of the property for default Java superclass.- Since:
- 1.1
- See Also:
- Constant Field Values
 
- 
DEFAULT_LOCK_TYPE_PROPERTYDefines the name of the property for default DB schema.- Since:
- 1.1
- See Also:
- Constant Field Values
 
- 
DEFAULT_QUOTE_SQL_IDENTIFIERS_PROPERTY- See Also:
- Constant Field Values
 
- 
SCHEMA_XSDThe namespace in which the data map XML file will be created. This is also the URI to locate a copy of the schema document.- See Also:
- Constant Field Values
 
- 
SCHEMA_XSD_LOCATION- See Also:
- Constant Field Values
 
- 
name
- 
location
- 
namespace
- 
quotingSQLIdentifiers
- 
defaultCatalog
- 
defaultSchema
- 
defaultPackage
- 
defaultSuperclass
- 
defaultLockTypeprotected int defaultLockType
- 
clientSupportedprotected boolean clientSupported
- 
defaultClientPackage
- 
defaultClientSuperclass
- 
configurationSource- Since:
- 3.1
 
- 
dataChannelDescriptor- Since:
- 3.1
 
 
- 
- 
Constructor Details- 
DataMappublic DataMap()Creates a new unnamed DataMap.
- 
DataMapCreates a new named DataMap.
- 
DataMap
 
- 
- 
Method Details- 
getDataChannelDescriptor- Since:
- 3.1
 
- 
setDataChannelDescriptor- Since:
- 3.1
 
- 
acceptVisitor- Specified by:
- acceptVisitorin interface- ConfigurationNode
- Since:
- 3.1
 
- 
compareTo- Specified by:
- compareToin interface- Comparable<DataMap>
- Since:
- 3.1
 
- 
isQuotingSQLIdentifierspublic boolean isQuotingSQLIdentifiers()- Since:
- 3.0
 
- 
setQuotingSQLIdentifierspublic void setQuotingSQLIdentifiers(boolean quotingSqlIdentifiers)- Since:
- 3.0
 
- 
initWithPropertiesPerforms DataMap initialization from a set of properties, using defaults for the missing properties.- Since:
- 1.1
 
- 
getClientDataMapReturns a DataMap stripped of any server-side information, such as DbEntity mapping, or ObjEntities that are not allowed in the client tier. Returns null if this DataMap as a whole does not support client tier persistence.- Since:
- 1.2
 
- 
encodeAsXMLPrints itself as XML to the provided PrintWriter.- Specified by:
- encodeAsXMLin interface- XMLSerializable
- Since:
- 1.1
 
- 
toString
- 
getNameReturns the name of this DataMap.
- 
setNameSet the name of this DataMap.
- 
mergeWithDataMapAdds all Object and DB entities and Queries from another map to this map. Overwrites all existing entities and queries with the new ones.TODO: will need to implement advanced merge that allows different policies for overwriting entities / queries. 
- 
getLocationReturns "location" property value. Location is abstract and can depend on how the DataMap was loaded. E.g. location can be a File on the filesystem or a location within a JAR.
- 
setLocationSets "location" property.
- 
getObjEntityMapReturns a unmodifiable map of ObjEntities contained in this DataMap, keyed by ObjEntity name.
- 
getDbEntityMapReturns a unmodifiable map of DbEntities contained in this DataMap, keyed by DbEntity name.
- 
getQueryDescriptorReturns a named query associated with this DataMap.- Specified by:
- getQueryDescriptorin interface- MappingNamespace
- Since:
- 4.0
 
- 
addQueryDescriptorStores a query descriptor under its name.- Since:
- 1.1
 
- 
removeQueryDescriptorRemoves a named query from the DataMap.- Since:
- 4.0
 
- 
clearEmbeddablespublic void clearEmbeddables()Removes all stored embeddable objects from the map.- Since:
- 3.0
 
- 
clearResultSetspublic void clearResultSets()- Since:
- 3.0
 
- 
clearQueriespublic void clearQueries()- Since:
- 1.1
 
- 
clearObjEntitiespublic void clearObjEntities()- Since:
- 1.2
 
- 
clearDbEntitiespublic void clearDbEntities()- Since:
- 1.2
 
- 
clearProcedurespublic void clearProcedures()- Since:
- 1.2
 
- 
getQueryDescriptorMap- Since:
- 4.0
 
- 
getQueryDescriptorsReturns an unmodifiable collection of mapped queries.- Specified by:
- getQueryDescriptorsin interface- MappingNamespace
- Since:
- 4.0
 
- 
addEmbeddableAdds an embeddable object to the DataMap.- Since:
- 3.0
 
- 
addResultAdds a named SQLResultSet to the DataMap.- Since:
- 3.0
 
- 
addObjEntityAdds a new ObjEntity to this DataMap.
- 
addDbEntityAdds a new DbEntity to this DataMap.
- 
getObjEntitiesReturns an unmodifiable collection of ObjEntities stored in this DataMap.- Specified by:
- getObjEntitiesin interface- MappingNamespace
 
- 
getEmbeddableMap- Since:
- 3.0
 
- 
getEmbeddablesReturns a collection ofEmbeddablemappings stored in the DataMap.- Specified by:
- getEmbeddablesin interface- MappingNamespace
- Since:
- 3.0
 
- 
getResultsMap- Since:
- 3.0
 
- 
getResults- Specified by:
- getResultsin interface- MappingNamespace
- Since:
- 3.0
 
- 
getEmbeddableDescription copied from interface:MappingNamespaceReturns anEmbeddablematching class name or null if such Embeddable is not mapped.- Specified by:
- getEmbeddablein interface- MappingNamespace
- Since:
- 3.0
 
- 
getResultDescription copied from interface:MappingNamespaceReturns a named result set mapping.- Specified by:
- getResultin interface- MappingNamespace
- Since:
- 3.0
 
- 
getDbEntitiesReturns all DbEntities in this DataMap.- Specified by:
- getDbEntitiesin interface- MappingNamespace
 
- 
getDbEntityReturns DbEntity matching thenameparameter. No dependencies will be searched.- Specified by:
- getDbEntityin interface- MappingNamespace
 
- 
getObjEntityForJavaClassReturns an ObjEntity for a DataObject class name.- Since:
- 1.1
 
- 
getObjEntityReturns an ObjEntity for a given name. If it is not found in this DataMap, it will search a parent EntityNamespace.- Specified by:
- getObjEntityin interface- MappingNamespace
 
- 
getMappedEntitiesReturns all ObjEntities mapped to the given DbEntity.
- 
removeEmbeddableRemoves anEmbeddabledescriptor with matching class name.- Since:
- 3.0
 
- 
removeResult- Since:
- 3.0
 
- 
removeDbEntity"Dirty" remove of the DbEntity from the data map.
- 
removeDbEntityRemoves DbEntity from the DataMap. IfclearDependenciesis true, all DbRelationships that reference this entity are also removed. ObjEntities that rely on this entity are cleaned up.- Since:
- 1.1
 
- 
removeObjEntity"Dirty" remove of the ObjEntity from the data map.
- 
removeObjEntityRemoves ObjEntity from the DataMap. IfclearDependenciesis true, all ObjRelationships that reference this entity are also removed.- Since:
- 1.1
 
- 
getProceduresReturns stored procedures associated with this DataMap.- Specified by:
- getProceduresin interface- MappingNamespace
 
- 
getProcedureReturns a Procedure for a given name or null if no such procedure exists. If Procedure is not found in this DataMap, a parent EntityNamcespace is searched.- Specified by:
- getProcedurein interface- MappingNamespace
 
- 
addProcedureAdds stored procedure to the list of procedures. If there is another procedure registered under the same name, throws an IllegalArgumentException.
- 
removeProcedure
- 
getProcedureMapReturns a sorted unmodifiable map of Procedures in this DataMap keyed by name.
- 
getNamespaceReturns a parent namespace where this DataMap resides. Parent EntityNamespace is used to establish relationships with entities in other DataMaps.- Since:
- 1.1
 
- 
setNamespaceSets a parent namespace where this DataMap resides. Parent EntityNamespace is used to establish relationships with entities in other DataMaps.- Since:
- 1.1
 
- 
getDefaultLockTypepublic int getDefaultLockType()- Since:
- 1.1
 
- 
setDefaultLockTypepublic void setDefaultLockType(int defaultLockType)- Since:
- 1.1
 
- 
isClientSupportedpublic boolean isClientSupported()- Since:
- 1.2
 
- 
setClientSupportedpublic void setClientSupported(boolean clientSupport)- Since:
- 1.2
 
- 
getDefaultClientPackageReturns default client package.- Since:
- 1.2
 
- 
setDefaultClientPackage- Since:
- 1.2
 
- 
getDefaultClientSuperclassReturns default client superclass.- Since:
- 3.0
 
- 
setDefaultClientSuperclass- Since:
- 3.0
 
- 
getDefaultPackage- Since:
- 1.1
 
- 
setDefaultPackage- Since:
- 1.1
 
- 
getDefaultSchema- Since:
- 1.1
 
- 
setDefaultSchema- Since:
- 1.1
 
- 
getDefaultSuperclass- Since:
- 1.1
 
- 
setDefaultSuperclass- Since:
- 1.1
 
- 
dbEntityChangedDbEntity property changed. May be name, attribute or relationship added or removed, etc. Attribute and relationship property changes are handled in respective listeners.- Specified by:
- dbEntityChangedin interface- DbEntityListener
- Since:
- 1.2
 
- 
dbEntityAddedNew entity has been created/added.- Specified by:
- dbEntityAddedin interface- DbEntityListener
 
- 
dbEntityRemovedEntity has been removed.- Specified by:
- dbEntityRemovedin interface- DbEntityListener
 
- 
objEntityChangedObjEntity property changed. May be name, attribute or relationship added or removed, etc. Attribute and relationship property changes are handled in respective listeners.- Specified by:
- objEntityChangedin interface- ObjEntityListener
- Since:
- 1.2
 
- 
objEntityAddedNew entity has been created/added.- Specified by:
- objEntityAddedin interface- ObjEntityListener
 
- 
objEntityRemovedEntity has been removed.- Specified by:
- objEntityRemovedin interface- ObjEntityListener
 
- 
getConfigurationSource- Since:
- 3.1
 
- 
setConfigurationSource- Since:
- 3.1
 
- 
getDefaultCatalog- Since:
- 4.0
 
- 
setDefaultCatalog- Since:
- 4.0
 
- 
getInheritanceTree- Specified by:
- getInheritanceTreein interface- MappingNamespace
- Since:
- 4.0
 
- 
getObjEntity- Specified by:
- getObjEntityin interface- MappingNamespace
- Since:
- 4.0
 
- 
getObjEntity- Specified by:
- getObjEntityin interface- MappingNamespace
 
- 
clearpublic void clear()
- 
getNameWithDefaultPackage- Returns:
- package + "." + name when it is possible otherwise just name
- Since:
- 4.0
 
- 
getNameWithPackage- Returns:
- package + "." + name when it is possible otherwise just name
- Since:
- 4.0
 
- 
getNameWithDefaultClientPackage- Returns:
- package + "." + name when it is possible otherwise just name
- Since:
- 4.0
 
- 
getSubclassesForObjEntity
 
-