Joins, reporting queries, and (My web server) subselects ANY The expression

Joins, reporting queries, and subselects ANY The expression evaluates to true if the comparison is true for some (any) value in the result of the subquery. If the subquery result is empty or no value satisfies the comparison, it evaluates to false. The keyword SOME is a synonym for ANY. IN This binary comparison operator can compare a list of values against the result of a subquery and evaluates to true if all values are found in the result. For example, this query returns items where all bids are less than 100: from Item i where 100 > all ( select b.amount from i.bids b ) The next query returns all the others, items with bids greater than 100: from Item i where 100 <= any ( select b.amount from i.bids b ) This query returns items with a bid of exactly 100: from Item i where 100 = some ( select b.amount from i.bids b ) So does this one: from Item i where 100 in ( select b.amount from i.bids b ) HQL supports a shortcut syntax for subqueries that operate on elements or indices of a collection. The following query uses the special HQL elements() function: List result = session.createQuery("from Category c" + " where :givenItem in elements(c.items)") .setEntity("givenItem", item) .list() The query returns all categories to which the item belongs and is equivalent to the following HQL (and valid JPA QL), where the subquery is more explicit: List result = session.createQuery( "from Category c where :givenItem in (select i from c.items i)" ) .setEntity("item", item) .list(); Along with elements(), HQL provides indices(), maxelement(), minelement(), maxindex(), minindex(), and size(), each of which is equivalent to a certain correlated subquery against the passed collection. Refer to the Hibernate documentation for more information about these special functions; they re rarely used.
Looking for affordable and reliable webhost to host and run your business application? Then look no more and go to servlet web hosting services.

Leave a Reply