事务 TransactionImple ActionStatus.ABORTED 已回滚
Transaction TransactionImple ActionStatus.ABORTED was already rolled back
我实现了 DTO 业务从 TomEE 到 JBoss 的迁移。
我有这个实体:
@NamedQueries({
@NamedQuery(name = "common.plagebusiness.plage.getAllPlages", query = "SELECT p FROM Plage p ORDER BY p.plageRgMax, p.plageCReseau") })
@Entity
@Table(name = "PLAGE")
public class Plage {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "idPlage")
private Integer idPlage;
@Column(name = "rgMin")
private String plageRgMin;
使用此界面:
@Local
public interface PlagePersistenceManager {
public void importPlages(List<DetailFH55> listeEnregDetail) throws PlageBusinessException, ParseException;
}
和实施:
@Stateless(name = "common.plagebusiness.PlagePersistenceManager")
public class PlagePersistenceManagerImpl implements PlagePersistenceManager {
private static final Logger LOGGER = Logger.getLogger(PlagePersistenceManager.class);
@PersistenceContext(unitName = "PlageBusiness")
private EntityManager em;
@Override
public void importPlages(final List<DetailFH55> listeEnregDetail) throws PlageBusinessException, ParseException {
LOGGER.debug("Entree dans importPlages");
if (null != listeEnregDetail) {
LOGGER.info("Debut Delete");
// suppression des plages
this.deleteAllPlages();
LOGGER.info("Fin Delete et Debut Insertion en bdd");
for (final DetailFH55 myEnreg : listeEnregDetail) {
// insertion des nouvelles plages
final Plage plage = this.convertEnregDetailToPersist(myEnreg);
this.em.persist(plage);
}
LOGGER.info("Fin Insertion en bdd");
}
LOGGER.debug("Sortie dans importPlages");
}
}
不幸的是,em.persist 不起作用,我遇到了这个异常:
Caused by: javax.transaction.RollbackException: JBAS014585: Transaction 'TransactionImple < ac, BasicAction: 0:ffff0a48268b:4bc8a0e:56f01b76:18 status: ActionStatus.ABORTED >' was already rolled back
我在论坛上看到这是因为 Jboss 的超时。我不想更改 Jboss 的配置,所以我尝试将
@org.jboss.annotation.ejb.TransactionTimeout(10000000)
public void importPlages(final List<DetailFH55> listeEnregDetail) throws PlageBusinessException, ParseException
还是一样的异常...这段代码有什么问题。
deleteAllPlages 方法包含:
@Override
public int deleteAllPlages() throws PlageBusinessException {
final Query query = this.em.createNativeQuery("DELETE FROM `PLAGE`");
return query.executeUpdate();
}
我尝试在 persist(plage) 之后放置一个 flush() 和 clear(),但仍然是相同的异常。
final Plage plage = this.convertEnregDetailToPersist(myEnreg);
this.em.persist(plage);
this.em.flush();
this.em.clear();
谢谢。
我注意到您使用的是 org.jboss.annotation.ejb.TransactionTimeout
而不是 required EJB3 one: org.jboss.ejb3.annotation.TransactionTimeout
。
在您的 POM 中,尝试用这个替换引用您当前 TransactionTimeout
的依赖项:
<dependency>
<groupId>org.jboss.ejb3</groupId>
<artifactId>jboss-ejb3-ext-api</artifactId>
<version>2.2.0.Final</version>
<scope>provided</scope>
</dependency>
然后您可以指定您的值和单位:
@TransactionTimeout(value = 10, unit = TimeUnit.SECONDS).
您可以在 JBoss 的论坛找到 related issue。
我实现了 DTO 业务从 TomEE 到 JBoss 的迁移。
我有这个实体:
@NamedQueries({
@NamedQuery(name = "common.plagebusiness.plage.getAllPlages", query = "SELECT p FROM Plage p ORDER BY p.plageRgMax, p.plageCReseau") })
@Entity
@Table(name = "PLAGE")
public class Plage {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "idPlage")
private Integer idPlage;
@Column(name = "rgMin")
private String plageRgMin;
使用此界面:
@Local
public interface PlagePersistenceManager {
public void importPlages(List<DetailFH55> listeEnregDetail) throws PlageBusinessException, ParseException;
}
和实施:
@Stateless(name = "common.plagebusiness.PlagePersistenceManager")
public class PlagePersistenceManagerImpl implements PlagePersistenceManager {
private static final Logger LOGGER = Logger.getLogger(PlagePersistenceManager.class);
@PersistenceContext(unitName = "PlageBusiness")
private EntityManager em;
@Override
public void importPlages(final List<DetailFH55> listeEnregDetail) throws PlageBusinessException, ParseException {
LOGGER.debug("Entree dans importPlages");
if (null != listeEnregDetail) {
LOGGER.info("Debut Delete");
// suppression des plages
this.deleteAllPlages();
LOGGER.info("Fin Delete et Debut Insertion en bdd");
for (final DetailFH55 myEnreg : listeEnregDetail) {
// insertion des nouvelles plages
final Plage plage = this.convertEnregDetailToPersist(myEnreg);
this.em.persist(plage);
}
LOGGER.info("Fin Insertion en bdd");
}
LOGGER.debug("Sortie dans importPlages");
}
}
不幸的是,em.persist 不起作用,我遇到了这个异常:
Caused by: javax.transaction.RollbackException: JBAS014585: Transaction 'TransactionImple < ac, BasicAction: 0:ffff0a48268b:4bc8a0e:56f01b76:18 status: ActionStatus.ABORTED >' was already rolled back
我在论坛上看到这是因为 Jboss 的超时。我不想更改 Jboss 的配置,所以我尝试将
@org.jboss.annotation.ejb.TransactionTimeout(10000000)
public void importPlages(final List<DetailFH55> listeEnregDetail) throws PlageBusinessException, ParseException
还是一样的异常...这段代码有什么问题。
deleteAllPlages 方法包含:
@Override
public int deleteAllPlages() throws PlageBusinessException {
final Query query = this.em.createNativeQuery("DELETE FROM `PLAGE`");
return query.executeUpdate();
}
我尝试在 persist(plage) 之后放置一个 flush() 和 clear(),但仍然是相同的异常。
final Plage plage = this.convertEnregDetailToPersist(myEnreg);
this.em.persist(plage);
this.em.flush();
this.em.clear();
谢谢。
我注意到您使用的是 org.jboss.annotation.ejb.TransactionTimeout
而不是 required EJB3 one: org.jboss.ejb3.annotation.TransactionTimeout
。
在您的 POM 中,尝试用这个替换引用您当前 TransactionTimeout
的依赖项:
<dependency>
<groupId>org.jboss.ejb3</groupId>
<artifactId>jboss-ejb3-ext-api</artifactId>
<version>2.2.0.Final</version>
<scope>provided</scope>
</dependency>
然后您可以指定您的值和单位:
@TransactionTimeout(value = 10, unit = TimeUnit.SECONDS).
您可以在 JBoss 的论坛找到 related issue。