tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ebaxt <eb...@broadpark.no>
Subject Re: Transaction when testing CRUD on facade
Date Sat, 29 Mar 2008 11:08:58 GMT

Thank you David. I changed the transaction-type to TRANSACTION and it all
works fine.

-Erik


David Blevins wrote:
> 
> I'd recommend transaction-type="TRANSACTION" which will allow your  
> EntityManager to be enrolled in the container managed transactions  
> that are created automatically around calls to your session bean.
> 
> As a side note, if you run into any exceptions that complain of an  
> object being "detached", check out this doc for some techniques:
>    - http://openejb.apache.org/3.0/jpa-usage.html#JPAUsage-Bedetachaware
> 
> -David
> 
> 
> On Mar 28, 2008, at 8:24 AM, ebaxt wrote:
>>
>> 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.
>>
>>
> 
> 
> 

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


Mime
View raw message