tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ebaxt <eb...@broadpark.no>
Subject Transaction when testing CRUD on facade
Date Fri, 28 Mar 2008 15:24:55 GMT

Hi.

I'm new to openEJB and EJB3 so please forgive me if this is a stupid
question.

Say I want to write a unitTest to test some CRUD methods on a facade. I have
a Session Bean with a method:

public X createNewX(String name) {
... creates newX
xxEAO.create(newX);
return newX;
}

The xxEAO is another Session Bean (the EAO pattern as explained in "EJB3 in
Action").

@PersistenceContext
EntityManager em;
..
public void create(X newX) {
  em.persist(newX)
  em.flush();
}

So the Facade creates a new X and delegates the EnitityManager actions to
the xxEAO.

In my unitTest(using embedded openEJB) I call the createNewX on the facade.
Now, my question is, do the facade create a transaction, and is the xxEAO
create() method invoked within this transaction? Or do I have to start a
transaction in the unitTest? 

The reason I'm asking is that the test succeeds, but the data isn't
committed to the database.

Thanks

Erik



-- 
View this message in context: http://www.nabble.com/Transaction-when-testing-CRUD-on-facade-tp16351025p16351025.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Mime
View raw message