-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Remove where clause for one query
PostPosted: Tue Apr 14, 2015 11:32 am 
Newbie

Joined: Tue Apr 14, 2015 11:01 am
Posts: 1
Hi,

I have a where clause in my Entity for applying some kind of filtering for all queries of this repository. This filtering I use for not retrieving any items, that have been marked as deleted (I am using soft delete so I just distinguish deleted entries with a flag). Up to now this worked very well but however I need to retrieve now a complete list of items (including the ones marked as deleted).

The Code looks like this:

Code:
@Entity
@Table(name = "table", schema = "schema")
@Where(clause = "deleted = 'false'")
public class MyClass implements Serializable{
}


Code:
@Repository
MyClassRepository extends JpaRepository<T, I>, JpaSpecificationExecutor<T> {

  @Query("SELECT m FROM MyClass m INNER JOIN m.otherClass o WHERE o.id = ?1")
  List<MyClass> findByOtherClass(Long id);
}


The generated query looks like this:

Code:
    select
       (...)
    from
        MyClass
    inner join
        (...)
    where
        (
            MyClass.deleted = 'false'
        )
        and MyClass.id = 1(...)


but what I actually want is a query like this:

Code:
    select
       (...)
    from
        MyClass
    inner join
        (...)
    where
        MyClass.id = 1


so that MyClass.deleted = 'false' is not used anymore to restrict the data retrieved (however only for this specific query - all other queries should stay unchanged).

How could this be done?

Thank you very much in advance


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.