Hibernate import.sql Tip

Hibernate的一个小功能对开发人员的单元测试挺有用的:在创建SessionFactory对象的时候自动导入数据(import.sql).
大家应该都很熟悉,在classpath下面建一个import.sql语句,还有把hibernate.hbm2ddl.auto属性设置为create或create-drop即可,不过我今天最主要的是说两个步骤都做了,但还以能成功导入数据的问题,就是我们在import.sql中的SQL语句,一行必须是一个完整的SQL语句,否则就可能导入数据失败.



hibernate + import.sql
This is my first article in my blog, it just a tip.
As we know, Hibernate has a function of import data automatically and it's useful for the unit test. We can execute our SQL script where we getting SessionFactory. step 1:create a file named import.sql in the classpath;
step 2:set the hibernate.hbm2ddl.auto property value of creat or create-drop.
(notice: one line one SQL script, and this is why I write on my blog)


你可能感兴趣的:(sql,Hibernate,单元测试,Blog)