I am adding Hibernate Envers to my Grails 3 project. I noticed that for one of my entities, which has an onLoad()
event, the onLoad()
event is never invoked for Envers revision entities.
How can I make sure this code is always invoked, even for historical revisions of this entity?
Use case:
I am working on a RESTful service using Grails 3 JSON views. One of my domain classes has a discriminator column, which must also be rendered in the JSON output so the consumer can tell what type it is. For this reason, the domain entity defines an onLoad()
method which populates a transient property matching the discriminator type:
class MyChildDomainClass extends MyBaseDomainClass {
void onLoad() {
valueType = ValueType.STRING
}
static mapping = {
discriminator value: ValueType.STRING
}
}
This works fine for normal domain instances, but when I look up an entity revision from Envers' AuditQueryCreator
, the audit query is not invoking the onLoad()
method.
It seems like I could loop over the results and manually invoke onLoad()
, but I was hoping there was a better way to fix this.
Thanks in advance!