JPA: is there any annotation with the same behaviour as Hibernate @Where?

Viewed 494

I'm working with JPA annotations, and I'd like to use an annotation that behaves the same as the Hibernate @Where.

I want to map an entity from a table, but I have to do add a where clause in every query that uses that table.

This is my case: my table has a column deleted, and when this column is 1, this row should not be appear.

If I'd use Hibernate hbm, this is resolved in this way:

<hibernate-mapping>
     <class 
        name="MyClass" 
        table="MyTable" 
        dynamic-insert="false" 
        dynamic-update="false"
        where="deleted = 0">
</hibernate-mapping>

But I don't know how to do this only with JPA.

The only idea that comes to me is to extend the JpaRepository of this entity, but my problem is that there is another entity that uses this one, so extending the JpaRepository of the first entity is useless.

Using the Where clause in the column should work, but I'm trying to find a way to do this without Hibernate.

Anyone have any idea?

1 Answers
Related