事务包装方法不会持久或删除

时间:2017-11-17 16:34:58

标签: java java-ee transactions cdi java-ee-7

嗨,我的CDI命名Bean问题是@Transactional。

我使用WildFly 11.1.0.Final。

此处代码:https://gist.github.com/stefanwendelmann/7a1f8352900067d5a59826d6ee205044

这是persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1"
             xmlns="http://xmlns.jcp.org/xml/ns/persistence"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence 
             http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
  <persistence-unit name="QuoLoco" transaction-type="JTA">
    <description>Verbindung zur QuoLoco Datenbank</description>
    <jta-data-source>java:/QUOLOCO_NORM</jta-data-source>
    <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
    <properties>
      <property name="hibernate.format_sql" value="false"/>
      <property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect"/>
      <property name="hibernate.id.new_generator_mappings" value="false"/>
    </properties>
  </persistence-unit>
</persistence>

当我调用方法“doChange”并且只编辑了Empfangseinheittypenparameter时,em.remove和em.persist不会触发刷新。

当我调用方法“doChange”并编辑了一些主要的Empfangseinheittypen empfangseinheittyp时,我在Empfangseinheittypen参数上找了一个不需要刷新的

出错了什么?

这两种方法都是公开的。

请查看相关应用程序的图片

提前感谢您的帮助

1 个答案:

答案 0 :(得分:0)

根据评论,doChange是从同一个bean调用的。 问题类似于@Transactional method called from another method doesn't obtain a transaction,这意味着事务不会以doChange结束,因此从方法返回时不能指望执行刷新。