|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.cayenne.map.Entity
org.apache.cayenne.map.DbEntity
public class DbEntity
A DbEntity is a mapping descriptor that defines a structure of a database table.
Field Summary | |
---|---|
protected java.lang.String |
catalog
|
protected java.util.Collection<DbAttribute> |
generatedAttributes
|
protected java.util.Collection<DbAttribute> |
primaryKey
|
protected DbKeyGenerator |
primaryKeyGenerator
|
protected Expression |
qualifier
Qualifier, that will be applied to all select queries and joins with this DbEntity |
protected java.lang.String |
schema
|
Fields inherited from class org.apache.cayenne.map.Entity |
---|
attributes, dataMap, name, OUTER_JOIN_INDICATOR, PATH_SEPARATOR, relationships |
Constructor Summary | |
---|---|
DbEntity()
Creates an unnamed DbEntity. |
|
DbEntity(java.lang.String name)
Creates a named DbEntity. |
Method Summary | ||
---|---|---|
|
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. |
|
java.util.Collection<DbAttribute> |
getAttributes()
Returns a Collection of all attributes that either belong to this DbEntity or inherited. |
|
java.lang.String |
getCatalog()
Returns the catalog name of the table described by this DbEntity. |
|
java.lang.String |
getFullyQualifiedName()
Returns table name including schema, if present. |
|
java.util.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. |
|
java.util.Collection<DbAttribute> |
getPrimaryKeys()
Returns an unmodifiable collection of DbAttributes representing the primary key of the table described by this DbEntity. |
|
Expression |
getQualifier()
|
|
java.util.SortedMap<java.lang.String,DbRelationship> |
getRelationshipMap()
Returns an unmodifiable map of relationships sorted by name. |
|
java.util.Collection<DbRelationship> |
getRelationships()
Returns a Collection of relationships from this entity or inherited. |
|
java.lang.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,
java.util.Map aliasMap)
Convenience method returning the last component in the path iterator. |
|
void |
removeAttribute(java.lang.String attrName)
Removes attribute from the entity, removes any relationship joins containing this attribute. |
|
java.lang.Iterable<PathComponent<DbAttribute,DbRelationship>> |
resolvePath(Expression pathExp,
java.util.Map aliasMap)
Returns an Iterable instance over expression path components based on this entity. |
|
java.util.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(java.lang.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(java.lang.String schema)
Sets the database schema name of the table described by this DbEntity. |
|
Expression |
translateToRelatedEntity(Expression expression,
java.lang.String relationshipPath)
Transforms Expression rooted in this entity to an analogous expression rooted in related entity. |
Methods inherited from class org.apache.cayenne.map.Entity |
---|
addAttribute, addRelationship, clearRelationships, getAnyRelationship, getAttribute, getAttributeMap, getDataMap, getName, getParent, getRelationship, removeRelationship, resolvePathComponents, setDataMap, setName, setParent, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected java.lang.String catalog
protected java.lang.String schema
protected java.util.Collection<DbAttribute> primaryKey
protected java.util.Collection<DbAttribute> generatedAttributes
protected DbKeyGenerator primaryKeyGenerator
protected Expression qualifier
Constructor Detail |
---|
public DbEntity()
public DbEntity(java.lang.String name)
Method Detail |
---|
public <T> T acceptVisitor(ConfigurationNodeVisitor<T> visitor)
acceptVisitor
in interface ConfigurationNode
public void encodeAsXML(XMLEncoder encoder)
encodeAsXML
in interface XMLSerializable
public java.lang.String getFullyQualifiedName()
public java.lang.String getSchema()
public void setSchema(java.lang.String schema)
public java.lang.String getCatalog()
public void setCatalog(java.lang.String catalog)
public java.util.Collection<DbAttribute> getPrimaryKeys()
public java.util.Collection<DbAttribute> getAttributes()
getAttributes
in class Entity
public java.util.Collection<DbAttribute> getGeneratedAttributes()
public void addAttribute(DbAttribute attr)
java.lang.IllegalArgumentException
- if Attribute has no name or there is an existing
attribute with the same name
java.lang.IllegalArgumentException
- if a relationship has the same name as this
attributepublic void removeAttribute(java.lang.String attrName)
removeAttribute
in class Entity
Entity.removeAttribute(String)
public void clearAttributes()
clearAttributes
in class Entity
public java.util.Collection<DbRelationship> getRelationships()
getRelationships
in class Entity
public java.util.SortedMap<java.lang.String,DbRelationship> getRelationshipMap()
Entity
getRelationshipMap
in class Entity
public PathComponent<DbAttribute,DbRelationship> lastPathComponent(Expression path, java.util.Map aliasMap)
Entity
lastPathComponent
in class Entity
public java.lang.Iterable<PathComponent<DbAttribute,DbRelationship>> resolvePath(Expression pathExp, java.util.Map aliasMap)
resolvePath
in class Entity
public java.util.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, java.lang.String relationshipPath)
translateToRelatedEntity
in class Entity
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |