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

问题描述 投票:0回答:1

嗨我有一个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时,我在Empfangseinheittypenparameter上找到了一个不需要刷新的方法

做错了什么?

两种方法都是公开的。

请查看附带的应用程序的图片

在此先感谢您的帮助

java java-ee transactions cdi java-ee-7
1个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.