0

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

2

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

It might help if you explain what the getEntityManager() method does.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.