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

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

public class MapContainsKeyMethod
extends AbstractSQLMethod

Method for evaluating {mapExpr}.containsKey(keyExpr). Returns a BooleanExpression.


Field Summary
 
Fields inherited from class org.datanucleus.store.rdbms.sql.method.AbstractSQLMethod
clr, exprFactory, LOCALISER, stmt
 
Constructor Summary
MapContainsKeyMethod()
           
 
Method Summary
protected  SQLExpression containsAsInnerJoin(MapExpression mapExpr, SQLExpression keyExpr)
          Method to return an expression for Map.containsKey using INNER JOIN to the element.
protected  SQLExpression containsAsSubquery(MapExpression mapExpr, SQLExpression keyExpr)
          Method to return an expression for Map.containsKey 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

MapContainsKeyMethod

public MapContainsKeyMethod()
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(MapExpression mapExpr,
                                            SQLExpression keyExpr)
Method to return an expression for Map.containsKey using INNER JOIN to the element. This is only for use when there are no "!containsKey" and no "OR" operations. Creates SQL by adding INNER JOIN to the join table (where it exists), and also to the key table adding an AND condition on the element (with value of the keyExpr). Returns a BooleanExpression "TRUE" (since the INNER JOIN will guarantee if the key is contained of not).

Parameters:
mapExpr - Map expression
keyExpr - Expression for the key
Returns:
Contains expression

containsAsSubquery

protected SQLExpression containsAsSubquery(MapExpression mapExpr,
                                           SQLExpression keyExpr)
Method to return an expression for Map.containsKey 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:
mapExpr - Map expression
keyExpr - Expression for the key
Returns:
Contains expression


Copyright © 2009. All Rights Reserved.