Class Entity<E extends Entity<E,A,R> , A extends Attribute<E,A,R> , R extends Relationship<E,A,R> >
java.lang.Object
org.apache.cayenne.map.Entity<E,A,R>
- All Implemented Interfaces:
XMLSerializable
public abstract class Entity<E extends Entity<E,A,R>, A extends Attribute<E,A,R>, R extends Relationship<E,A,R>>
extends Object
implements XMLSerializable
An abstract descriptor for an entity mapping concept. Entity can represent either a descriptor of database table or
a persistent object.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAttribute(A attribute) Adds new attribute to the entity, setting its parent entity to be this object.voidaddRelationship(R relationship) Adds new relationship to the entity.voidvoidgetAnyRelationship(E targetEntity) Returns a relationship that has a specified entity as a target.getAttribute(String attributeName) Returns attribute with nameattributeNameor null if no attribute with this name exists.Returns an unmodifiable sorted map of entity attributes.Returns an unmodifiable collection of entity attributes.getName()Returns entity name.getRelationship(String relName) Returns relationship with namerelName.Returns an unmodifiable map of relationships sorted by name.Returns an unmodifiable collection of Relationships that exist in this entity.voidremoveAttribute(String attrName) Removes an attribute namedattrName.voidremoveRelationship(String relName) Removes a relationship namedattrName.resolvePath(String path) Resolves the path against this entity into a list of Attributes and Relationships, one per path segment.resolvePath(CayennePath path) Resolves the path against this entity into a list of Attributes and Relationships, one per path segment.voidsetDataMap(DataMap dataMap) Sets parent DataMap of this entity.voidtoString()translateToRelatedEntity(Expression expression, String relationshipPath) Translates Expression rooted in this entity to an analogous expression rooted in related entity.abstract ExpressiontranslateToRelatedEntity(Expression expression, CayennePath relationshipPath) Transforms Expression rooted in this entity to an analogous expression rooted in related entity.voidupdateAttribute(A attribute) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface XMLSerializable
encodeAsXML
-
Field Details
-
PATH_SEPARATOR
- See Also:
-
OUTER_JOIN_INDICATOR
Deprecated, for removal: This API element is subject to removal in a future version.in favor ofCayennePath.OUTER_JOIN_INDICATORA suffix that can be used in a path component to indicate that an OUTER JOIN should be used when resolving the expression.- Since:
- 3.0
- See Also:
-
name
-
dataMap
-
attributes
-
relationships
-
-
Constructor Details
-
Entity
public Entity()Creates an unnamed Entity. -
Entity
Creates a named Entity.
-
-
Method Details
-
toString
-
getName
Returns entity name. Name is a unique identifier of the entity within its DataMap. -
setName
-
getDataMap
- Returns:
- parent DataMap of this entity.
-
setDataMap
Sets parent DataMap of this entity. -
getAttribute
-
addAttribute
Adds new attribute to the entity, setting its parent entity to be this object. If attribute has no name, IllegalArgumentException is thrown. -
removeAttribute
Removes an attribute namedattrName. -
updateAttribute
- Since:
- 4.0
-
clearAttributes
public void clearAttributes() -
getRelationship
-
addRelationship
Adds new relationship to the entity. -
removeRelationship
Removes a relationship namedattrName. -
clearRelationships
public void clearRelationships() -
getRelationshipMap
-
getAnyRelationship
-
getRelationships
Returns an unmodifiable collection of Relationships that exist in this entity. -
getAttributeMap
-
getAttributes
Returns an unmodifiable collection of entity attributes. -
translateToRelatedEntity
Translates Expression rooted in this entity to an analogous expression rooted in related entity.- Since:
- 1.1
-
translateToRelatedEntity
public abstract Expression translateToRelatedEntity(Expression expression, CayennePath relationshipPath) Transforms Expression rooted in this entity to an analogous expression rooted in related entity.- Since:
- 5.0
-
resolvePath
Resolves the path against this entity into a list of Attributes and Relationships, one per path segment. An invalid path results in an ExpressionException.- Throws:
ExpressionException- Since:
- 5.0
-
resolvePath
Resolves the path against this entity into a list of Attributes and Relationships, one per path segment. Aliases are not resolved here: expand them first withCayennePath.expandAliases(Map). An invalid path results in an ExpressionException.- Throws:
ExpressionException- Since:
- 5.0
-
CayennePath.OUTER_JOIN_INDICATOR