Package org.apache.cayenne.map
Class DbEntity
java.lang.Object
org.apache.cayenne.map.Entity
org.apache.cayenne.map.DbEntity
- All Implemented Interfaces:
- Serializable,- EventListener,- ConfigurationNode,- DbAttributeListener,- DbEntityListener,- DbRelationshipListener,- CayenneMapEntry,- XMLSerializable
- Direct Known Subclasses:
- DetectedDbEntity
public class DbEntity extends Entity implements ConfigurationNode, DbEntityListener, DbAttributeListener, DbRelationshipListener
A DbEntity is a mapping descriptor that defines a structure of a database
 table.
- See Also:
- Serialized Form
- 
Field SummaryFields Modifier and Type Field Description protected Stringcatalogprotected Collection<DbAttribute>generatedAttributesprotected Collection<DbAttribute>primaryKeyprotected DbKeyGeneratorprimaryKeyGeneratorprotected ExpressionqualifierQualifier, that will be applied to all select queries and joins with this DbEntityprotected StringschemaFields inherited from class org.apache.cayenne.map.Entityattributes, dataMap, name, OUTER_JOIN_INDICATOR, PATH_SEPARATOR, relationships
- 
Constructor Summary
- 
Method SummaryModifier and Type Method Description <T> TacceptVisitor(ConfigurationNodeVisitor<T> visitor)voidaddAttribute(DbAttribute attr)Adds a new attribute to this entity.voidclearAttributes()voiddbAttributeAdded(AttributeEvent e)New attribute has been created/added.voiddbAttributeChanged(AttributeEvent e)Attribute property changed.voiddbAttributeRemoved(AttributeEvent e)Attribute has been removed.voiddbEntityAdded(EntityEvent e)New entity has been created/added.voiddbEntityChanged(EntityEvent e)DbEntity property changed event.voiddbEntityRemoved(EntityEvent e)Entity has been removed.voiddbRelationshipAdded(RelationshipEvent e)Relationship has been created/added.voiddbRelationshipChanged(RelationshipEvent e)Relationship property changed.voiddbRelationshipRemoved(RelationshipEvent e)Relationship has been removed.voidencodeAsXML(XMLEncoder encoder, ConfigurationNodeVisitor delegate)Prints itself as XML to the provided XMLEncoder.DbAttributegetAttribute(String attributeName)Returns attribute with nameattributeNameor null if no attribute with this name exists.Collection<DbAttribute>getAttributes()Returns a Collection of all attributes that either belong to this DbEntity or inherited.StringgetCatalog()Returns the catalog name of the table described by this DbEntity.StringgetFullyQualifiedName()Returns table name including catalog and schema, if any of those are present.Collection<DbAttribute>getGeneratedAttributes()Returns an unmodifiable collection of DbAttributes that are generated by the database.DbKeyGeneratorgetPrimaryKeyGenerator()Return the primary key generator for this entity.Collection<DbAttribute>getPrimaryKeys()Returns an unmodifiable collection of DbAttributes representing the primary key of the table described by this DbEntity.ExpressiongetQualifier()DbRelationshipgetRelationship(String relName)Returns relationship with namerelName.Map<String,DbRelationship>getRelationshipMap()Returns an unmodifiable map of relationships sorted by name.Collection<DbRelationship>getRelationships()Returns a Collection of relationships from this entity or inherited.StringgetSchema()Returns database schema of this table.booleanisFullReplacementIdAttached(ObjectId id)Returns true if there is full replacement id is attached to an ObjectId.PathComponent<DbAttribute,DbRelationship>lastPathComponent(Expression path, Map aliasMap)Convenience method returning the last component in the path iterator.Collection<ObjEntity>mappedObjEntities()voidremoveAttribute(String attrName)Removes attribute from the entity, removes any relationship joins containing this attribute.Iterable<PathComponent<DbAttribute,DbRelationship>>resolvePath(Expression pathExp, Map aliasMap)Returns an Iterable instance over expression path components based on this entity.Iterator<CayenneMapEntry>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 entityvoidsetSchema(String schema)Sets the database schema name of the table described by this DbEntity.ExpressiontranslateToRelatedEntity(Expression expression, String relationshipPath)Transforms Expression rooted in this entity to an analogous expression rooted in related entity.Methods inherited from class org.apache.cayenne.map.EntityaddAttribute, addRelationship, clearRelationships, getAnyRelationship, getAttributeMap, getDataMap, getName, getParent, removeRelationship, resolvePathComponents, setDataMap, setName, setParent, toString, updateAttribute
- 
Field Details- 
catalog
- 
schema
- 
- 
generatedAttributes- Since:
- 1.2
 
- 
primaryKeyGenerator
- 
qualifierQualifier, that will be applied to all select queries and joins with this DbEntity
 
- 
- 
Constructor Details- 
DbEntitypublic DbEntity()Creates an unnamed DbEntity.
- 
DbEntityCreates a named DbEntity.
 
- 
- 
Method Details- 
getRelationshipDescription copied from class:EntityReturns relationship with namerelName. Will return null if no relationship with this name exists in the entity.- Overrides:
- getRelationshipin class- Entity
 
- 
getAttributeDescription copied from class:EntityReturns attribute with nameattributeNameor null if no attribute with this name exists.- Overrides:
- getAttributein class- Entity
 
- 
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
 
- 
getFullyQualifiedNameReturns table name including catalog and schema, if any of those are present.
- 
getSchemaReturns database schema of this table.- Returns:
- table's schema, null if not set.
 
- 
setSchemaSets the database schema name of the table described by this DbEntity.
- 
getCatalogReturns the catalog name of the table described by this DbEntity.
- 
setCatalogSets the catalog name of the table described by this DbEntity.
- 
getPrimaryKeysReturns an unmodifiable collection of DbAttributes representing the primary key of the table described by this DbEntity.- Since:
- 3.0
 
- 
getAttributesReturns a Collection of all attributes that either belong to this DbEntity or inherited.- Overrides:
- getAttributesin class- Entity
 
- 
getGeneratedAttributesReturns an unmodifiable collection of DbAttributes that are generated by the database.- Since:
- 1.2
 
- 
addAttributeAdds a new attribute to this entity.- Throws:
- IllegalArgumentException- if Attribute has no name or there is an existing attribute with the same name
- IllegalArgumentException- if a relationship has the same name as this attribute
- Since:
- 3.0
 
- 
removeAttributeRemoves attribute from the entity, removes any relationship joins containing this attribute. Does nothing if the attribute name is not found.- Overrides:
- removeAttributein class- Entity
- See Also:
- Entity.removeAttribute(String)
 
- 
clearAttributespublic void clearAttributes()- Overrides:
- clearAttributesin class- Entity
 
- 
getRelationshipsReturns a Collection of relationships from this entity or inherited.- Overrides:
- getRelationshipsin class- Entity
 
- 
getRelationshipMapDescription copied from class:EntityReturns an unmodifiable map of relationships sorted by name.- Overrides:
- getRelationshipMapin class- Entity
 
- 
lastPathComponentDescription copied from class:EntityConvenience method returning the last component in the path iterator. If the last component is an alias, it is fully resolved down to the last ObjRelationship.- Overrides:
- lastPathComponentin class- Entity
- Since:
- 3.0
 
- 
resolvePathpublic Iterable<PathComponent<DbAttribute,DbRelationship>> resolvePath(Expression pathExp, Map aliasMap)Returns an Iterable instance over expression path components based on this entity.- Specified by:
- resolvePathin class- Entity
- Since:
- 3.0
 
- 
resolvePathComponentspublic Iterator<CayenneMapEntry> resolvePathComponents(Expression pathExp) throws ExpressionExceptionDescription 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
- Throws:
- ExpressionException
 
- 
setPrimaryKeyGeneratorSet the primary key generator for this entity. If null is passed, nothing is changed.
- 
getPrimaryKeyGeneratorReturn the primary key generator for this entity.
- 
dbEntityChangedDbEntity property changed event. 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
 
- 
dbAttributeAddedDescription copied from interface:DbAttributeListenerNew attribute has been created/added.- Specified by:
- dbAttributeAddedin interface- DbAttributeListener
 
- 
dbAttributeChangedDescription copied from interface:DbAttributeListenerAttribute property changed.- Specified by:
- dbAttributeChangedin interface- DbAttributeListener
 
- 
dbAttributeRemovedDescription copied from interface:DbAttributeListenerAttribute has been removed.- Specified by:
- dbAttributeRemovedin interface- DbAttributeListener
 
- 
dbRelationshipChangedRelationship property changed.- Specified by:
- dbRelationshipChangedin interface- DbRelationshipListener
 
- 
dbRelationshipAddedRelationship has been created/added.- Specified by:
- dbRelationshipAddedin interface- DbRelationshipListener
 
- 
dbRelationshipRemovedRelationship has been removed.- Specified by:
- dbRelationshipRemovedin interface- DbRelationshipListener
 
- 
getQualifier- Returns:
- qualifier that will be ANDed to all select queries with this entity
 
- 
setQualifierSets qualifier for this entity
- 
isFullReplacementIdAttachedReturns 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
- 
translateToRelatedEntityTransforms Expression rooted in this entity to an analogous expression rooted in related entity.- Specified by:
- translateToRelatedEntityin class- Entity
- Since:
- 1.1
 
 
-