I am using Spring HibernateTemplate and need to insert hundreds of records into a mysql database every second.
Not sure what is the most performant way of doing it, but I am trying to see how the multi value mysql inserts do using hibernate.
String query = "insert into user(age, name, birth_date) values(24, 'Joe', '2010-05-19 14:33:14'), (25, 'Joe1', '2010-05-19 14:33:14')"
getHibernateTemplate().execute(new HibernateCallback(){
public Object doInHibernate(Session session) throws HibernateException, SQLException {
return session.createSQLQuery(query).executeUpdate();
}
});
But I get this error: 'could not execute native bulk manipulation query.' Please check your query .....
Any idea of I can use a multi value mysql insert using Hibernate? or is my query incorrect?
Any other ways that I can improve the performance? I did try the saveOrUpdateAll() method, and that wasn't good enough!