-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Add items to @ElementCollection without loading
PostPosted: Tue Dec 10, 2013 2:04 am 
Newbie

Joined: Mon Jun 20, 2005 12:20 pm
Posts: 17
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.