我有一个使用 postgres 数据库的 spring + hibernate 应用程序。我需要为 Controller 编写单元测试。对于测试,我想使用 h2 数据库,但不幸的是,测试在 create-drop 期间崩溃,给我留下了 bpchar 数据类型无效的信息。我想知道如何解决这个问题,以便我可以运行测试。
我无法将使用 bpchar 的列更改为 varchar,它需要保持原样。我也尝试设置 postgresql 模式,但没有帮助。 我唯一的解决方案是使用嵌入式 postgres 数据库来执行测试,或者还有其他我可以使用的方法吗?
最佳答案
Am I right that the only solution I have is to use embedded postgres database in order to perform tests or is there any other approach that I could use?
您尝试将 postgres 特定的数据类型与 h2(没有它)一起使用。当然,这是行不通的。
如果您不能更改此字段的类型 - 在测试中使用嵌入式 postgres。
关于java - 如何对使用 bpchar 的 h2 数据库进行单元测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56434081/