You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Andriy Redko (JIRA)" <ji...@apache.org> on 2018/09/27 01:42:00 UTC
[jira] [Commented] (CXF-7848) JPATypedQueryVisitor does not support
isNull or isNotNull JPA operation
[ https://issues.apache.org/jira/browse/CXF-7848?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16629635#comment-16629635 ]
Andriy Redko commented on CXF-7848:
-----------------------------------
Indeed, null is not well supported sadly, we may look for adding a new operator as you have suggested. Thank you.
> 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
> Priority: Major
>
> Upon supplying null as argument to field in FIQL, CXF generated Query does not return any results.
> 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)