设置内存数据库需要哪些步骤,使用 Netbeans 6.5.1 在 Junit (3) 'setUp()' 中使用 Hibernate 的'hbm2ddl' 工具自动构建模式?我没有使用 Hibernate 注释——只是一个映射文件。
对于实际代码,我当然想使用磁盘数据库。[那是 Junits 住一个单独的“测试”包]
所以我认为这是到了那里:
- 在 Netbeans 6.5.1 中创建一个标准 Java 项目,添加到 Hiberate 库中。
- 创建 POJO、hibernate.cfg 和 hibernate 映射文件。
- 将 cfg 和映射文件复制到测试包。
设置方法如下所示:
protected void setUp() throws Exception {
Configuration config = new Configuration();
config.configure();
SchemaExport exporter;
exporter=new SchemaExport(config);
exporter.create(true, true);
}