Class Property<E>

    • Field Detail

      • COUNT

        public static final Property<Long> COUNT

        Property 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 Detail

      • Property

        protected Property​(String name,
                           Class<? super E> type)
        Constructs 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)
      • Property

        protected Property​(String name,
                           Expression expression,
                           Class<? super E> type)
        Constructs 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 Detail

      • getName

        public String getName()
        Returns:
        Name of the property in the object.
      • getAlias

        public String getAlias()
        Returns:
        alias for this property
      • getExpression

        public Expression getExpression()
        This method returns fresh copy of the expression for each call.
        Returns:
        expression that represents this Property
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • dot

        public Property<Object> dot​(String property)
        Constructs a property path by appending the argument to the existing property separated by a dot.
        Returns:
        a newly created Property object.
      • dot

        public <T> Property<T> dot​(Property<T> property)
        Constructs a new property path by appending the argument to the existing property separated by a dot.
        Returns:
        a newly created Property object.
      • outer

        public Property<E> outer()
        Returns 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.
      • path

        public Expression path()
        Converts 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

        public Expression isNull()
        Returns:
        An expression representing null.
      • isNotNull

        public Expression isNotNull()
        Returns:
        An expression representing a non-null value.
      • isTrue

        public Expression isTrue()
        Returns:
        An expression representing equality to TRUE.
      • isFalse

        public Expression isFalse()
        Returns:
        An expression representing equality to FALSE.
      • eq

        public Expression eq​(E value)
        Returns:
        An expression representing equality to a value.
      • eq

        public Expression eq​(Property<?> value)
        Returns:
        An expression representing equality between two attributes (columns).
      • ne

        public Expression ne​(E value)
        Returns:
        An expression representing inequality to a value.
      • ne

        public Expression ne​(Property<?> value)
        Returns:
        An expression representing inequality between two attributes (columns).
      • like

        public Expression like​(String pattern)
        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

        public Expression like​(String pattern,
                               char escapeChar)
        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

        public Expression likeIgnoreCase​(String pattern)
        Returns:
        An expression for a case insensitive "LIKE" query.
      • nlike

        public Expression nlike​(String value)
        Returns:
        An expression for a Database "NOT LIKE" query.
      • nlikeIgnoreCase

        public Expression nlikeIgnoreCase​(String value)
        Returns:
        An expression for a case insensitive "NOT LIKE" query.
      • contains

        public Expression contains​(String substring)
        Creates 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.
      • startsWith

        public Expression startsWith​(String value)
        Creates 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.
      • endsWith

        public Expression endsWith​(String value)
        Creates 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.
      • between

        public Expression between​(E lower,
                                  E upper)
        Parameters:
        lower - The lower bound.
        upper - The upper bound.
        Returns:
        An expression checking for objects between a lower and upper bound inclusive
      • in

        public Expression in​(E firstValue,
                             E... moreValues)
        Returns:
        An expression for finding objects with values in the given set.
      • nin

        public Expression nin​(E firstValue,
                              E... moreValues)
        Returns:
        An expression for finding objects with values not in the given set.
      • in

        public Expression in​(Collection<E> values)
        Returns:
        An expression for finding objects with values in the given set.
      • nin

        public Expression nin​(Collection<E> values)
        Returns:
        An expression for finding objects with values not in the given set.
      • gt

        public Expression gt​(E value)
        Returns:
        A greater than Expression.
      • gt

        public Expression gt​(Property<?> value)
        Returns:
        Represents a greater than relationship between two attributes (columns).
      • gte

        public Expression gte​(E value)
        Returns:
        A greater than or equal to Expression.
      • gte

        public Expression gte​(Property<?> value)
        Returns:
        Represents a greater than or equal relationship between two attributes (columns).
      • lt

        public Expression lt​(E value)
        Returns:
        A less than Expression.
      • lt

        public Expression lt​(Property<?> value)
        Returns:
        Represents a less than relationship between two attributes (columns).
      • lte

        public Expression lte​(E value)
        Returns:
        A less than or equal to Expression.
      • lte

        public Expression lte​(Property<?> value)
        Returns:
        Represents a less than or equal relationship between two attributes (columns).
      • asc

        public Ordering asc()
        Returns:
        Ascending sort orderings on this property.
      • ascs

        public Orderings ascs()
        Returns:
        Ascending sort orderings on this property.
      • ascInsensitive

        public Ordering ascInsensitive()
        Returns:
        Ascending case insensitive sort orderings on this property.
      • ascInsensitives

        public Orderings ascInsensitives()
        Returns:
        Ascending case insensitive sort orderings on this property.
      • desc

        public Ordering desc()
        Returns:
        Descending sort orderings on this property.
      • descs

        public Orderings descs()
        Returns:
        Descending sort orderings on this property.
      • descInsensitive

        public Ordering descInsensitive()
        Returns:
        Descending case insensitive sort orderings on this property.
      • descInsensitives

        public Orderings descInsensitives()
        Returns:
        Descending case insensitive sort orderings on this property.
      • joint

        public PrefetchTreeNode joint()
        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.
      • disjoint

        public PrefetchTreeNode disjoint()
        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.
      • disjointById

        public PrefetchTreeNode disjointById()
        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.
      • getFrom

        public E getFrom​(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.
      • getFromAll

        public 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.
      • setIn

        public void setIn​(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.
      • setInAll

        public void setInAll​(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.
      • alias

        public Property<E> alias​(String alias)
        Creates alias with different name for this property
      • flat

        public <T extends PersistentProperty<T> flat​(Class<? super T> tClass)

        Create 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

        public Class<? super E> getType()
      • createSelf

        public static <T extends PersistentProperty<T> createSelf​(Class<? super T> type)

        Creates "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);