public class DbEntity extends Entity implements ConfigurationNode, DbEntityListener, DbAttributeListener, DbRelationshipListener
Modifier and Type | Field and Description |
---|---|
protected String |
catalog |
protected Collection<DbAttribute> |
generatedAttributes |
protected Collection<DbAttribute> |
primaryKey |
protected DbKeyGenerator |
primaryKeyGenerator |
protected Expression |
qualifier
Qualifier, that will be applied to all select queries and joins with this DbEntity
|
protected String |
schema |
attributes, dataMap, name, OUTER_JOIN_INDICATOR, PATH_SEPARATOR, relationships
Constructor and Description |
---|
DbEntity()
Creates an unnamed DbEntity.
|
DbEntity(String name)
Creates a named DbEntity.
|
Modifier and Type | Method and Description |
---|---|
<T> T |
acceptVisitor(ConfigurationNodeVisitor<T> visitor) |
void |
addAttribute(DbAttribute attr)
Adds a new attribute to this entity.
|
void |
clearAttributes() |
void |
dbAttributeAdded(AttributeEvent e)
New attribute has been created/added.
|
void |
dbAttributeChanged(AttributeEvent e)
Attribute property changed.
|
void |
dbAttributeRemoved(AttributeEvent e)
Attribute has been removed.
|
void |
dbEntityAdded(EntityEvent e)
New entity has been created/added.
|
void |
dbEntityChanged(EntityEvent e)
DbEntity property changed event.
|
void |
dbEntityRemoved(EntityEvent e)
Entity has been removed.
|
void |
dbRelationshipAdded(RelationshipEvent e)
Relationship has been created/added.
|
void |
dbRelationshipChanged(RelationshipEvent e)
Relationship property changed.
|
void |
dbRelationshipRemoved(RelationshipEvent e)
Relationship has been removed.
|
void |
encodeAsXML(XMLEncoder encoder)
Prints itself as XML to the provided XMLEncoder.
|
Collection<DbAttribute> |
getAttributes()
Returns a Collection of all attributes that either belong to this DbEntity or
inherited.
|
String |
getCatalog()
Returns the catalog name of the table described by this DbEntity.
|
String |
getFullyQualifiedName()
Returns table name including schema, if present.
|
Collection<DbAttribute> |
getGeneratedAttributes()
Returns an unmodifiable collection of DbAttributes that are generated by the
database.
|
DbKeyGenerator |
getPrimaryKeyGenerator()
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.
|
Expression |
getQualifier() |
SortedMap<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.
|
String |
getSchema()
Returns database schema of this table.
|
boolean |
isFullReplacementIdAttached(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.
|
void |
removeAttribute(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 expression
pathExp and returns an Iterator of path
components that contains a sequence of Attributes and Relationships. |
void |
setCatalog(String catalog)
Sets the catalog name of the table described by this DbEntity.
|
void |
setPrimaryKeyGenerator(DbKeyGenerator primaryKeyGenerator)
Set the primary key generator for this entity.
|
void |
setQualifier(Expression qualifier)
Sets qualifier for this entity
|
void |
setSchema(String schema)
Sets the database schema name of the table described by this DbEntity.
|
Expression |
translateToRelatedEntity(Expression expression,
String relationshipPath)
Transforms Expression rooted in this entity to an analogous expression rooted in
related entity.
|
addAttribute, addRelationship, clearRelationships, getAnyRelationship, getAttribute, getAttributeMap, getDataMap, getName, getParent, getRelationship, removeRelationship, resolvePathComponents, setDataMap, setName, setParent, toString
protected String catalog
protected String schema
protected Collection<DbAttribute> primaryKey
protected Collection<DbAttribute> generatedAttributes
protected DbKeyGenerator primaryKeyGenerator
protected Expression qualifier
public DbEntity()
public DbEntity(String name)
public <T> T acceptVisitor(ConfigurationNodeVisitor<T> visitor)
acceptVisitor
in interface ConfigurationNode
public void encodeAsXML(XMLEncoder encoder)
encodeAsXML
in interface XMLSerializable
public String getFullyQualifiedName()
public String getSchema()
public void setSchema(String schema)
public String getCatalog()
public void setCatalog(String catalog)
public Collection<DbAttribute> getPrimaryKeys()
public Collection<DbAttribute> getAttributes()
getAttributes
in class Entity
public Collection<DbAttribute> getGeneratedAttributes()
public void addAttribute(DbAttribute attr)
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
attributepublic void removeAttribute(String attrName)
removeAttribute
in class Entity
Entity.removeAttribute(String)
public void clearAttributes()
clearAttributes
in class Entity
public Collection<DbRelationship> getRelationships()
getRelationships
in class Entity
public SortedMap<String,DbRelationship> getRelationshipMap()
Entity
getRelationshipMap
in class Entity
public PathComponent<DbAttribute,DbRelationship> lastPathComponent(Expression path, Map aliasMap)
Entity
lastPathComponent
in class Entity
public Iterable<PathComponent<DbAttribute,DbRelationship>> resolvePath(Expression pathExp, Map aliasMap)
resolvePath
in class Entity
public Iterator<CayenneMapEntry> resolvePathComponents(Expression pathExp) throws ExpressionException
Entity
pathExp
and 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.resolvePathComponents
in class Entity
ExpressionException
public void setPrimaryKeyGenerator(DbKeyGenerator primaryKeyGenerator)
public DbKeyGenerator getPrimaryKeyGenerator()
public void dbEntityChanged(EntityEvent e)
dbEntityChanged
in interface DbEntityListener
public void dbEntityAdded(EntityEvent e)
dbEntityAdded
in interface DbEntityListener
public void dbEntityRemoved(EntityEvent e)
dbEntityRemoved
in interface DbEntityListener
public void dbAttributeAdded(AttributeEvent e)
DbAttributeListener
dbAttributeAdded
in interface DbAttributeListener
public void dbAttributeChanged(AttributeEvent e)
DbAttributeListener
dbAttributeChanged
in interface DbAttributeListener
public void dbAttributeRemoved(AttributeEvent e)
DbAttributeListener
dbAttributeRemoved
in interface DbAttributeListener
public void dbRelationshipChanged(RelationshipEvent e)
dbRelationshipChanged
in interface DbRelationshipListener
public void dbRelationshipAdded(RelationshipEvent e)
dbRelationshipAdded
in interface DbRelationshipListener
public void dbRelationshipRemoved(RelationshipEvent e)
dbRelationshipRemoved
in interface DbRelationshipListener
public Expression getQualifier()
public void setQualifier(Expression qualifier)
public boolean isFullReplacementIdAttached(ObjectId id)
public Expression translateToRelatedEntity(Expression expression, String relationshipPath)
translateToRelatedEntity
in class Entity
Copyright © 2001–2018 Apache Cayenne. All rights reserved.