[jboss-user] [JBoss Seam] - Nested conversations and transaction management

FabBoco do-not-reply at jboss.com
Tue May 1 11:18:25 EDT 2007


Hi,

I have a couple of SFSB:


  | 
  | @Stateful
  | @Name("A")
  | @Scope(ScopeType.CONVERSATION)
  | @Transactional
  | public class ABean implements Serializable, A
  | {
  |    @PersistenceContext(type = PersistenceContextType.EXTENDED)
  |    private EntityManager				em;
  | 
  |    @End(beforeRedirect=true)
  |    @Rollback
  |    public String cancel()
  |    {
  |       return "/AList.xhtml";
  |    }
  | 
  |    
  |    @Begin(nested=true)
  |    public String initCreate()
  |    {
  |       ....
  | 
  |       return "/A.xhtml";
  |    }
  | 
  |    @End(beforeRedirect=true)
  |    public String initCreate()
  |    {
  |       ....
  | 
  |       return "/ListA.xhtml";
  |    }
  | }
  | 
  | @Stateful
  | @Name("B")
  | @Scope(ScopeType.CONVERSATION)
  | @Transactional
  | public class BBean implements Serializable, B
  | {
  |    @PersistenceContext(type = PersistenceContextType.EXTENDED)
  |    private EntityManager				em;
  | 
  |    @End(beforeRedirect=true)
  |    @Rollback
  |    public String cancel()
  |    {
  |       return "/BList.xhtml";
  |    }
  | 
  |    
  |    @Begin(nested=true)
  |    public String initCreate()
  |    {
  |       ....
  | 
  |       return "/B.xhtml";
  |    }
  | 
  |    @End(beforeRedirect=true)
  |    public String initCreate()
  |    {
  |       ....
  | 
  |       return "/ListB.xhtml";
  |    }
  | }
  | 
  | 

I do the following actions:

1) I call a.initCreate();  (a is an instance of A, a long running conversation is still active before this call, say #1)
1.a) The page A.xhtml is shown
1.b) a new nested conversation is created, say #2

2) from inside the A page I call b.initCreate() (it is opened in a popup)
2.a) The page B.xhtml is shown
2.b) a new nested conversation is created, say #3

3) from inside the B page I call b.processCreate
3.a) conversation #3 is closed
3.b) a new B object is create and stored into the database

4) from inside the A page I call a.cancell
4.a) conversation #2 is rolled back
4.b) no new a object is create but the b object is present into the database

>From this behavior I presume that the parent conversation and the nested conversation have two different database transaction and  that the transaction related to the nested conversation is always committed on nested conversation closure even thought the parent conversation (and the related database transaction) could be rolled back.

Am I right ? 

Can I change this behavior in some way ?  

I wonder why the nested conversation doesn't nest the database transaction too.

Thank you to everybody for his help.

Regards 

Fab.

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

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



More information about the jboss-user mailing list