I am developing a application with spring roo, which uses spring 3 and hibernate.
Due to the fact that the Backend is built to be not a productive one, I net an option to set the data back to a dump.
This dump should be "executed" if the user submits a jsp form.
I can load the Dump.sql file and everything is fine except that I do not know how to execute it.
I tried several ways:
1. Native Query with entity Manager:
Query q = entityManager.createNativeQuery(dump);
q.executeUpdate();
But it doesn't work (hibernate exception) I think it's because hibernate cannot "read" a mysql exported Dump.sql file"
2. Way was to use just hibernate:
Configuration cfg = new Configuration();
File configFile = new File(getClass().getClassLoader().getResource("/METAINF/persistence.xml").toURI());
cfg.configure(configFile);
SessionFactory sf=cfg.buildSessionFactory();
Session sess=sf.openSession();
Statement st;
st = sess.connection().createStatement();
But it didn't work either:
org.hibernate.MappingException: invalid configuration Caused by: org.xml.sax.SAXParseException: Document is invalid: no grammar found.
Any suggestions?