Class MapContainsEntryMethod
java.lang.Object
org.datanucleus.store.rdbms.sql.method.MapContainsEntryMethod
- All Implemented Interfaces:
SQLMethod
Method for evaluating {mapExpr}.containsEntry(keyExpr, valueExpr).
Returns a BooleanExpression.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected SQLExpression
containsAsInnerJoin
(SQLStatement stmt, MapExpression mapExpr, SQLExpression keyExpr, SQLExpression valExpr) Method to return an expression for Map.containsEntry using INNER JOIN to the element.protected SQLExpression
containsAsSubquery
(SQLStatement stmt, MapExpression mapExpr, SQLExpression keyExpr, SQLExpression valExpr) Method to return an expression for Map.containsEntry using a subquery "EXISTS".getExpression
(SQLStatement stmt, SQLExpression expr, List<SQLExpression> args) Return the expression for this SQL function.protected boolean
getNeedsSubquery
(SQLStatement stmt) Convenience method to decide if we handle the contains() by using a subquery, or otherwise via an inner join.
-
Constructor Details
-
MapContainsEntryMethod
public MapContainsEntryMethod()
-
-
Method Details
-
getExpression
Description copied from interface:SQLMethod
Return the expression for this SQL function.- Specified by:
getExpression
in interfaceSQLMethod
- Parameters:
stmt
- SQLStatement that this expression is forexpr
- The expression that it is invoked onargs
- Arguments passed in- Returns:
- The SQL expression using the SQL function
-
getNeedsSubquery
Convenience method to decide if we handle the contains() by using a subquery, or otherwise via an inner join. If there is an OR or a NOT in the query then uses a subquery.- Parameters:
stmt
- SQLStatement- Returns:
- Whether to use a subquery
-
containsAsInnerJoin
protected SQLExpression containsAsInnerJoin(SQLStatement stmt, MapExpression mapExpr, SQLExpression keyExpr, SQLExpression valExpr) Method to return an expression for Map.containsEntry using INNER JOIN to the element. This is only for use when there are no "!containsEntry" and no "OR" operations. Creates SQL by adding INNER JOIN to the join table (where it exists), and also to the value table adding an AND condition on the value (with value of the valueExpr). Returns a BooleanExpression "TRUE" (since the INNER JOIN will guarantee if the entry is contained of not).- Parameters:
stmt
- SQLStatementmapExpr
- Map expressionkeyExpr
- Expression for the keyvalExpr
- Expression for the value- Returns:
- Contains expression
-
containsAsSubquery
protected SQLExpression containsAsSubquery(SQLStatement stmt, MapExpression mapExpr, SQLExpression keyExpr, SQLExpression valExpr) Method to return an expression for Map.containsEntry using a subquery "EXISTS". This is for use when there are "!contains" or "OR" operations in the filter. Creates the following SQL,- Map using join table
SELECT 1 FROM JOIN_TBL A0_SUB WHERE A0_SUB.JOIN_OWN_ID = A0.ID AND A0_SUB.JOIN_VAL_ID = {valExpr} AND Ao_SUB.JOIN_KEY_ID = {keyExpr}
- Map with key stored in value
SELECT 1 FROM VAL_TABLE A0_SUB WHERE B0.JOIN_OWN_ID = A0.ID AND A0_SUB.ID = {valExpr} AND A0_SUB.KEY_ID = {keyExpr}
- Map of value stored in key
SELECT 1 FROM KEY_TABLE A0_SUB WHERE A0_SUB.OWN_ID = A0.ID AND A0_SUB.VAL_ID = {valExpr} AND A0_SUB.ID = {keyExpr}
- Parameters:
stmt
- SQLStatementmapExpr
- Map expressionkeyExpr
- Expression for the keyvalExpr
- Expression for the value- Returns:
- Contains expression
- Map using join table
-