users@glassfish.java.net

JTA transactions inside Session beans and JSF

From: Q Beukes <java.net_at_add.za.net>
Date: Sat, 2 Aug 2008 17:19:41 +0200

Hey,

I'm using Glassfish 2, with Toplink JTA and JTA. No extra libraries,
just a pure Netbeans 6.1 and Glassfish installation, then start a
JavaEE app with a WAR/JSF and EJB jar.

Now, I have a bunch of entities inside the EJB, and then use Session
beans to work with them. Inside the session beans I have
@PersistenceContext EntityManager injections to work with the
entities.

Then I have a RequestScopeBean called BusinessBean inside my JSF.

I use this to again work with the Session beans. Methods like for
example "Create Person" which would call the person facade(session
bean) to create the person entities and persist them, and there after
the businessBean will again call a separate session bean called
"create address" for each of the person's addresses.

Here is a depiction:
BusinessBean in War (public class BusinessBean extends AbstractRequestBean)
PersonBean is a session bean
AddressBean is a session bean
Person is an entity
Address is an entity

Now.
Inside BusinessBean I do:
Person p = new Person()
personBean.create(p);

Address a1 = new Address();
addressBean.create(a1);
Address a2 = new Address();
addressBean.create(a2);

Will all this be wrapped in a single transaction? Or do I need to
create a 3rd session bean and wrap the person/addresses creation
inside of?

This app will ONLY be hosted on glassfish.

-- 
Quintin Beukes