Wim Verreycken ha scritto:
> OK.
>
> Seems you need to call the JPA entityManager.joinTransaction() for it to
> join JTA transaction if the EntityManager itself is defined outside the
> transaction.
>
Hi Wim,
thank you for your help. I've changed my code in this manner:
<code>
EntityManager entityManager =
javax.persistence.Persistence.createEntityManagerFactory("MyRentStorePU").createEntityManager();
try {
entityManager.joinTransaction(); // New line
entityManager.getTransaction().begin();
entityManager.persist(cliente);
entityManager.getTransaction().commit();
</code>
Is it correct?
I obtain the same exception :-(
In a previous email you suggest to change persistence.xml using JTA
instead JPA. I've noticed that I'm just using JTA. I post my
persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0"
xmlns="
http://java.sun.com/xml/ns/persistence"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="MyRentStorePU" transaction-type="JTA">
<jta-data-source>jdbc/myrentstore</jta-data-source>
<class>it.myrent.store.entity.Clienti</class>
<class>it.myrent.store.entity.CreditCard</class>
<class>it.myrent.store.entity.Ordini</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="toplink.ddl-generation" value="create-tables"/>
<property name="toplink.logging.level" value="FINE"/>
</properties>
</persistence-unit>
</persistence>
What should I do?
Thanks in advance,
Mauro Chiarugi
--
Mauro Chiarugi
Dogma Systems Srl:
http://www.dogmasystems.it
MyRent, Car Rental Software:
http://www.myrent.it
http://www.myrent.es
http://www.myrent.eu
Email: mauro.chiarugi [at] dogmasystems.it
Tel : +39 071 90 90 188
Fax : +39 071 250 99 63