Is there a replacement for the in 6.3 deprecated @Where and @Loader

3.4k Views Asked by At

Since hibernate 6.3 org.hibernate.annotations.Where and Loader are deprecated.

We are using these annotations together with @NamedQuery and @SQLDelete to implement soft deletion.

What is de non-deprecated way of implementing this?

1

There are 1 best solutions below

3
Andrei Lisa On BEST ANSWER

According to documentation you can replace @Where annotation to @SQLRestriction:

From:

 @Entity
 @Where(clause = "status <> 'DELETED'")
 class Document {
     ...
     @Enumerated(STRING)
     Status status;
     ...
 }

To:

 @Entity
 @SQLRestriction("status <> 'DELETED'")
 class Document {
     ...
     @Enumerated(STRING)
     Status status;
     ...
 }

Also according to documentation you also can replace @Loader to @SQLSelect or @HQLSelect

About @HQLSelect and @SQLSelect

These annotation is just an abbreviation for Loader together with NamedQuery.

More information about HOW TO DO IT I think you should check attached references to documentation about it.