public class NullExpression
extends java.lang.Object
"a = ?"
and "a <> ?"
would never
be true but rather "UNKNOWN" when the value substituted for the parameter is null.
Comparisons with null are done properly with the IS NULL operator like
"a IS NULL" or "NOT a IS NULL".
NullExpression
instances can be used to
a = ?
when the value is not null and a Is Null
when the value is null)
Object[]
of the bind variables to achieve conditional binding.
NullExpression ne1 = NullExpression.wrap("a1",v1); NullExpression ne2 = NullExpression.wrap("a2",v2); ServiceLocator.getStore().list(classname, "a0 = ? and "+ne1+" and not "+ne2",new Object[]{v0,ne1,ne2});If
v1 != null
and v2 == null
, then the resulting where clause would be
,the parameters fora0 = ? and a1 = ? and NOT a2 Is NULL
a0
and a1
will be set, no parameter will be used for a2
.
Note that usage for parameters in value lists of inserts and "set column = value" assignments of update statements is not intended
(see Nil
for this).Modifier and Type | Method and Description |
---|---|
java.lang.Object |
getValue()
Return the wrapped value.
|
java.lang.String |
toString()
Constructs the appropriate expression depending on the value of getValue().
|
static NullExpression |
wrap(java.lang.String attributeName,
java.lang.Object value)
Wrap up an attribute name and a value for null expression construction.
|
public java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
public java.lang.Object getValue()
public static NullExpression wrap(java.lang.String attributeName, java.lang.Object value)
attributeName
- the name of the attributevalue
- the value to be wrapped (can be null)@enterprise 9.0.33982 Copyright © 2001-2023 Groiss Informatics GmbH. All Rights Reserved.