3
|
Brandon Yarbrough · 技术社区 · 15 年前 |
![]() |
1
5
对于数据库,请使用
For the 2nd level cache, get access to the underlying cache regions from the
For the 1st level cache, well, simply get a new
|
![]() |
2
1
采用上面的Pascal方法,我在Spring中寻找创建SchemaUpdate对象的正确方法,并意识到我不需要这样做。相反,我只需要为Hibernate获取一个Spring的sessionFactory对象,并要求它删除/创建模式。结合帕斯卡的其他解决方案,我们得到:
这是相当有效的。唯一的缺点是(至少对我来说)它比在每个表名上调用“delete from obj1”、“delete from obj2”慢得多。不过,我还是喜欢不必重复自己的话。 |
![]() |
3
1
看一看 Unitils . It has great support for database testing (使用dbunit)我们已经使用了很长一段时间。It's really flexible, so you can use it if you ever find the need to pre-load data into the database for particular unit tests.
With Unitils, you'll create a dataset file (
在需要配置数据集的类或测试上
对于所有持久性测试,我们都有一个公共的基类,因此我们能够将注释放在一个地方。 缺点是,每次将实体添加到休眠时,都必须向该文件添加行。您必须获得正确的顺序才能与外键约束保持一致。我们最后添加了一个单元测试来对照hibernate配置检查这个文件,以保持对它的检查。 The up side, especially for a large schema, is that it's way faster than rebuilding the schema. |
![]() |
Gero Mendy · 如何为一个类分配兵变的结果。查询 1 年前 |
![]() |
Hamvy B · 替换不推荐的hibernate方法 1 年前 |
![]() |
Martin Pfeffer · Spring Boot JPA 1 年前 |
|
denstran · 休眠未生成正确的id 2 年前 |
![]() |
Frank · 忽略/跳过Hibernate架构验证中的特定字段 2 年前 |