【发布时间】:2019-10-05 08:43:30
【问题描述】:
从 glassfish3 传递到 payara5 一段代码停止工作。我们的代码将日期保存到一组记录并选择那些更新的记录。在 glassfish3 中无缝工作,在 payara5 中,选择不返回任何记录(似乎它确实在另一个事务中工作)。如果结果不同,我们会抛出异常,因此永远不会保存数据。 事务范围为 READ_COMMITTED
try {
String whereClause = " where "
+ "em.mailboxToBeUsed =:mailbox "
+ "and em.lastSendResult is null "
+ "and (em.errorsNumber is null or em.errorsNumber<4) ";
Query updateQuery = em.createQuery("update EmailTobeSended em "
+ "set em.trysendsince=:dat " + whereClause);
updateQuery.setParameter("mailbox", mb);
updateQuery.setParameter("dat", key);
int modificate = updateQuery.executeUpdate();
em.flush();
TypedQuery<EmailTobeSended> emlocksel = em.createQuery(
"select em from EmailTobeSended em WHERE em.mailboxToBeUsed =:mailbox AND "
+ "em.trysendsince=:dat "
+ " order by em.emailId ", EmailTobeSended.class);
emlocksel.setParameter("mailbox", mb);
emlocksel.setParameter("dat", key);
res = emlocksel.getResultList();
if (modificate != res.size()) {
throw new java.lang.AssertionError("Lock error on select emailtobesended");
}
} catch (Exception ex) {
gotError = true;
res = null;
}
在 glassfish3 上,刷新后,第二个查询找出更新的记录。在payara5上没有结果
编辑
我们使用eclipselink
【问题讨论】:
-
@Karan Sethi :似乎它们与休眠有关,而不是 eclipselink 我们在函数上没有注释
-
任何我希望看到的建议
-
这个问题不清楚结果是什么。修改的值是什么,返回的 res 列表中有什么?我能看到这种情况发生的唯一方法是 EntityManager 不是事务的一部分,但这会导致 em.flush() 调用引发异常。否则,这是您的服务器中的配置问题或错误,您需要展示如何获取 EntityManager 和事务
标签: java jpa eclipselink payara