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