1
我在JBoss6.1實驗的非常奇怪的行爲與CMT +訪問ZOS/390 DB2。DB2 EJB/JPA不會回退
環境是:
- 的JBoss 6.1+
- Linux的紅帽
- DB2在隔離區內運行390
- EJB3/JPA2
交易根本不SystemExceptions回滾。 我試圖BMT和surprisily不工作要麼。 我BMT代碼爲波紋管:
@Stateless
@LocalBean
@TransactionManagement(TransactionManagementType.BEAN)
public class ManterPortabilidadeBean
implements PortabilidadeService {
@Inject
private UserTransaction tx;
@Override
public void incluirPortabilidade(...) {
try {
tx.begin();
//insert into database
daoPortabilidade.incluir(portabilidade);
if (1==1)
throw new EJBException("Bingo");
tx.commit();
} catch (Exception e) {
try {
tx.rollback();
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
}
那麼,記錄在數據庫中!難以置信!!! EJB容器完全忽略了,什麼都不做。
這裏是CMT代碼:
@Stateless
@LocalBean
@TransactionManagement(TransactionManagementType.CONTAINER)
public class ManterPortabilidadeBean
implements PortabilidadeService {
@Override
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public void incluirPortabilidade(...) {
//insert into database
daoPortabilidade.incluir(portabilidade);
if (1==1)
throw new EJBException("Bingo");
}
}
我相信,DB2自動commiting,像自動提交=真實的,但配置informes即自動提交是假的,看到的persistence.xml波紋管:
<persistence-unit name="gecDS" transaction-type="JTA">
<jta-data-source>java:/jdbc/DB2SigecDS</jta-data-source>
<properties>
<property name="hibernate.dialect"value="org.hibernate.dialect.DB2390Dialect" />
<property name="hibernate.default_schema" value="GEC" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.connection.isolation" value="2" />
<property name="hibernate.connection.autocommit" value="false"/>
<property name="javax.persistence.jdbc.driver" value="com.ibm.db2.jcc.DB2Driver" />
</properties>
</persistence-unit>
我standalone.xml我有這樣的數據源配置:
<datasource jta="false" jndi-name="java:/jdbc/DB2SigecDS" pool-name="jdbc/DB2SigecDS" enabled="true">
<connection-url>jdbc:db2://************</connection-url>
<driver-class>com.ibm.db2.jcc.DB2XADataSource</driver-class>
<driver>db2</driver>
<security>
<user-name>*******</user-name>
<password>*******</password>
</security>
</datasource>
任何想法,配置? THX
嘗試改變JTA屬性爲true的數據源文件。 –