I would like hibernate to initialise my database using mapping (to create tables) and import.sql (to insert init datas).
I've put this property <property name="hibernate.hbm2ddl.auto">create</property> .
It works great, but each time i reload my webapp, my datas are deleted.
Using 'update' instead of 'create', works for the tables, but doesn't read the import.sql file.
The solution, for the moment, is :
1/ put property value to create (create table+datas),
2/ comment the property or set it to update.
But it is not really 'user-friendly', it's a portlet and i don't want everybody to configure my hibernate property file each time after the first deploy.
I think two solutions can be implemented in the code of hibernate:
1/ add a create-update value
If tables don't exist apply create value (create tables and load import.sql), if exist apply update value (don't reload import.sql)
2/ modify update
Make it loading the import.sql file just after the create table call (but load the file just one time).
My Question:
Does anybody have the same problem (or the solution) to avoid users modifying the property after the first deploy ?
Cheers,
Eric BOURDIN
Hibernate version: 3.1.3
|