Package org.apache.cayenne.map
Class ObjEntity
java.lang.Object
org.apache.cayenne.map.Entity<ObjEntity,ObjAttribute,ObjRelationship>
  
org.apache.cayenne.map.ObjEntity
- All Implemented Interfaces:
- Serializable,- EventListener,- ConfigurationNode,- ObjEntityListener,- CayenneMapEntry,- XMLSerializable
public class ObjEntity
extends Entity<ObjEntity,ObjAttribute,ObjRelationship>
implements ObjEntityListener, ConfigurationNode  
ObjEntity is a mapping descriptor for a Persistent Java class. It contains
 the information about the Java class itself, as well as its mapping to the
 DbEntity layer.
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected booleanprotected Map<String,CayennePath> protected CallbackMapprotected Stringprotected Stringprotected static final Collection<String>A collection of default "generic" entity classes excluded from class generation.static final intstatic final intprotected intprotected Expressionprotected booleanprotected Stringprotected StringFields inherited from class org.apache.cayenne.map.Entityattributes, dataMap, name, OUTER_JOIN_INDICATOR, PATH_SEPARATOR, relationships
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescription<T> TacceptVisitor(ConfigurationNodeVisitor<T> visitor) voidaddAttributeOverride(String attributeName, String dbPath) voidaddAttributeOverride(String attributeName, CayennePath dbPath) voidClears all the mapping between this obj entity and its current db entity.voidencodeAsXML(XMLEncoder encoder, ConfigurationNodeVisitor delegate) Prints itself as XML to the provided XMLEncoder.getAttribute(String name) Returns a named attribute that is either declared in this ObjEntity or is inherited.getAttributeForDbAttribute(DbAttribute dbAttribute) Returns ObjAttribute of this entity that maps todbAttributeparameter.Returns a Map of all attributes that either belong to this ObjEntity or inherited.Returns a Collection of all attributes that either belong to this ObjEntity or inherited.Returns an object that stores callback methods of this entity.Returns the name of Persistent class described by this entity.Returns a DbEntity associated with this ObjEntity.Returns the name of the underlying DbEntity.getDeclaredAttribute(String name) Finds attribute declared by this ObjEntity, excluding inherited attributes.Returns a Collection of all attributes that belong to this ObjEntity, excluding inherited attributes.intReturns the type of lock used by this ObjEntity, regardless of what locking type is used by super entities.Returns a qualifier that imposes a restriction on what objects belong to this entity.Returns a Collection of all relationships that belong to this ObjEntity, excluding inherited attributes.Returns a non-null class name.intReturns the type of lock used by this ObjEntity.Returns the names of DbAtributes that comprise the primary key of the parent DbEntity.Returns an unmodifiable collection of ObjAttributes representing the primary key of the table described by this DbEntity.getRelationship(String name) Returns a named Relationship that either belongs to this ObjEntity or is inherited.getRelationshipForDbRelationship(DbRelationship dbRelationship) Returns ObjRelationship of this entity that maps todbRelationshipparameter.Returns an unmodifiable map of relationships sorted by name.Returns an unmodifiable collection of Relationships that exist in this entity.Returns a fully-qualified name of the super class of the Persistent class.Returns a "super" entity in the entity inheritance hierarchy.Returns an entity name for a parent entity in the inheritance hierarchy.booleanbooleanReturns whether this entity is "generic", meaning it is not mapped to a unique Java class.booleanReturnstrueif this ObjEntity represents a set of read-only objects.booleanisSubentityOf(ObjEntity entity) Returns true if this entity directly or indirectly inherits from a given entity, false otherwise.voidNew entity has been created/added.voidObjEntity property changed.voidEntity has been removed.voidremoveAttributeOverride(String attributeName) resolvePath(Expression pathExp, Map<String, String> aliasMap) Returns an Iterable instance over expression path components based on this entity.resolvePathComponents(Expression pathExp) Processes expressionpathExpand returns an Iterator of path components that contains a sequence of Attributes and Relationships.voidsetAbstract(boolean isAbstract) Sets whether this entity is abstract only.voidsetClassName(String className) Sets the name of the Persistent class described by this entity.voidsetDbEntity(DbEntity dbEntity) Sets the DbEntity used by this ObjEntity.voidsetDbEntityName(String string) Sets the name of underlying DbEntity.voidsetDeclaredLockType(int i) Sets the type of lock used by this ObjEntity.voidsetDeclaredQualifier(Expression qualifier) Sets a qualifier that imposes a limit on what objects belong to this entity.voidsetReadOnly(boolean readOnly) voidsetSuperClassName(String superClassName) Sets a fully-qualified name of the super class of the Persistent class.voidsetSuperEntityName(String superEntityName) Sets an entity name for a parent entity in the inheritance hierarchy.translateToDbPath(Expression expression) Transforms an Expression to an analogous expression in terms of the underlying DbEntity.translateToRelatedEntity(Expression expression, String relationshipPath) Transforms an Expression rooted in this entity to an analogous expression rooted in related entity.translateToRelatedEntity(Expression expression, CayennePath relationshipPath) Transforms an Expression rooted in this entity to an analogous expression rooted in related entity.Methods inherited from class org.apache.cayenne.map.EntityaddAttribute, addRelationship, clearAttributes, clearRelationships, getAnyRelationship, getDataMap, getName, getParent, lastPathComponent, removeAttribute, removeRelationship, resolvePathComponents, resolvePathComponents, setDataMap, setName, setParent, toString, updateAttribute
- 
Field Details- 
LOCK_TYPE_NONEpublic static final int LOCK_TYPE_NONE- See Also:
 
- 
LOCK_TYPE_OPTIMISTICpublic static final int LOCK_TYPE_OPTIMISTIC- See Also:
 
- 
DEFAULT_GENERIC_CLASSESA collection of default "generic" entity classes excluded from class generation.- Since:
- 1.2
 
- 
superClassName
- 
className
- 
dbEntityName
- 
superEntityName
- 
qualifier
- 
readOnlyprotected boolean readOnly
- 
lockTypeprotected int lockType
- 
_abstractprotected boolean _abstract
- 
callbacks
- 
attributeOverrides
 
- 
- 
Constructor Details- 
ObjEntitypublic ObjEntity()
- 
ObjEntity
 
- 
- 
Method Details- 
acceptVisitor- Specified by:
- acceptVisitorin interface- ConfigurationNode
- Since:
- 3.1
 
- 
encodeAsXMLPrints itself as XML to the provided XMLEncoder.- Specified by:
- encodeAsXMLin interface- XMLSerializable
- Since:
- 1.1
 
- 
getJavaClassNameReturns a non-null class name. For generic entities with no class specified explicitly, default DataMap superclass is used, and if it is not set - GenericPersistentObject is used.- Since:
- 4.0
 
- 
getCallbackMapReturns an object that stores callback methods of this entity.- Since:
- 3.0
 
- 
getLockTypepublic int getLockType()Returns the type of lock used by this ObjEntity. If this entity is not locked, this method would look in a super entity recursively, until it finds a lock somewhere in the inheritance hierarchy.- Since:
- 1.1
 
- 
getDeclaredLockTypepublic int getDeclaredLockType()Returns the type of lock used by this ObjEntity, regardless of what locking type is used by super entities.- Since:
- 1.1
 
- 
setDeclaredLockTypepublic void setDeclaredLockType(int i) Sets the type of lock used by this ObjEntity.- Since:
- 1.1
 
- 
isGenericpublic boolean isGeneric()Returns whether this entity is "generic", meaning it is not mapped to a unique Java class. Criterion for generic entities is that it either has no Java class mapped or its class is the same as DataMap's default superclass, or it is GenericPersistentObject.- Since:
- 1.2
 
- 
isAbstractpublic boolean isAbstract()
- 
setAbstractpublic void setAbstract(boolean isAbstract) Sets whether this entity is abstract only.
- 
getDeclaredQualifierReturns a qualifier that imposes a restriction on what objects belong to this entity. Returned qualifier is the one declared in this entity, and does not include qualifiers declared in super entities.- Since:
- 1.1
 
- 
getSuperEntityNameReturns an entity name for a parent entity in the inheritance hierarchy.- Since:
- 1.1
 
- 
setDeclaredQualifierSets a qualifier that imposes a limit on what objects belong to this entity.- Since:
- 1.1
 
- 
setSuperEntityNameSets an entity name for a parent entity in the inheritance hierarchy.- Since:
- 1.1
 
- 
getClassNameReturns the name of Persistent class described by this entity.
- 
setClassNameSets the name of the Persistent class described by this entity.
- 
getSuperClassNameReturns a fully-qualified name of the super class of the Persistent class. This value is used as a hint for class generation. If the entity inherits from another entity, a superclass is the class of that entity.
- 
setSuperClassNameSets a fully-qualified name of the super class of the Persistent class. This value is used as a hint for class generation.An attempt to set superclass on an inherited entity has no effect, since a class of the super entity is always used as a superclass. 
- 
getSuperEntityReturns a "super" entity in the entity inheritance hierarchy.- Since:
- 1.1
 
- 
getDbEntityReturns a DbEntity associated with this ObjEntity.
- 
setDbEntitySets the DbEntity used by this ObjEntity.Setting DbEntity on an inherited entity has no effect, since a class of the super entity is always used as a superclass. 
- 
getPrimaryKeysReturns an unmodifiable collection of ObjAttributes representing the primary key of the table described by this DbEntity. Note that since PK is very often not an object property, the returned collection may contain "synthetic" ObjAttributes that are created on the fly and are not a part of ObjEntity and will not be a part of entity.getAttributes().- Since:
- 3.0
 
- 
getAttributeReturns a named attribute that is either declared in this ObjEntity or is inherited. In any case returned attribute 'getEntity' method will return this entity. Returns null if no matching attribute is found.- Overrides:
- getAttributein class- Entity<ObjEntity,- ObjAttribute, - ObjRelationship> 
 
- 
getAttributeMapReturns a Map of all attributes that either belong to this ObjEntity or inherited.- Overrides:
- getAttributeMapin class- Entity<ObjEntity,- ObjAttribute, - ObjRelationship> 
 
- 
addAttributeOverride- Since:
- 3.0
- See Also:
 
- 
addAttributeOverride- Since:
- 5.0
 
- 
removeAttributeOverride- Since:
- 4.0
 
- 
getDeclaredAttributeOverrides- Since:
- 3.0, 5.0 result map uses CayennePathinstead of String as values
 
- 
getAttributesReturns a Collection of all attributes that either belong to this ObjEntity or inherited.- Overrides:
- getAttributesin class- Entity<ObjEntity,- ObjAttribute, - ObjRelationship> 
 
- 
getDeclaredAttributesReturns a Collection of all attributes that belong to this ObjEntity, excluding inherited attributes.- Since:
- 1.1
 
- 
getDeclaredAttributeFinds attribute declared by this ObjEntity, excluding inherited attributes.- Parameters:
- name- of the attribute
- Returns:
- declared attribute or null if no attribute is found
- Since:
- 4.0
- See Also:
 
- 
getRelationshipReturns a named Relationship that either belongs to this ObjEntity or is inherited. Returns null if no matching attribute is found.- Overrides:
- getRelationshipin class- Entity<ObjEntity,- ObjAttribute, - ObjRelationship> 
 
- 
getRelationshipMapDescription copied from class:EntityReturns an unmodifiable map of relationships sorted by name.- Overrides:
- getRelationshipMapin class- Entity<ObjEntity,- ObjAttribute, - ObjRelationship> 
 
- 
getRelationshipsDescription copied from class:EntityReturns an unmodifiable collection of Relationships that exist in this entity.- Overrides:
- getRelationshipsin class- Entity<ObjEntity,- ObjAttribute, - ObjRelationship> 
 
- 
getDeclaredRelationshipsReturns a Collection of all relationships that belong to this ObjEntity, excluding inherited attributes.- Since:
- 1.1
 
- 
getAttributeForDbAttributeReturns ObjAttribute of this entity that maps todbAttributeparameter. Returns null if no such attribute is found.
- 
getPrimaryKeyNamesReturns the names of DbAtributes that comprise the primary key of the parent DbEntity.- Since:
- 3.0
 
- 
getRelationshipForDbRelationshipReturns ObjRelationship of this entity that maps todbRelationshipparameter. Returns null if no such relationship is found.
- 
clearDbMappingpublic void clearDbMapping()Clears all the mapping between this obj entity and its current db entity. Clears mapping between entities, attributes and relationships.
- 
isReadOnlypublic boolean isReadOnly()Returnstrueif this ObjEntity represents a set of read-only objects.- Returns:
- boolean
 
- 
setReadOnlypublic void setReadOnly(boolean readOnly) 
- 
isSubentityOfReturns true if this entity directly or indirectly inherits from a given entity, false otherwise.- Since:
- 1.1
 
- 
resolvePathpublic Iterable<PathComponent<ObjAttribute,ObjRelationship>> resolvePath(Expression pathExp, Map<String, String> aliasMap) Returns an Iterable instance over expression path components based on this entity.- Specified by:
- resolvePathin class- Entity<ObjEntity,- ObjAttribute, - ObjRelationship> 
- Since:
- 3.0
 
- 
resolvePathComponentspublic Iterator<CayenneMapEntry> resolvePathComponents(Expression pathExp) throws ExpressionException Description copied from class:EntityProcesses expressionpathExpand returns an Iterator of path components that contains a sequence of Attributes and Relationships. Note that if path is invalid and can not be resolved from this entity, this method will still return an Iterator, but an attempt to read the first invalid path component will result in ExpressionException.- Specified by:
- resolvePathComponentsin class- Entity<ObjEntity,- ObjAttribute, - ObjRelationship> 
- Throws:
- ExpressionException
 
- 
translateToDbPathTransforms an Expression to an analogous expression in terms of the underlying DbEntity.- Since:
- 1.1
 
- 
translateToRelatedEntityTransforms an Expression rooted in this entity to an analogous expression rooted in related entity.- Overrides:
- translateToRelatedEntityin class- Entity<ObjEntity,- ObjAttribute, - ObjRelationship> 
- Since:
- 1.1
- See Also:
 
- 
translateToRelatedEntityTransforms an Expression rooted in this entity to an analogous expression rooted in related entity.- Specified by:
- translateToRelatedEntityin class- Entity<ObjEntity,- ObjAttribute, - ObjRelationship> 
- Parameters:
- expression- expression to translate
- relationshipPath- path to the related entity
- Returns:
- transformed expression
- Since:
- 5.0
 
- 
getCallbackMethods- Since:
- 4.0
 
- 
getDbEntityNameReturns the name of the underlying DbEntity.- Since:
- 1.1
 
- 
setDbEntityNameSets the name of underlying DbEntity.- Since:
- 1.1
 
- 
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
 
 
-