[jboss-user] [JBoss Seam] - Re: EntityManger-per-user-session...
bkyrlach
do-not-reply at jboss.com
Wed Nov 8 15:25:55 EST 2006
See, this still leaves some key questions unanswered.
1) I've updated my ChildActions thusly...
| @In @Out
| Parent parent;
|
| @Begin
| public String preCreateChild()
| {
| parent = parentActions.getParent(parent.getId());
| return "/pc/createChild.xhtml";
| }
|
| @End
| public String createChild()
| {
| child.setParent(parent);
| parent.getChildren().add(child);
| return "/pc/viewer.xhtml";
| }
|
Which _mostly_ works the way I want. The one problem being that this method of adding the children to the parent doesn't take into account annotations on the children collection on parent which has (now) an @OrderBy("name"). By doing the following...
| em.persist(child);
| em.flush();
| em.refresh(user);
|
I can get around this, but that doesn't seem like it's the right way.
2) For my pre/edit action methods...
| @Begin
| public String preEditChild(Child child)
| {
| parent = parentActions.getParent(parent.getId());
| this.child = child;
| return "/pc/editChild.xhtml";
| }
|
| @End
| public String editChild()
| {
| return "/pc/viewer.xhtml";
| }
|
almost works, but again, I find that I have to change the line...
| this.child = child;
|
to this...
| this.child = em.merge(child);
|
Which also seems bad. I'm guessing I can add a helper method on ChildListBean similar to the method on UserActions that does a find on Activity, but again... all of this magically works when I use a session scoped EM because it doesn't forget these entities so quickly. I guess if it needs be done, then fine. It just seems a little ugly.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3984302#3984302
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3984302
More information about the jboss-user
mailing list