Class DbEntity
java.lang.Object
org.apache.cayenne.map.Entity<DbEntity, DbAttribute, DbRelationship>
org.apache.cayenne.map.DbEntity
- All Implemented Interfaces:
Serializable, ConfigurationNode, CayenneMapEntry, XMLSerializable
public class DbEntity
extends Entity<DbEntity, DbAttribute, DbRelationship>
implements ConfigurationNode
A DbEntity is a mapping descriptor that defines a structure of a database
table.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringprotected Collection<DbAttribute> protected List<DbAttribute> protected DbKeyGeneratorprotected ExpressionQualifier, that will be applied to all select queries and joins with this DbEntityprotected StringFields inherited from class Entity
attributes, dataMap, name, OUTER_JOIN_INDICATOR, PATH_SEPARATOR, relationshipsModifier and TypeFieldDescriptionprotected final Map<String, DbAttribute> protected DataMapprotected Stringstatic final StringA prefix or a suffix that can be used in a path component to indicate that an OUTER JOIN should be used when resolving the expression.static final Stringprotected final Map<String, DbRelationship> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> TacceptVisitor(ConfigurationNodeVisitor<T> visitor) voidaddAttribute(DbAttribute attr) Adds a new attribute to this entity.voidvoidencodeAsXML(XMLEncoder encoder, ConfigurationNodeVisitor delegate) Prints itself as XML to the provided XMLEncoder.Returns the catalog name of the table described by this DbEntity.Returns table name including catalog and schema, if any of those are present.Returns an unmodifiable collection of DbAttributes that are generated by the database.Return the primary key generator for this entity.Returns an unmodifiable collection of DbAttributes representing the primary key of the table described by this DbEntity.Returns database schema of this table.booleanReturns true if there is full replacement id is attached to an ObjectId.voidremoveAttribute(String attrName) Removes attribute from the entity, removes any relationship joins containing this attribute.voidrenameAttribute(DbAttribute attr, String newName) Renames an attribute owned by this entity, re-keying the attribute map and updating all dependent references across the parentDataMap: ObjAttribute paths and DbJoin source/target names.voidrenameRelationship(DbRelationship rel, String newName) Renames a relationship owned by this entity, re-keying the relationship map and refreshing dependent ObjAttribute db-paths across the parentDataMap.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.voidsetCatalog(String catalog) Sets the catalog name of the table described by this DbEntity.voidsetPrimaryKeyGenerator(DbKeyGenerator primaryKeyGenerator) Set the primary key generator for this entity.voidsetQualifier(Expression qualifier) Sets qualifier for this entityvoidSets the database schema name of the table described by this DbEntity.translateToRelatedEntity(Expression expression, CayennePath relationshipPath) Transforms Expression rooted in this entity to an analogous expression rooted in related entity.Methods inherited from class Entity
addRelationship, clearRelationships, getAnyRelationship, getAttribute, getAttributeMap, getAttributes, getDataMap, getName, getParent, getRelationship, getRelationshipMap, getRelationships, lastPathComponent, removeRelationship, resolvePathComponents, resolvePathComponents, setDataMap, setName, setParent, toString, translateToRelatedEntity, updateAttributeModifier and TypeMethodDescriptionvoidaddRelationship(DbRelationship relationship) Adds new relationship to the entity.voidgetAnyRelationship(DbEntity 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.Returns the parent map.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.lastPathComponent(Expression path, Map<String, String> aliasMap) Convenience method returning the last component in the path iterator.voidremoveRelationship(String relName) Removes a relationship namedattrName.resolvePathComponents(String path) Returns an Iterator over the path components that contains a sequence of Attributes and Relationships.voidsetDataMap(DataMap dataMap) Sets parent DataMap of this entity.voidvoidStores the parent map.toString()translateToRelatedEntity(Expression expression, String relationshipPath) Translates Expression rooted in this entity to an analogous expression rooted in related entity.voidupdateAttribute(DbAttribute attribute)
-
Field Details
-
catalog
-
schema
-
-
generatedAttributes
- Since:
- 1.2
-
primaryKeyGenerator
-
qualifier
Qualifier, that will be applied to all select queries and joins with this DbEntity
-
-
Constructor Details
-
DbEntity
public DbEntity()Creates an unnamed DbEntity. -
DbEntity
Creates a named DbEntity.
-
-
Method Details
-
acceptVisitor
- Specified by:
acceptVisitorin interfaceConfigurationNode- Since:
- 3.1
-
encodeAsXML
Prints itself as XML to the provided XMLEncoder.- Specified by:
encodeAsXMLin interfaceXMLSerializable- Since:
- 1.1
-
getFullyQualifiedName
Returns table name including catalog and schema, if any of those are present. -
getSchema
Returns database schema of this table.- Returns:
- table's schema, null if not set.
-
setSchema
Sets the database schema name of the table described by this DbEntity. -
getCatalog
Returns the catalog name of the table described by this DbEntity. -
setCatalog
Sets the catalog name of the table described by this DbEntity. -
getPrimaryKeys
Returns an unmodifiable collection of DbAttributes representing the primary key of the table described by this DbEntity.- Since:
- 3.0
-
getGeneratedAttributes
Returns an unmodifiable collection of DbAttributes that are generated by the database.- Since:
- 1.2
-
addAttribute
Adds a new attribute to this entity.- Overrides:
addAttributein classEntity<DbEntity, DbAttribute, DbRelationship>- Throws:
IllegalArgumentException- if Attribute has no name or there is an existing attribute with the same nameIllegalArgumentException- if a relationship has the same name as this attribute- Since:
- 3.0
-
removeAttribute
Removes attribute from the entity, removes any relationship joins containing this attribute. Does nothing if the attribute name is not found.- Overrides:
removeAttributein classEntity<DbEntity, DbAttribute, DbRelationship>- See Also:
-
clearAttributes
public void clearAttributes()- Overrides:
clearAttributesin classEntity<DbEntity, DbAttribute, DbRelationship>
-
renameAttribute
Renames an attribute owned by this entity, re-keying the attribute map and updating all dependent references across the parentDataMap: ObjAttribute paths and DbJoin source/target names.- Since:
- 5.0
-
renameRelationship
Renames a relationship owned by this entity, re-keying the relationship map and refreshing dependent ObjAttribute db-paths across the parentDataMap.- Since:
- 5.0
-
resolvePath
public Iterable<PathComponent<DbAttribute, DbRelationship>> resolvePath(Expression pathExp, Map<String, String> aliasMap) Returns an Iterable instance over expression path components based on this entity.- Specified by:
resolvePathin classEntity<DbEntity, DbAttribute, DbRelationship>- Since:
- 3.0
-
resolvePathComponents
public 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 classEntity<DbEntity, DbAttribute, DbRelationship>- Throws:
ExpressionException
-
setPrimaryKeyGenerator
Set the primary key generator for this entity. If null is passed, nothing is changed. -
getPrimaryKeyGenerator
Return the primary key generator for this entity. -
getQualifier
- Returns:
- qualifier that will be ANDed to all select queries with this entity
-
setQualifier
Sets qualifier for this entity -
isFullReplacementIdAttached
Returns true if there is full replacement id is attached to an ObjectId. "Full" means that all PK columns are present and only PK columns are present.- Since:
- 1.2
-
mappedObjEntities
-
translateToRelatedEntity
Transforms Expression rooted in this entity to an analogous expression rooted in related entity.- Specified by:
translateToRelatedEntityin classEntity<DbEntity, DbAttribute, DbRelationship>- Since:
- 5.0
-