Hi All,
My User class has Set<Audit> for audit tracking. When it is updated, a new Audit object will be added to the collection.
@Entity public class User { ... @ElementCollection @CollectionTable(name = "user_audit", joinColumns = @JoinColumn(name = "user_id")) private Set<Audit> audits; ... }
@Embeddable public class Audit { ... }
When a web page posts a modified user object back to server, its audits value is null. What I want to do is to update the user object and add a new audit entry in database. It can be done easily with update and insert SQL queries. However, with Hibernate I have to retrieve the audits, add new entry to the set, set it as audits value in the user object, and update the User.
Is there a better/more efficient way to accomplish the job (without loading the audit set from database)?
Thank you in advance, -ZJ
|