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

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?

Answers


No, there isn't anything like that in JPA.

But there's really nothing wrong in having a few provider specific annotations here and there that do the job.


Need Your Help

R colon operator on list of matrices

r list collections matrix indexing

I've created a list of matrices in R. In all matrices in the list, I'd like to "pull out" the collection of matrix elements of a particular index. I was thinking that the colon operator might allow...

How to set up Kannel without using a 3rd party gateway service

sms sms-gateway kannel smpp

I'd like to set up Kannel to send SMS messages without going through a 3rd party gateway like Clickatell or Twilio. In other words, I'd like to connect to the SMPP server for each wireless service...