I\'m trying to run a script (.sql file) but i have multiples errors since i tried many ways, here\'s my main sql script:
INSERT INTO `Unity` VALUES (11,\'paq
You can't execute the script by the em.createNativeQuery
, as i know.
You should to split the script into statements and execute them one by one.
You may use ScriptRunner. It can be used separately from the MyBatis.
Example:
em.getTransaction().begin();
Connection connection = em.unwrap(Connection.class);
ScriptRunner sr = new ScriptRunner(connection);
sr.runScript(new StringReader("INSERT INTO `Unity` VALUES (11,'paq',0,'2013-04-15 11:41:37','Admin','Paquete','Paq',0,'2013-04-15 11:41:37','AAA010101AAA',NULL);\r\nINSERT INTO `product` VALUES (11,'chi','USD','chi one',0,'2013-04-15 11:42:13',0,'Admin','Chi name',0.25,0,15,'2013-04-15 11:42:13','AAA010101AAA',NULL);"));
em.getTransaction().commit();