更新时间:2023-02-07 09:58:53
一切都必须在同一个try / catch:
That was the problem, everything has to be in the same try/catch:
try {
utx.begin();
Query q3 = em.createNativeQuery("DELETE FROM ItemModuleConnection");
Query q4 = em.createNativeQuery("DELETE FROM ModuleConnection");
Query q1 = em.createNativeQuery("DELETE FROM BomModule");
Query q2 = em.createNativeQuery("DELETE FROM BomItem");
q1.executeUpdate();
q2.executeUpdate();
q3.executeUpdate();
q4.executeUpdate();
utx.commit();
} catch (NotSupportedException | SystemException | SecurityException | IllegalStateException | RollbackException | HeuristicMixedException | HeuristicRollbackException e) {
e.printStackTrace();
}