[jboss-user] [JBoss Seam] - Re: EntityManger-per-user-session...

iradix do-not-reply at jboss.com
Tue Nov 7 16:00:28 EST 2006


With a proper cascade on the activities list stored within the user, you should be able to just bind the values that are editable via the value attribute of each JSF component.  After they are validated and the model is updated (i.e. new values are set on each appropriate activity) saving the user at the end of the transaction will update the DB representation of whatever activities have changed.  There should be no merging necessary  as long as your conversation is long running because they are the same objects from page to page.  What could be easier than that?

If what you're saying about the UserActions SLSB is that you have a User spanning more than one conversation, try this:


  | @In(create = true)
  | private EntityManager em;
  | 
  | private String userId;
  | 
  | public void setUser(User user){
  |   this.userId = user.getId();
  | }
  | 
  | public User getUser(){
  |   return em.find(User.class, userId);
  | }
  | 

Seam will make sure the appropriate conversation scoped em is injected into your SLSB on each call so you'll get the same User object every time, as long as you are within the same conversation.  No merging necessary.  You can even inject it into other beans using @In(value="#{userActions.user}")

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3983916#3983916

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3983916



More information about the jboss-user mailing list