I try to write database usign container managed jta with wildfly 10 application server. It gives no errors but writes nothing to database.
This is my persistence.xml file:
<persistence-unit name="myPersistenceUnit" transaction-type="JTA">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<jta-data-source>java:/datasources/myOracleDataSource</jta-data-source>
</persistence-unit>
My class is:
@TransactionManagement(TransactionManagementType.CONTAINER)
public class UserDaoImpl implements UserDao {
@PersistenceContext(unitName="myPersistenceUnit")
EntityManager userEM;
public UserDaoImpl (EntityManager userEM) {
this.userEM = userEM;
}
@Transactional(Transactional.TxType.REQUIRES_NEW)
public int createNewUser(int id, String name) {
User user = new User(id, name);
userEM.persist(user);
}
}
When I try to write second time it throws unique index exception. However, after restart the server it gives again no errors. I think it holds changes in memory but not writes to database.
I have stucked with this issue. Do you have any idea?