You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltaspike.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/12/17 11:53:00 UTC

[jira] [Commented] (DELTASPIKE-1330) Criteria with OR generate AND on query

    [ https://issues.apache.org/jira/browse/DELTASPIKE-1330?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16722911#comment-16722911 ] 

ASF GitHub Bot commented on DELTASPIKE-1330:
--------------------------------------------

GitHub user arthurgregorio opened a pull request:

    https://github.com/apache/deltaspike/pull/82

    DELTASPIKE-1330 fix

    just updated line 47 to the correct method call

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/arthurgregorio/deltaspike master

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/deltaspike/pull/82.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #82
    
----
commit 8f306265774ced53bd890c7b920c9e0f825e527f
Author: Arthur Gregório <ar...@...>
Date:   2018-12-17T11:48:00Z

    fix for DELTASPIKE-1330

----


> Criteria with OR generate AND on query
> --------------------------------------
>
>                 Key: DELTASPIKE-1330
>                 URL: https://issues.apache.org/jira/browse/DELTASPIKE-1330
>             Project: DeltaSpike
>          Issue Type: Bug
>          Components: Data-Module
>    Affects Versions: 1.8.1
>         Environment: JDK 8u161, Wildfly 11, JEE 7
>            Reporter: Arthur Pereira Gregório
>            Priority: Critical
>
> If I use a OR on criteria the generated query use AND instead of OR to mix the properties after WHERE clause.
> Sample: 
> {code:java}
> // code placeholder
> default List<T> findAllBy(String filter, Boolean blocked, int start, int pageSize) {
> final Criteria<T, T> criteria = criteria();
> if (isNotBlank(filter)) {
> criteria.or(this.criteria()
> .likeIgnoreCase(User_.name, filter)
> .likeIgnoreCase(User_.username, filter)
> .likeIgnoreCase(User_.email, filter));
> } 
> if (blocked != null) {
> criteria.eq(this.getBlockedProperty(), blocked);
> }
> criteria.orderDesc(PersistentEntity_.createdOn);
> return criteria.createQuery()
> .setFirstResult(start)
> .setMaxResults(pageSize)
> .getResultList();
> }
> {code}
>  
> Generate this hibernate query: 
> 17:41:24,813 INFO  [stdout] (default task-64) Hibernate: select user0_.id as id1_4_, user0_.created_by as created_2_4_, user0_.created_on as created_3_4_, user0_.modified_by as modified4_4_, user0_.modified_on as modified5_4_, user0_.blocked as blocked6_4_, user0_.email as email7_4_, user0_.id_group as id_grou12_4_, user0_.name as name8_4_, user0_.password as password9_4_, user0_.store_type as store_t10_4_, user0_.username as usernam11_4_ from security.users user0_ *where (upper(user0_.name) like ?) and (upper(user0_.username) like ?) and (upper(user0_.email) like ?)* order by user0_.created_on desc limit ?



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)