|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.cayenne.map.Attribute
org.apache.cayenne.map.DbAttribute
org.apache.cayenne.map.DerivedDbAttribute
public class DerivedDbAttribute
A DerivedDbAttribute is a DbAttribute that resolves to an SQL expression based on a set
of other attributes. DerivedDbAttribute's allow to build expressions like "
count(id)
", "sum(price)
", etc.
Internally DerivedDbAttribute is defined as a specification string and a set of
substitution DbAttribute parameters. Specification string is an SQL expression that
contains placeholders (%@
) for attribute parameters, for example:
sum(%@) + sum(%@)
Field Summary | |
---|---|
static java.lang.String |
ATTRIBUTE_TOKEN
|
protected java.lang.String |
expressionSpec
|
protected boolean |
groupBy
|
protected java.util.List |
params
|
Fields inherited from class org.apache.cayenne.map.DbAttribute |
---|
generated, mandatory, maxLength, precision, primaryKey, type |
Fields inherited from class org.apache.cayenne.map.Attribute |
---|
entity, name |
Constructor Summary | |
---|---|
DerivedDbAttribute()
Constructor for DerivedDbAttribute. |
|
DerivedDbAttribute(DbEntity entity,
DbAttribute parentProto)
Creates and initializes a derived attribute with an attribute of a parent entity. |
|
DerivedDbAttribute(java.lang.String name)
Constructor for DerivedDbAttribute. |
|
DerivedDbAttribute(java.lang.String name,
int type,
DbEntity entity,
java.lang.String spec)
Constructor for DerivedDbAttribute. |
Method Summary | |
---|---|
void |
addParam(DbAttribute param)
Adds parameter. |
void |
clearParams()
|
void |
encodeAsXML(XMLEncoder encoder)
Prints itself as XML to the provided XMLEncoder. |
java.lang.String |
getAliasedName(java.lang.String alias)
|
java.lang.String |
getExpressionSpec()
Returns the expressionSpec. |
java.util.List |
getParams()
Returns the params. |
boolean |
isGroupBy()
Returns true if this attribute is used in GROUP BY clause of the parent entity. |
void |
removeParam(DbAttribute param)
|
void |
setExpressionSpec(java.lang.String expressionSpec)
Sets the expressionSpec. |
void |
setGroupBy(boolean flag)
|
Methods inherited from class org.apache.cayenne.map.DbAttribute |
---|
getMaxLength, getPrecision, getType, isForeignKey, isGenerated, isMandatory, isPrimaryKey, setGenerated, setMandatory, setMaxLength, setPrecision, setPrimaryKey, setType |
Methods inherited from class org.apache.cayenne.map.Attribute |
---|
getEntity, getName, getParent, setEntity, setName, setParent |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String ATTRIBUTE_TOKEN
protected java.lang.String expressionSpec
protected java.util.List params
protected boolean groupBy
Constructor Detail |
---|
public DerivedDbAttribute()
public DerivedDbAttribute(java.lang.String name)
public DerivedDbAttribute(java.lang.String name, int type, DbEntity entity, java.lang.String spec)
public DerivedDbAttribute(DbEntity entity, DbAttribute parentProto)
Method Detail |
---|
public void encodeAsXML(XMLEncoder encoder)
encodeAsXML
in interface XMLSerializable
encodeAsXML
in class DbAttribute
public java.lang.String getAliasedName(java.lang.String alias)
getAliasedName
in class DbAttribute
public boolean isGroupBy()
public void setGroupBy(boolean flag)
public java.util.List getParams()
public java.lang.String getExpressionSpec()
public void addParam(DbAttribute param)
public void removeParam(DbAttribute param)
public void clearParams()
public void setExpressionSpec(java.lang.String expressionSpec)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |