Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/367.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.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
Java Jpa未刷新删除_Java_Spring_Hibernate_Jpa_Spring Data Jpa - Fatal编程技术网

Java Jpa未刷新删除

Java Jpa未刷新删除,java,spring,hibernate,jpa,spring-data-jpa,Java,Spring,Hibernate,Jpa,Spring Data Jpa,我有以下代码: @Transactional public class DbCrudServiceImpl implements DbCrudService { @Override public void cleanupDb() { ... serviceUserRepository.deleteAll(); //Spring data JPA repository for entity ServiceUser serviceUs

我有以下代码:

@Transactional
public class DbCrudServiceImpl implements DbCrudService {

    @Override
    public void cleanupDb() {
        ...
        serviceUserRepository.deleteAll(); //Spring data JPA repository for entity ServiceUser
        serviceUserRepository.flush();
        ...

    }

    ...
}
这是一种春豆

我在Jpa属性中将
org.hibernate.event.internal.AbstractFlushingEventListener的记录器设置为
DEBUG
,以检查cleanupDb中发生的情况

显示了cleanupDb生成的日志行:

23:18:53.398 [main] DEBUG o.h.e.i.AbstractFlushingEventListener:149 - ## Processing flush-time cascades
23:18:53.401 [main] DEBUG o.h.e.i.AbstractFlushingEventListener:189 - ## Dirty checking collections
23:18:53.406 [main] DEBUG o.h.e.i.AbstractFlushingEventListener:123 - ## Flushed: 0 insertions, 0 updates, 0 deletions to 8 objects
23:18:53.407 [main] DEBUG o.h.e.i.AbstractFlushingEventListener:130 - ## Flushed: 0 (re)creations, 0 updates, 0 removals to 24 collections
Hibernate: select ... from SERVICE_USER ...
23:19:01.753 [main] DEBUG o.h.e.i.AbstractFlushingEventListener:149 - ## Processing flush-time cascades
23:19:01.757 [main] DEBUG o.h.e.i.AbstractFlushingEventListener:189 - ## Dirty checking collections
23:19:01.761 [main] DEBUG o.h.e.i.AbstractFlushingEventListener:123 - ## Flushed: 0 insertions, 0 updates, 0 deletions to 8 objects
23:19:01.763 [main] DEBUG o.h.e.i.AbstractFlushingEventListener:130 - ## Flushed: 0 (re)creations, 0 updates, 0 removals to 24 collections
为什么没有delete语句?
为什么没有刷新它?

这可能是因为Hibernate遍历整个对象图,如果父对象没有被删除,它会取消子对象的删除

您可以通过将日志级别更改为跟踪并查找来自Hibernate的以下消息来检查这一点:

取消调度实体删除