Mitesh Panchal created CXF-7848:
-----------------------------------
Summary: JPATypedQueryVisitor does not support isNull or isNotNull
JPA operation
Key: CXF-7848
URL: https://issues.apache.org/jira/browse/CXF-7848
Project: CXF
Issue Type: Bug
Components: JAX-RS
Affects Versions: 3.2.6
Reporter: Mitesh Panchal
Upon suppling null as argument to field in FIQL no results found.
e.g. _s=city==null or _s=city!=null does not return any results. while
leveraging JPATypedQueryVisitor which build criteria query.
found couple of instances where this issue is discussed or resolved.
e.g. [https://github.com/jirutka/rsql-parser/issues/21] : talks about add a new
operator as an option
or [https://github.com/jirutka/rsql-parser] solves the issue by looking at the
argument and creating a criteria builder query with help of
builder.isNull(exp); or builder.isNotNull(exp); statements.
Please let us know what can be done?
Workaround I have applies for temporary is as below
{code:java}
/** Enhanced AbstractSearchConditionVisitor.java method doBuildPredicate **//
private Predicate doBuildPredicate(ConditionType ct, Path<?> path, Class<?>
valueClazz, Object value) {
.
.
case EQUALS:
if (clazz.equals(String.class)) {
if(value.toString().equalsIgnoreCase("null")){
pred = builder.isNull(exp);
}else if(value.toString().equalsIgnoreCase("notNull")){
pred = builder.isNotNull(exp);
}else{
final String originalValue = value.toString();
String theValue = SearchUtils.toSqlWildcardString(originalValue,
isWildcardStringMatch());
if (SearchUtils.containsWildcard(originalValue)) {
if (SearchUtils.containsEscapedChar(theValue)) {
pred = builder.like((Expression<String>)exp, theValue,
'\\');
} else {
pred = builder.like((Expression<String>)exp,
theValue);
}
} else {
pred = builder.equal(exp, clazz.cast(value));
}
}
} else {
pred = builder.equal(exp, clazz.cast(value));
}
.
.
.
{code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)