Support for @OrderBy, @Sort, @SortComparator, and @SortNatural are being tracked as a part of
HHH-3562 Open . Support for @WhereJoinTable is being tracked as part of
HHH-9432 Open . One of the problems I see with @Where is that its meant to supply a SQL fragment. This is an issue simply because relations are queried at runtime using HQL, so we cannot simply cache the value and append it to the HQL query, it just wouldn't work. Also, Envers does not model relationships between entities such as a @OneToMany and a @ManyToOne using the traditional XML mapping means because entities can be audited independently of one another, so instead relations are queried at run-time using the foreign-key values directly. Suffice to say, if you had something like
@OneToMany(mappedBy="order")
@Where(clause="deleted = 'N'")
private List<OrderItem> items;
We wouldn't be able to model that in traditional Hibernate XML mappings like the following because of how we generate relation queries:
<bag name="items" where="deleted = 'N'">
<key name="order_id" not-null="true" />
<one-to-many class="OrderItem"/>
</bag>
I suspect the only real solution here might be to introduce an Envers-specific @AuditWhere annotation that is meant to take an HQL/JPQL fragment rather than SQL fragment, which we could then easily apply to the relation query generated at runtime with HQL/JPQL. Thoughts? |