在我與Wildfly 10,JAVA 8,MySQL和駱駝項目和休眠Wildfly - @TransactionAttribute -
的methodKO仍然存在實體orderEntity( 「KO」),呼叫methodOK,去的除外; methodOK堅持實體orderEntity( 「OK」)
儘管methodKO例外,我想在數據庫中發現orderEntity( 「OK」),所以我詮釋了methodOK用@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) 但這並不工作
這裏的細節上的配置文件:
獨立,全ha.xml:
<datasources>
<xa-datasource jndi-name="java:jboss/datasources/myDS" pool-name="myDS" enabled="true" use-ccm="true">
....
</datasources>
的persistence.xml:
<persistence-unit name="camel" transaction-type="JTA">
<jta-data-source>java:jboss/datasources/myDS</jta-data-source>
....
爲myBean:
@Stateless
public class MyBean {
@Inject
OrderDAO orderDAO;
private void methodKO() throws Exception {
orderDAO.create(new orderEntity("ko"));
methodOK();
throw new Exception("err");
}
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
private void methodOK() {
orderDAO.create(new orderEntity("ok"));
}
}
這將不能工作。對'methodOK'的調用是作爲常規方法調用進行的,它的註釋被忽略。 –