users@glassfish.java.net

Glassfish Oracle Mystery

From: Kenneth Clark <kenneth.clark_at_skyetech.co.za>
Date: Sat, 27 Oct 2007 21:03:58 +0200

Hi everyone

 

When using em.persist(object) everything works as expected

BUT

When I try em.merge(object)

 

The object is not commited and when I try wrap it in a transaction

 

Em.getTransaction().begin();

Em.merge(object);

Em.getTransaction().commit();

 

I get an error telling me that I can’t do this

“Cannot use an EntityTransaction while using JTA.”

 

This has worked for all the other databases I use (MySQL, Postgres, MS SQL)
and I have only seen this error on the oracle connection pool

 

Does anyone had any ideas or pointers to a resolution for this headache? I
have been fighting with this thing for about 5 hours now.

 

Thanks

 

------- CODE --------------------

@Stateless

@WebService(endpointInterface =
"com.ax.business.services.InvoiceManagement")

public class InvoiceManagementImpl implements InvoiceManagement {

  

  @PersistenceContext(unitName = "ax_ps01")

  private EntityManager em;

 

  public Object mergeEntity(Object entity) {

    entity = em.merge(entity); // Does not commit

    return entity;

  }

 

 //Throws exception:

//Caused by: java.lang.IllegalStateException:

//Exception Description: Cannot use an EntityTransaction while using JTA.

  public Object mergeEntity2(Object entity) {

    em.getTransaction().begin();

    entity = em.merge(entity);

    em.getTransaction().commit();

    return entity;

  }

 

  public Object persistEntity(Object entity) {

    em.persist(entity);

    return entity;

  }

}

--------------- END CODE -------------------------

 

 

________________

Thanks and regards

 

Kenneth Clark

Solutions Engineer

 

ShadowLogo.png

Tel: 27 11 679 3075

Mobile: 27 (0) 84 583 1348

Email: HYPERLINK
"mailto:kenneth.clark_at_skyetech.co.za"kenneth.clark_at_skyetech.co.za

Website: http://www.skyetech.co.za

 


No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.15.12/1095 - Release Date: 2007/10/26
19:54
 
  





image001.png
(image/png attachment: image001.png)