Package org.hibernate.annotations
Annotation Interface SQLRestriction
Specifies a restriction written in native SQL to add to the generated
SQL for entities or collections.
For example, @SQLRestriction
could be used to hide entity
instances which have been soft-deleted, either for the entity class
itself:
@Entity @SQLRestriction("status <> 'DELETED'") class Document { ... @Enumerated(STRING) Status status; ... }
or, at the level of an association to the entity:
@OneToMany(mappedBy = "owner") @SQLRestriction("status <> 'DELETED'") List<Document> documents;
The SQLJoinTableRestriction
annotation lets a restriction be
applied to an association table:
@ManyToMany @JoinTable(name = "collaborations") @SQLRestriction("status <> 'DELETED'") @SQLJoinTableRestriction("status = 'ACTIVE'") List<Document> documents;
Note that @SQLRestriction
s are always applied and cannot be
disabled. Nor may they be parameterized. They're therefore much
less flexible than filters.
- Since:
- 6.3
- See Also:
-
Required Element Summary
Required Elements
-
Element Details
-
value
String valueA predicate, written in native SQL.
-