org.datanucleus.store.rdbms.sql.method
Class CollectionContainsMethod

java.lang.Object
  extended by org.datanucleus.store.rdbms.sql.method.AbstractSQLMethod
      extended by org.datanucleus.store.rdbms.sql.method.CollectionContainsMethod
All Implemented Interfaces:
SQLMethod

public class CollectionContainsMethod
extends AbstractSQLMethod

Method for evaluating {collExpr1}.contains(). Returns a BooleanExpression.


Field Summary
 
Fields inherited from class org.datanucleus.store.rdbms.sql.method.AbstractSQLMethod
clr, exprFactory, LOCALISER, stmt
 
Constructor Summary
CollectionContainsMethod()
           
 
Method Summary
protected  SQLExpression containsAsInnerJoin(CollectionExpression collExpr, SQLExpression elemExpr)
          Method to return an expression for Collection.contains using INNER JOIN to the element.
protected  SQLExpression containsAsSubquery(CollectionExpression collExpr, SQLExpression elemExpr)
          Method to return an expression for Collection.contains using a subquery "EXISTS".
 SQLExpression getExpression(SQLExpression expr, java.util.List args)
          Return the expression for this SQL function.
 
Methods inherited from class org.datanucleus.store.rdbms.sql.method.AbstractSQLMethod
getMappingForClass, setStatement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CollectionContainsMethod

public CollectionContainsMethod()
Method Detail

getExpression

public SQLExpression getExpression(SQLExpression expr,
                                   java.util.List args)
Description copied from interface: SQLMethod
Return the expression for this SQL function.

Parameters:
expr - The expression that it is invoked on
args - Arguments passed in
Returns:
The SQL expression using the SQL function

containsAsInnerJoin

protected SQLExpression containsAsInnerJoin(CollectionExpression collExpr,
                                            SQLExpression elemExpr)
Method to return an expression for Collection.contains using INNER JOIN to the element. This is only for use when there are no "!contains" and no "OR" operations. Creates SQL by adding INNER JOIN to the join table (where it exists), and also to the element table adding an AND condition on the element (with value of the elemExpr). Returns a BooleanExpression "TRUE" (since the INNER JOIN will guarantee if the element is contained of not).

Parameters:
collExpr - Collection expression
elemExpr - Expression for the element
Returns:
Contains expression

containsAsSubquery

protected SQLExpression containsAsSubquery(CollectionExpression collExpr,
                                           SQLExpression elemExpr)
Method to return an expression for Collection.contains using a subquery "EXISTS". This is for use when there are "!contains" or "OR" operations in the filter. Creates the following SQL, and returns a BooleanSubqueryExpression ("EXISTS (subquery)")

Parameters:
collExpr - Collection expression
elemExpr - Expression for the element
Returns:
Contains expression


Copyright © 2009. All Rights Reserved.