aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes some doubts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "some doubts" Watch "some doubts" New topic
Author

some doubts

Pradeep Dhavakumar
Greenhorn

Joined: Feb 05, 2004
Posts: 19
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 ]

SCJP1.4,SCWCD1.3,SCBCD1.3.
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
  • 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.


  • Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
    Keerthi P
    Ranch Hand

    Joined: Aug 19, 2003
    Posts: 203
    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 ]

    Cheers.<br />Keerthi<br />(SCJP, SCWCD, SCBCD)
    Pradeep Dhavakumar
    Greenhorn

    Joined: Feb 05, 2004
    Posts: 19
    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

    Joined: Jan 14, 2004
    Posts: 60
    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.


    SCJP1.4,SCBCD1.3,SCWCD1.4(Preparing)
    Vijaya laxmi
    Ranch Hand

    Joined: Jan 14, 2004
    Posts: 60
    sorry I am very confused.I got the answer.
    Lionel Orellana
    Ranch Hand

    Joined: Mar 19, 2004
    Posts: 87
    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

    Joined: Feb 05, 2004
    Posts: 19
    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
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: some doubts
     
    Similar Threads
    Is SCJD useful for me ?
    whereto use setRollbackOnly
    Transaction attributes question
    Is this a Nested Transaction?
    BMT Mock question