gpt4 book ai didi

java - DBUnit 不重置序列

转载 作者:行者123 更新时间:2023-11-29 06:12:33 26 4
gpt4 key购买 nike

我有一个包含 Spring + Maven + JPA (Hibernate) 的系统。我使用 Junit 和 DBUnit。我有一个带有生成 id 的实体:在测试期间它不会重置序列。我该如何解决这个问题?

最佳答案

您可以尝试以下方法:

    @Before
public void resetSequence() {
// run sql to reset the sequence.
// for DB without functionality to reset sequences (eg. oracle) you can try dropping and re-creating the sequence
}

序列将在每次测试前重置。

关于java - DBUnit 不重置序列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6307604/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com