Reputation: 11
I have a requirement to load and run a sql-script (ReportData_pr.sql) which will create some procedures on start-up and run those procedures.
We are using Spring 4.0.2.RELEASE and hibernate 4.3.5.Final for development.
Is it possible to run the script file by using hibernate. If yes how to do that. If not is there any other work around to achieve my goal.
Thanks
Upvotes: 0
Views: 5691
Reputation: 8434
You can run your script using nativequery:
e.g.
EntityManager manager = getEntityManager();
Query q = manager.createNativeQuery("BEGIN"+sqlScript+"END;");
q.executeUpdate();
See if that helps
Upvotes: 1