@Transactional / JPA / JTA / JBoss 5.1.0
Hi, I don't get the transaction work with my setup:
My repository bean:
Code:
@Transactional
public class UserRepositoryBean implements UserRepository {
@PersistenceContext(unitName = "blabla")private EntityManager entityManager;
public IBewirtschafterUser updateBewirtschafterUser(Context ctx, IBewirtschafterUser bewUser) {
.....
}
My spring config:
Code:
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="blabla" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<!-- <property name="showSql" value="true" /> -->
<property name="databasePlatform" value="org.hibernate.dialect.OracleDialect" />
</bean>
</property>
</bean>
<tx:annotation-driven transaction-manager="txManager" />
<bean id="txManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:blablaDS" />
</bean>
My persistence.xml:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!--
<persistence version="2.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_2_0.xsd">
-->
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<persistence-unit name="blabla" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/blablaDS</jta-data-source>
<class>blabla.persistence.entity.blabla</class>
<properties>
<property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
<property name="hibernate.hbm2ddl.auto" value="read-write" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.use_sql_comments" value="true" />
</properties>
</persistence-unit>
</persistence>
It looks like spring don't attaches a transaction to the method call: updateBewirtschafterUser.
When I use
Code:
@TransactionAttribute(TransactionAttributeType.REQUIRED)
instead of then it works.
Can anybody explain whats going on?