Issue
For spring-data-jpa-datatables:4.3
, how to make DataTablesRepository
to return all entities, ignoring the Hibernate's @Where
annotation?
This is an entity with Hibernate's @Where
annotation:
@Entity
@SQLDelete(sql = "UPDATE vehicle SET deleted_at = NOW() WHERE id = ?")
@Where(clause = "deleted_at IS NULL")
public class Vehicle extends AbstractEntity implements Serializable {...}
And this is a corresponding repository extending spring-data-jpa-datatables's DataTablesRepository
:
@Repository
public interface VehicleDataTableRepository extends DataTablesRepository<Vehicle, Long> {
}
Solution
That's not possible. The @Where
predicate is always applied. You can map the same table again to a different entity class without the @Where
and query that instead if you want though or you create a filter (@Filter
) instead of using @Where
and just ensure the filter is always active except when you explicitly don't want the filter predicate to be applied. Also see: https://docs.jboss.org/hibernate/orm/5.5/userguide/html_single/Hibernate_User_Guide.html#pc-filter
Answered By - Christian Beikov