public class ExpressionUtils extends Object
Constructor and Description |
---|
ExpressionUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
checkAndCorrectExpressionMappingsForBooleanComparison(SQLExpression expr1,
SQLExpression expr2)
Convenience method that compares the mappings used by the two expressions for compatibility for
use in a boolean comparison (eq, noteq, gt, gteq, lt, lteq) and, if necessary, updates the mapping
if one of them is a SQLLiteral and is deemed inconsistent with the other expression.
|
protected static void |
checkAndCorrectLiteralForConsistentMappingsForBooleanComparison(SQLLiteral lit,
SQLExpression expr) |
static BooleanExpression |
getAppIdEqualityExpression(Object id,
SQLExpression expr,
RDBMSStoreManager storeMgr,
org.datanucleus.ClassLoaderResolver clr,
org.datanucleus.metadata.AbstractClassMetaData acmd,
Integer index,
BooleanExpression bExpr)
Create an equality expression "(expr == id)" for an application identity using reflection
to retrieve values and generate the mappings.
|
static BooleanExpression |
getEqualityExpressionForObjectExpressions(ObjectExpression expr1,
ObjectExpression expr2,
boolean equals)
Method to generate an equality/inequality expression between two ObjectExpressions.
|
static SQLExpression |
getEscapedPatternExpression(SQLExpression patternExpr)
The pattern string for representing one character.
|
static SQLExpression |
getLiteralForOne(SQLStatement stmt)
Convenience accessor for a literal for the number 1.
|
static NumericExpression |
getNumericExpression(SQLExpression expr)
Method to return a numeric expression for the supplied SQL expression.
|
static StringExpression |
getStringExpression(SQLExpression expr)
Method to convert the provided expression into a String-based expression using the datastore.
|
static Object |
getValueForMemberOfObject(org.datanucleus.ExecutionContext ec,
org.datanucleus.metadata.AbstractMemberMetaData mmd,
Object object)
Get the value of a managed field/property in the provided object.
|
static int |
populatePrimaryKeyMappingsValuesForPCMapping(JavaTypeMapping[] pkMappings,
Object[] pkFieldValues,
int position,
PersistableMapping pcMapping,
org.datanucleus.metadata.AbstractClassMetaData cmd,
org.datanucleus.metadata.AbstractMemberMetaData mmd,
Object fieldValue,
RDBMSStoreManager storeMgr,
org.datanucleus.ClassLoaderResolver clr)
Convenience method to populate PK mappings/values allowing for recursion where a PK field is itself
a PCMapping, that itself has PK mappings, which in turn may include PCMappings.
|
public static NumericExpression getNumericExpression(SQLExpression expr)
expr
- The expressionpublic static SQLExpression getLiteralForOne(SQLStatement stmt)
stmt
- The SQL statementpublic static StringExpression getStringExpression(SQLExpression expr)
CAST({expr} AS VARCHAR(4000))TODO Move this to a method so we can have datastore differences. e.g MySQL wants to cast as CHAR
expr
- The expressionpublic static SQLExpression getEscapedPatternExpression(SQLExpression patternExpr)
patternExpr
- The expression that represents one character for a matcher/parser in the databasepublic static int populatePrimaryKeyMappingsValuesForPCMapping(JavaTypeMapping[] pkMappings, Object[] pkFieldValues, int position, PersistableMapping pcMapping, org.datanucleus.metadata.AbstractClassMetaData cmd, org.datanucleus.metadata.AbstractMemberMetaData mmd, Object fieldValue, RDBMSStoreManager storeMgr, org.datanucleus.ClassLoaderResolver clr)
pkMappings
- The array of pk mappings to be populatedpkFieldValues
- The array of pk field values to be populatedposition
- The current position needing populatingpcMapping
- The PC mapping we are processingcmd
- ClassMetaData for the owning class with this PCMapping fieldmmd
- Field metadata for the field that this PCMapping representsfieldValue
- The value for the PCMapping field in the owning objectstoreMgr
- Store Managerclr
- ClassLoader resolverpublic static Object getValueForMemberOfObject(org.datanucleus.ExecutionContext ec, org.datanucleus.metadata.AbstractMemberMetaData mmd, Object object)
ec
- execution contextmmd
- metadata for the field/propertyobject
- the pc objectpublic static BooleanExpression getAppIdEqualityExpression(Object id, SQLExpression expr, RDBMSStoreManager storeMgr, org.datanucleus.ClassLoaderResolver clr, org.datanucleus.metadata.AbstractClassMetaData acmd, Integer index, BooleanExpression bExpr)
id
- the identity to compare againstexpr
- the object expressionstoreMgr
- the StoreManagerclr
- the ClassLoaderResolveracmd
- MetaData for the class the object id representsindex
- the current index in the source expression (internal)bExpr
- the boolean equals expression (internal)public static BooleanExpression getEqualityExpressionForObjectExpressions(ObjectExpression expr1, ObjectExpression expr2, boolean equals)
expr1
- First expressionexpr2
- Second expressionequals
- Whether it is equality (otherwise inequality)public static void checkAndCorrectExpressionMappingsForBooleanComparison(SQLExpression expr1, SQLExpression expr2)
expr1
- First expressionexpr2
- Second expressionprotected static void checkAndCorrectLiteralForConsistentMappingsForBooleanComparison(SQLLiteral lit, SQLExpression expr)
Copyright © 2015. All rights reserved.