Rephrase of original question:
I have your typical M:M relationship, in my case think of the User
/Role
example:
USER, ROLE, USER_ROLE
I need a second USER_ROLE table matching up User
s to Role
s. I won't get into specifics as to why that is (unless you need me to), but I am looking for a way to accomplish this with JPA AND without changing up the User
and Role
Entities.
*I need a second USER_ROLE table to audit actions the User
performs and which Role
he was at the time the action was performed.*
You may want to use a internal callback method that will create an entry in the audit log whenever the lifecycle of the entity changes (according to your needs).
The callback annotations are self-explanatory more or less:
I quote from the documentation of the annotations: