Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring hibernate不更新实体_Hibernate_Spring_Jpa_Quartz Scheduler - Fatal编程技术网

Spring hibernate不更新实体

Spring hibernate不更新实体,hibernate,spring,jpa,quartz-scheduler,Hibernate,Spring,Jpa,Quartz Scheduler,我有一个Spring/JPA/Hibernate应用程序,其中有一段代码,quartz作业每分钟都会调用它来发送一些通知 @Transactional public void sendNotifications(){ Set<MyEntity> entitySet = getDAO().findEntitiesToNotify(); for (MyEntity e : entitySet) { sendEntityNotificationEmail(e

我有一个Spring/JPA/Hibernate应用程序,其中有一段代码,quartz作业每分钟都会调用它来发送一些通知

@Transactional
public void sendNotifications(){
    Set<MyEntity> entitySet = getDAO().findEntitiesToNotify();
    for (MyEntity e : entitySet) {
        sendEntityNotificationEmail(e);
        e.setNotification(true);
        this.merge(e);
    }
     return false;
 }
@Transactional
公共无效发送通知(){
Set entitySet=getDAO().findEntitiesToNotify();
for(MyEntity e:entitySet){
发送实体通知电子邮件(e);
e、 setNotification(true);
本条合并(e);
}
返回false;
}

这在大多数情况下都很有效。关键短语是“大部分时间”,因为此事务有时不会更新数据库,因此通知电子邮件每分钟发送一次,直到我手动停止quartz作业或更新数据库。日志中没有错误,数据库也没有更新。有人知道这个问题是什么吗?或者任何我可以调试这个问题的方法。是否存在某些争用条件,因为此方法每分钟调用一次,因此一个新线程在另一个线程处理同一任务时再次调用该任务,因此更改不会持久化

在其他线程中发送通知可能比再次从数据库获取实体、更新实体状态并保存更好

void方法如何返回布尔值?您似乎在发布问题时忘记了一些详细信息。为什么合并而不保存或更新?为什么合并而不保留?最终使用“flush()”,编写更多代码