Reputation: 220
I am working on Seam to CDI migration. For database transaction I am using Deltaspike, Javaee6. I have followed the instruction given in the Deltaspike with JTA document.
persistence.xml
<persistence 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_2_0.xsd"
version="2.0">
<persistence-unit name="XXXX" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:jboss/datasources/jdbc/XXXX</jta-data-source>
<properties>
<!-- property name="hibernate.hbm2ddl.auto" value="validate"/ -->
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
<property name="hibernate.cache.use_query_cache" value="false"/>
<!-- property name="hibernate.cache.use_second_level_cache" value="false"/-->
<property name="hibernate.show_sql" value="false"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
</properties>
ResourceProducer.java
@PersistenceUnit(unitName="XXXX")
private EntityManagerFactory entityManagerFactory;
@Produces
@Default
@RequestScoped
public EntityManager create()
{
return this.entityManagerFactory.createEntityManager();
}
public void dispose(@Disposes @Default EntityManager entityManager)
{
if (entityManager.isOpen())
{
entityManager.close();
}
}
I am trying to store the value into database using @Transactional annotation in Deltaspike. I haven't seen any errors but the value is not stored in the database.
@Named("accountDetailsAction")
@ConversationScoped
public class AccountDetailsAction implements Serializable {
@Inject
private EntityManager entityManager;
...
@Transactional
public void saveAccountComment() throws SystemException {
System.out.println("Entered into saveAccountComments method...");
Account acct = acctInfo.getAccount();
acct.setComment(accountForm.getCommentText());
Date lastEdited = new Date();
acct.setCommentLastEdited(lastEdited);
Officer lastEditor = utils.getOfficer();
acct.setCommentLastEditorEmployeeId(lastEditor.getEmployeeId());
accountForm.setLastEditDate(lastEdited);
accountForm.setLastEditor(lastEditor.getEmpIdAndFullName());
}
Anyone have faced the same issue? Can you please guide me to fix this issue? Is there any configuration I have missed.
Upvotes: 1
Views: 1526
Reputation: 763
Didi You try to enable it in beans.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans bean-discovery-mode="all" version="1.1"
xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd">
<interceptors>
<class>org.apache.deltaspike.jpa.impl.transaction.TransactionalInterceptor</class>
</interceptors>
</beans>
Upvotes: 1