|
||||||||||
| 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 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
|
| 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(String name)
Creates a named DbEntity. |
|
| Method Summary | |
|---|---|
void |
addAttribute(Attribute attr)
Deprecated. in favour of addAttribute(DbAttribute attr). Scheduled for
removal in Cayenne 4. |
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. |
List<DbAttribute> |
getPrimaryKey()
Deprecated. since 3.0 use getPrimaryKeys() that returns a collection. |
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. |
| Methods inherited from class org.apache.cayenne.map.Entity |
|---|
addRelationship, clearRelationships, getAnyRelationship, getAttribute, getAttributeMap, getDataMap, getName, getParent, getRelationship, lastPathComponent, 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 String catalog
protected String schema
protected Collection<DbAttribute> primaryKey
protected Collection<DbAttribute> generatedAttributes
protected DbKeyGenerator primaryKeyGenerator
protected Expression qualifier
| Constructor Detail |
|---|
public DbEntity()
public DbEntity(String name)
| Method Detail |
|---|
public void encodeAsXML(XMLEncoder encoder)
encodeAsXML in interface XMLSerializablepublic String getFullyQualifiedName()
public String getSchema()
public void setSchema(String schema)
public String getCatalog()
public void setCatalog(String catalog)
public Collection<DbAttribute> getPrimaryKeys()
@Deprecated public List<DbAttribute> getPrimaryKey()
getPrimaryKeys() that returns a collection.
public Collection<DbAttribute> getAttributes()
getAttributes in class Entitypublic Collection<DbAttribute> getGeneratedAttributes()
public void addAttribute(DbAttribute attr)
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@Deprecated public void addAttribute(Attribute attr)
addAttribute(DbAttribute attr). Scheduled for
removal in Cayenne 4.
addAttribute in class Entitypublic void removeAttribute(String attrName)
removeAttribute in class EntityEntity.removeAttribute(String)public void clearAttributes()
clearAttributes in class Entitypublic Collection<DbRelationship> getRelationships()
getRelationships in class Entitypublic 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
EntitypathExp 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 EntityExpressionExceptionpublic void setPrimaryKeyGenerator(DbKeyGenerator primaryKeyGenerator)
public DbKeyGenerator getPrimaryKeyGenerator()
public void dbEntityChanged(EntityEvent e)
dbEntityChanged in interface DbEntityListenerpublic void dbEntityAdded(EntityEvent e)
dbEntityAdded in interface DbEntityListenerpublic void dbEntityRemoved(EntityEvent e)
dbEntityRemoved in interface DbEntityListenerpublic void dbAttributeAdded(AttributeEvent e)
DbAttributeListener
dbAttributeAdded in interface DbAttributeListenerpublic void dbAttributeChanged(AttributeEvent e)
DbAttributeListener
dbAttributeChanged in interface DbAttributeListenerpublic void dbAttributeRemoved(AttributeEvent e)
DbAttributeListener
dbAttributeRemoved in interface DbAttributeListenerpublic void dbRelationshipChanged(RelationshipEvent e)
dbRelationshipChanged in interface DbRelationshipListenerpublic void dbRelationshipAdded(RelationshipEvent e)
dbRelationshipAdded in interface DbRelationshipListenerpublic void dbRelationshipRemoved(RelationshipEvent e)
dbRelationshipRemoved in interface DbRelationshipListenerpublic Expression getQualifier()
public void setQualifier(Expression qualifier)
public boolean isFullReplacementIdAttached(ObjectId id)
public Expression translateToRelatedEntity(Expression expression,
String relationshipPath)
translateToRelatedEntity in class Entity
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||