Package org.apache.cayenne.exp
Class Property<E>
java.lang.Object
org.apache.cayenne.exp.Property<E>
- Type Parameters:
- E- The type this property returns.
public class Property<E> extends Object
 A property in a DataObject.
 
Used to construct Expressions quickly and with type-safety, and to construct Orderings.
Instances of this class are immutable.
 Must be created via factory methods Property.create(..)
 
- Since:
- 4.0
- See Also:
- create(String, Class),- create(Expression, Class),- create(String, Expression, Class)
- 
Field Summary
- 
Constructor Summary
- 
Method SummaryModifier and Type Method Description Property<E>abs()Property<E>alias(String alias)Creates alias with different name for this propertyOrderingasc()OrderingascInsensitive()OrderingsascInsensitives()Orderingsascs()Property<E>avg()Expressionbetween(E lower, E upper)Property<String>concat(Object... args)Arguments will be converted as follows: if argument is aPropertythan its expression will be used if argument is aExpressionthan it will be used as is all other values will be converted to StringExpressioncontains(String substring)Creates an expression for a database "LIKE" query with the value converted to a pattern matching anywhere in the String.ExpressioncontainsIgnoreCase(String value)Same ascontains(String), only using case-insensitive comparison.Property<Long>count()Property<Long>countDistinct()static <T> Property<T>create(String name, Class<? super T> type)Creates property with name and typestatic <T> Property<T>create(String name, Expression expression, Class<? super T> type)Creates property with name, expression and typestatic <T> Property<T>create(Expression expression, Class<? super T> type)Creates property with expression and typestatic <T extends Persistent>
 Property<T>createSelf(Class<? super T> type)Creates "self" Property for persistent class.Orderingdesc()OrderingdescInsensitive()OrderingsdescInsensitives()Orderingsdescs()PrefetchTreeNodedisjoint()Returns a prefetch tree that follows this property path, potentially spanning a number of phantom nodes, and having a single leaf with "disjoint" prefetch semantics.PrefetchTreeNodedisjointById()Returns a prefetch tree that follows this property path, potentially spanning a number of phantom nodes, and having a single leaf with "disjoint by id" prefetch semantics.Property<Object>dot(String property)Constructs a property path by appending the argument to the existing property separated by a dot.<T> Property<T>dot(Property<T> property)Constructs a new property path by appending the argument to the existing property separated by a dot.ExpressionendsWith(String value)Creates an expression for a database "LIKE" query with the value converted to a pattern matching the tail of a String.ExpressionendsWithIgnoreCase(String value)Same asendsWith(String), only using case-insensitive comparison.Expressioneq(E value)Expressioneq(Property<?> value)booleanequals(Object o)<T extends Persistent>
 Property<T>flat(Class<? super T> tClass)Create new "flat" property for toMany relationship.StringgetAlias()ExpressiongetExpression()This method returns fresh copy of the expression for each call.EgetFrom(Object bean)Extracts property value from an object using JavaBean-compatible introspection with one addition - a property can be a dot-separated property name path.List<E>getFromAll(Collection<?> beans)Extracts property value from a collection of objects using JavaBean-compatible introspection with one addition - a property can be a dot-separated property name path.StringgetName()Class<? super E>getType()Expressiongt(E value)Expressiongt(Property<?> value)Expressiongte(E value)Expressiongte(Property<?> value)inthashCode()Expressionin(E firstValue, E... moreValues)Expressionin(Collection<E> values)ExpressionisFalse()ExpressionisNotNull()ExpressionisNull()ExpressionisTrue()PrefetchTreeNodejoint()Returns a prefetch tree that follows this property path, potentially spanning a number of phantom nodes, and having a single leaf with "joint" prefetch semantics.Property<Integer>length()Expressionlike(String pattern)Expressionlike(String pattern, char escapeChar)ExpressionlikeIgnoreCase(String pattern)Property<Integer>locate(String string)Property<Integer>locate(Property<? extends String> property)Property<String>lower()Expressionlt(E value)Expressionlt(Property<?> value)Expressionlte(E value)Expressionlte(Property<?> value)Property<E>max()Property<E>min()Property<E>mod(Number number)Expressionne(E value)Expressionne(Property<?> value)Expressionnin(E firstValue, E... moreValues)Expressionnin(Collection<E> values)Expressionnlike(String value)ExpressionnlikeIgnoreCase(String value)Property<E>outer()Returns a version of this property that represents an OUTER join.Expressionpath()Converts this property to a path expression.voidsetIn(Object bean, E value)Sets a property value in 'obj' using JavaBean-compatible introspection with one addition - a property can be a dot-separated property name path.voidsetInAll(Collection<?> beans, E value)Sets a property value in a collection of objects using JavaBean-compatible introspection with one addition - a property can be a dot-separated property name path.Property<E>sqrt()ExpressionstartsWith(String value)Creates an expression for a database "LIKE" query with the value converted to a pattern matching the beginning of a String.ExpressionstartsWithIgnoreCase(String value)Same asstartsWith(String), only using case-insensitive comparison.Property<String>substring(int offset, int length)Property<E>sum()Property<String>trim()Property<String>upper()
- 
Field Details- 
COUNTProperty that can be used in COUNT(*) queries List<Object[]> result = ObjectSelect .columnQuery(Artist.class, Property.COUNT, Artist.ARTIST_NAME) .having(Property.COUNT.gt(1L)) .select(context);
 
- 
- 
Constructor Details- 
PropertyConstructs a new property with the given name and type.- Parameters:
- name- of the property (usually it's obj path)
- type- of the property
- See Also:
- create(String, Class)
 
- 
PropertyConstructs a new property with the given name and expression- Parameters:
- name- of the property (will be used as alias for the expression)
- expression- expression for property
- type- of the property
- See Also:
- create(String, Expression, Class)
 
 
- 
- 
Method Details- 
getName- Returns:
- Name of the property in the object.
 
- 
getAlias- Returns:
- alias for this property
 
- 
getExpressionThis method returns fresh copy of the expression for each call.- Returns:
- expression that represents this Property
 
- 
hashCodepublic int hashCode()
- 
equals
- 
dotConstructs a property path by appending the argument to the existing property separated by a dot.- Returns:
- a newly created Property object.
 
- 
dotConstructs a new property path by appending the argument to the existing property separated by a dot.- Returns:
- a newly created Property object.
 
- 
outerReturns a version of this property that represents an OUTER join. It is up to caller to ensure that the property corresponds to a relationship, as "outer" attributes make no sense.
- 
pathConverts this property to a path expression. This method is equivalent of getExpression() which is preferred as more generic.- Returns:
- a newly created expression.
- See Also:
- getExpression()
 
- 
isNull- Returns:
- An expression representing null.
 
- 
isNotNull- Returns:
- An expression representing a non-null value.
 
- 
isTrue- Returns:
- An expression representing equality to TRUE.
 
- 
isFalse- Returns:
- An expression representing equality to FALSE.
 
- 
eq- Returns:
- An expression representing equality to a value.
 
- 
eq- Returns:
- An expression representing equality between two attributes (columns).
 
- 
ne- Returns:
- An expression representing inequality to a value.
 
- 
ne- Returns:
- An expression representing inequality between two attributes (columns).
 
- 
like- Parameters:
- pattern- a pattern matching property value. Pattern may include "_" and "%" wildcard symbols to match any single character or a sequence of characters. To prevent "_" and "%" from being treated as wildcards, they need to be escaped and escape char passed with- like(String, char)method.
- Returns:
- An expression for a Database "LIKE" query.
 
- 
like- Parameters:
- pattern- a properly escaped pattern matching property value. Pattern may include "_" and "%" wildcard symbols to match any single character or a sequence of characters.
- escapeChar- an escape character used in the pattern to escape "%" and "_".
- Returns:
- An expression for a Database "LIKE" query.
 
- 
likeIgnoreCase- Returns:
- An expression for a case insensitive "LIKE" query.
 
- 
nlike- Returns:
- An expression for a Database "NOT LIKE" query.
 
- 
nlikeIgnoreCase- Returns:
- An expression for a case insensitive "NOT LIKE" query.
 
- 
containsCreates an expression for a database "LIKE" query with the value converted to a pattern matching anywhere in the String.- Parameters:
- substring- a String to match against property value. "_" and "%" symbols are NOT treated as wildcards and are escaped when converted to a LIKE expression.
- Returns:
- a newly created expression.
 
- 
startsWithCreates an expression for a database "LIKE" query with the value converted to a pattern matching the beginning of a String.- Parameters:
- value- a String to match against property value. "_" and "%" symbols are NOT treated as wildcards and are escaped when converted to a LIKE expression.
- Returns:
- a newly created expression.
 
- 
endsWithCreates an expression for a database "LIKE" query with the value converted to a pattern matching the tail of a String.- Parameters:
- value- a String to match against property value. "_" and "%" symbols are NOT treated as wildcards and are escaped when converted to a LIKE expression.
- Returns:
- a newly created expression.
 
- 
containsIgnoreCaseSame ascontains(String), only using case-insensitive comparison.
- 
startsWithIgnoreCaseSame asstartsWith(String), only using case-insensitive comparison.
- 
endsWithIgnoreCaseSame asendsWith(String), only using case-insensitive comparison.
- 
between- Parameters:
- lower- The lower bound.
- upper- The upper bound.
- Returns:
- An expression checking for objects between a lower and upper bound inclusive
 
- 
in- Returns:
- An expression for finding objects with values in the given set.
 
- 
nin- Returns:
- An expression for finding objects with values not in the given set.
 
- 
in- Returns:
- An expression for finding objects with values in the given set.
 
- 
nin- Returns:
- An expression for finding objects with values not in the given set.
 
- 
gt- Returns:
- A greater than Expression.
 
- 
gt- Returns:
- Represents a greater than relationship between two attributes (columns).
 
- 
gte- Returns:
- A greater than or equal to Expression.
 
- 
gte- Returns:
- Represents a greater than or equal relationship between two attributes (columns).
 
- 
lt- Returns:
- A less than Expression.
 
- 
lt- Returns:
- Represents a less than relationship between two attributes (columns).
 
- 
lte- Returns:
- A less than or equal to Expression.
 
- 
lte- Returns:
- Represents a less than or equal relationship between two attributes (columns).
 
- 
asc- Returns:
- Ascending sort orderings on this property.
 
- 
ascs- Returns:
- Ascending sort orderings on this property.
 
- 
ascInsensitive- Returns:
- Ascending case insensitive sort orderings on this property.
 
- 
ascInsensitives- Returns:
- Ascending case insensitive sort orderings on this property.
 
- 
desc- Returns:
- Descending sort orderings on this property.
 
- 
descs- Returns:
- Descending sort orderings on this property.
 
- 
descInsensitive- Returns:
- Descending case insensitive sort orderings on this property.
 
- 
descInsensitives- Returns:
- Descending case insensitive sort orderings on this property.
 
- 
jointReturns a prefetch tree that follows this property path, potentially spanning a number of phantom nodes, and having a single leaf with "joint" prefetch semantics.
- 
disjointReturns a prefetch tree that follows this property path, potentially spanning a number of phantom nodes, and having a single leaf with "disjoint" prefetch semantics.
- 
disjointByIdReturns a prefetch tree that follows this property path, potentially spanning a number of phantom nodes, and having a single leaf with "disjoint by id" prefetch semantics.
- 
getFromExtracts property value from an object using JavaBean-compatible introspection with one addition - a property can be a dot-separated property name path.
- 
getFromAllExtracts property value from a collection of objects using JavaBean-compatible introspection with one addition - a property can be a dot-separated property name path.
- 
setInSets a property value in 'obj' using JavaBean-compatible introspection with one addition - a property can be a dot-separated property name path.
- 
setInAllSets a property value in a collection of objects using JavaBean-compatible introspection with one addition - a property can be a dot-separated property name path.
- 
count
- 
countDistinct- Since:
- 4.1
- See Also:
- FunctionExpressionFactory.countDistinctExp(Expression)
 
- 
max
- 
min
- 
avg
- 
sum
- 
mod
- 
abs
- 
sqrt
- 
length
- 
locate
- 
locate
- 
trim
- 
upper
- 
lower
- 
concatArguments will be converted as follows: - if argument is a Propertythan its expression will be used
- if argument is a Expressionthan it will be used as is
- all other values will be converted to String
 Usage: Property<String> fullName = Artist.FIRST_NAME.concat(" ", Artist.SECOND_NAME);
- if argument is a 
- 
substring
- 
aliasCreates alias with different name for this property
- 
flatCreate new "flat" property for toMany relationship. Example: List<Object[]> result = ObjectSelect .columnQuery(Artist.class, Artist.ARTIST_NAME, Artist.PAINTING_ARRAY.flat(Painting.class)) .select(context);
- 
getType
- 
createCreates property with name and type
- 
createCreates property with expression and type
- 
createCreates property with name, expression and type- See Also:
- create(String, Class),- create(Expression, Class)
 
- 
createSelfCreates "self" Property for persistent class. This property can be used to select full object along with some of it properties (or properties that can be resolved against query root) Here is sample code, that will select all Artists and count of their Paintings: Property<Artist> artistFull = Property.createSelf(Artist.class); List<Object[]> result = ObjectSelect .columnQuery(Artist.class, artistFull, Artist.PAINTING_ARRAY.count()) .select(context);
 
-