Reputation: 2125
I want to add comment to my revision entity, but I don't know how to do this, because I don't know how to pass data to either RevisionListener
or EntityTrackingRevisionListener
.
My revision entity looks like this:
@Entity
@RevisionEntity
public class RevisionWithComment extends DefaultRevisionEntity {
private String comment;
/*Normal Hibernate stuff for defining 'comment' as column goes here.*/
}
I also have entity Foo
and query which mutates some foos. I would like to be able to add arbitrary comments to the new revisions :
public class FooService {
public void updateFoo( DataForUpdate dataForUpdate, String reasonForChange) {
//First select and update some foos
//Now add comment to the new revisions - but how do I do that?
}
}
How do I do that?
Upvotes: 1
Views: 522
Reputation: 1
You can achieve this with an AOP Introduction. This way you can add a comment field via an Introduction. You can read more about AOP in the official Spring documentation: http://docs.spring.io/spring/docs/current/spring-framework-reference/html/aop.html
Upvotes: 0
Reputation: 558
I would use a ThreadLocal variable to hold the comment. the updateFoo method will set it and the RevisionWithComment class will get the value and copy it's current value to the entity.
Upvotes: 2