Implement Envers querying on top of SQL2011 versioned tables #7072
Replies: 2 comments 1 reply
-
Is that the right way to do it, or should it be more of a session-level setting like with filters? |
Beta Was this translation helpful? Give feedback.
-
Coming from https://discourse.hibernate.org/t/predeleteeventlistener-veto-deletion-of-entity-with-relation/11649/9 I'd like to give you my perspective on the envers vs system-versioned tables discussion, because we were at the point of choosing between sql:2011-style versioning and envers a couple of years back. First, because we struggled a lot to find the authorative pieces of documentation for Oracle, some Oracle-specific information dump:
I think MySQL/MariaDB and MSSQL support it fully out-of-the-box, and postgres supports it with an extension, though I have no experience with any of those. Now, back to topic.
Our (partially self-imposed) restrictions were:
We didn't go with Oracle, partially because of (4), in retrospect a bit because of (3), but also for bad reasons: Failing to investigate into the state of oracle's support, reading some documentation for Oracle 10 and concluding their flashback feature was not fit for long-term versioning (7). We didn't go with envers because we feared we had to make large compromises on (4), (5) and (6). If hibernate added JDBC-support for system-versioned tables, that would imo be a huge functionality win and might allow us to ditch our custom stuff entirely. I believe all we'd need are the features mentioned in this thread already:
Though by my judgmenet the latter is of lesser importance because the entire functionality can technically be built using the first feature only, with the session-level stuff just being QoL. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The idea to support SQL2011 versioned tables, which came up on the JPA spec project in the past and the idea is interesting, because it could be a nice abstraction for Hibernate Envers to use.
I didn't give this too much thought yet, but I imagine the following:
('as' 'of' ('system time'|timestampExpression)|'versions' betweenPredicate)
The added benefit of Envers would be the possibility to fine tune columns/properties that should be audited as system versioning is an all or nothing thing. The
AuditQuery
API should be buildable on top of the new HQL syntax and there should be an SPI that Envers can plug into, to translate queries to the proper SQL.Beta Was this translation helpful? Give feedback.
All reactions