我的 JPA 测试用例有什么问题?我无法使用 em.remove() 删除元组
What is wrong with my JPA test case? I cannot remove tuples with em.remove()
我正在尝试测试我的存储库的删除方法class,但我无法通过测试。
这是我的测试代码。
post delete test code
当调用 persistAll() 时,成员被添加到持久性上下文中。接下来,当 flush() 时,由于 Cascade.Persist 选项,100 post 被添加到持久性上下文中。
然后我再次调用 count()、delete() 和 count() 来检查 post 元组是否已从数据库中删除。
这是 count() 和 delete() 代码。
methods of my repository
我从 JUnit 收到了这条失败消息
test failure message
我通过在 persistAll() 方法的 em.flush() 之后添加 em.clear() 来解决它。
我正在尝试测试我的存储库的删除方法class,但我无法通过测试。
这是我的测试代码。
post delete test code
当调用 persistAll() 时,成员被添加到持久性上下文中。接下来,当 flush() 时,由于 Cascade.Persist 选项,100 post 被添加到持久性上下文中。
然后我再次调用 count()、delete() 和 count() 来检查 post 元组是否已从数据库中删除。
这是 count() 和 delete() 代码。
methods of my repository
我从 JUnit 收到了这条失败消息
test failure message
我通过在 persistAll() 方法的 em.flush() 之后添加 em.clear() 来解决它。