Hi.

I've read (namely in the O'Reilly /Enterprise Java Beans/ book, 3rd
ed.), that:

       ...it is strongly recommended that you do not attempt to manage
       transactions explicitly. Through transaction attributes,
       Enterprise JavaBeans provides a comprehensive and simple
       mechanism for delimiting transactions at the method level and
       propagating transactions automatically. Only developers with a
       thorough understanding of transactional systems should attempt
       to use JTA with EJB. (Chap 14.5)

Consequently, I'm curious if it is possible to write the following
code without using a UserTransaction (e.g., using only transaction
attributes). 

I have an entity bean, Foo. I would like to write an interface method
of Foo, update(). update() that adjusts some of Foo's fields, then
calls an internal validation method, validate(), that checks the
validity of those new field values. validate() returns null on
success, and a string explaining any failures if it fails.

If validate() succeeds, I'd like to commit the changes to Foo. If
validate() fails, I'd like to roll back the changes, and return the
error message to the caller.

In pseudo-Java, 

public String update(int val1, String val2, float val3) {
       setVal1(val1);
       setVal2(val2);
       setVal3(val3);
       
       String result = validate();
       
       if (result != null) {
          rollback();
       }         
       else {
          commit();
       }      
       return result;

}

I'm curious: is this possible to do using only method-level transaction
attributes? Or do I need a UserTransaction?

Any advice would be much appreciated.

Thanks in advance,

--Joe

-- 
Joseph Barillari -- http://barillari.org


-------------------------------------------------------
This SF.Net email sponsored by: Parasoft
Error proof Web apps, automate testing & more.
Download & eval WebKing and get a free book.
www.parasoft.com/bulletproofapps1
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to