numtech
asked on
Feed database with persistance file in JPA
Hello,
when i deploy my JAR with my persistance.xml it remove the database and recreate it :
For the moment i have sql file that i insert manually in the database after each deploy...
How can i automatize it directly with the deploiment phase?
Can i put sql-insert in my persistance.xml?
Thanks
when i deploy my JAR with my persistance.xml it remove the database and recreate it :
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
But i also want to auto-feed the database after re-create it.For the moment i have sql file that i insert manually in the database after each deploy...
How can i automatize it directly with the deploiment phase?
Can i put sql-insert in my persistance.xml?
Thanks
ASKER
I dont understand what you mean by "classpath".
I used Maven to build my Jar, so maybe i have to set an option in the build phase?
I used Maven to build my Jar, so maybe i have to set an option in the build phase?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Nice job!
Its works great, thanks
Its works great, thanks
ASKER
perfect.
You are welcome ;)
Adding import.sql to the class path works great, hbm2ddl checks if the file exists and executes it. The only additional detail is that every sql command most be on one line, otherwise it will fail to execute.