Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

some doubts

 
Pradeep Dhavakumar
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some basic doubts.Kindly help.

* Could u call any bean from any other bean ?Like EB from MDB ?

* I know Session context and Entity Context extends EJB Context. But
Where does security context ,transaction context ,Initial Context and EJB context go in the tree of Contexts ? What extends what ?

* Can someone give a practical example where setRollbackOnly() is used ? I dont understand why we would go forward in a transaction if we are sure that we would "NEVER" commit..

Thanks,
Pradeep.D

[ July 13, 2004: Message edited by: Pradeep Dhavakumar ]
[ July 13, 2004: Message edited by: Pradeep Dhavakumar ]
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
  • You can access a bean from just about anything, even non-Java clients and non-object-oriented-clients (as long as they are IIOP or JRMP compatible).
  • Just because they all use the word "context" doesn't mean there is an inheritance relationship.
  • The container handles transactions for you. Consider if you were involved in a distributed transaction spanning 5 continents and 100 different database servers. Do you want to deal with that? No? Okay -- just setRollbackOnly.
  •  
    Keerthi P
    Ranch Hand
    Posts: 203
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Originally posted by Pradeep Dhavakumar:
    Some basic doubts.Kindly help.

    * Could u call any bean from any other bean ?Like EB from MDB ?

    * I know Session context and Entity Context extends EJB Context. But
    Where does security context ,transaction context ,Initial Context and EJB context go in the tree of Contexts ? What extends what ?

    * Can someone give a practical example where setRollbackOnly() is used ? I dont understand why we would go forward in a transaction if we are sure that we would "NEVER" commit..

    Thanks,
    Pradeep.D

    [ July 13, 2004: Message edited by: Pradeep Dhavakumar ]

    [ July 13, 2004: Message edited by: Pradeep Dhavakumar ]



    This is an overly simplyfied example where we 'commit' a database update if we were able to send acknowledgement successfully to admin. We are letting the container to rollback the current transaction if we could not send acknowledgement to the admin. This is one hypothetical scenario leveraging container managed transaction. Note that for this method to run predictably, it must be invoked in the context of a valid transaction.
    [ July 13, 2004: Message edited by: Keerthi P ]
     
    Pradeep Dhavakumar
    Greenhorn
    Posts: 19
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Nathaniel and Keerti - thanks for ur reply.But I still dont understand the use of setRollbackOnly for BMT.

    LETS say transaction propagates in this order BeanA >> BeanB >>BeanC .All BMT beans.

    Lets say we do a ut.setRollbackOnly() in bean A .My question is shoudnt we just do a ut.rollback() and "come out" of Bean A ? Instead of ut.setRollbackOnly() and propagate to BeanB and BeanC when U can NEVER commit i.e nothing can be changed .

    I think for CMT beans there is NO rollback()(Why ??) so U got to use setRollbackOnly().But for BMT there IS rollback() so we can "come out" anytime if there is an error .Why should we use ut.setRollbackOnly() and propagate forward then??(Unless u got to free up resources or null objects/variables which I think can be done in the same bean).

    Thanks,
    Pradeep.D
     
    Vijaya laxmi
    Ranch Hand
    Posts: 60
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    According to the page 477(HFEJB Book),getRollbackOnly(),setRollbackOnly() are mentioned only for CMT beans.

    I thought that these methods will not be used for BMT beans.

    Please tell me that I am correct or not.
     
    Vijaya laxmi
    Ranch Hand
    Posts: 60
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    sorry I am very confused.I got the answer.
     
    Lionel Orellana
    Ranch Hand
    Posts: 87
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    LETS say transaction propagates in this order BeanA >> BeanB >>BeanC .All BMT beans


    Transactions don't propagate into BMT beans.

    I think for CMT beans there is NO rollback()(Why ??)


    If you use CMT is because you want the container to take care of the transactions. The container will commit or rollback the transaction for you.


    But I still dont understand the use of setRollbackOnly for BMT.


    Pradeep do you have HFEJB? If you do look at page 486. It goes something like this (ut is an UserTransaction):



    According to the page 477(HFEJB Book),getRollbackOnly(),setRollbackOnly() are mentioned only for CMT beans.

    I thought that these methods will not be used for BMT beans.


    Vijaya, transaction-related methods in EJBContext are indeed for CMT beans. For BMT you can use the methods in UserTransaction. But you already found that out ...

    Cheers
     
    Pradeep Dhavakumar
    Greenhorn
    Posts: 19
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    thanks for that .Shouldnt have used BMT for the question .My question was why not END the transcation "immediately" if I DONT have any work in the next bean.And the answer is becos there are NO methods in CMT to end "immediately" .So the tranaaction will porpagate whether it is usefull or not but never commit..Anyway pretty clear now..

    Thanks,
    Pradeep.D
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic