We use Hibernate/JPA, Spring, Spring Data and Spring Security in our application. I have a standard User
entity which is mapped using JPA. Further, I have a U
It looks like you use a User entity for two different things:
I think it will be better to prepare a special AuditableUser for audit purpose (it will have identical username field as original User). Consider following case: you want to delete some User from database. If all your audit objects are linked to User then they will a) loose author b) may be deleted by cascade too (depends on how the link is implemented). Not sure that you want it. So by using special AuditableUser you will have: