In general, ORM in the project and everything seems to be an insertion of select. But there is a problem. If I want to sink in an array of strings, an error flies.
public EntityManager em = Persistence.createEntityManagerFactory("COLIBRI").createEntityManager(); public void insertAVAYAcmCDRs(List<AvayaCmCdr> cdrList) { em.getTransaction().begin(); for (AvayaCmCdr aCdrList : cdrList) { em.persist(aCdrList); } em.getTransaction().commit(); }
but if on one line all is normal
public void insertAVAYAcmCDRs(List<AvayaCmCdr> cdrList) { for (AvayaCmCdr avayaCmCdr : cdrList) { em.getTransaction().begin(); em.persist(avayaCmCdr); em.getTransaction().commit(); } }
I tried different examples of Tipo
em.getTransaction().begin(); for (int i = 1; i <= 1000000; i++) { Point point = new Point(i, i); em.persist(point); if ((i % 10000) == 0) { em.flush(); em.clear(); } } em.getTransaction().commit();
and other options helps nothing. an error on the em.persist(aCdrList);
line em.persist(aCdrList);
org.hibernate.exception.SQLGrammarException: could not execute statement
SQLGrammarException
means that Hibernate sent an invalid SQL request to the server. In the stack path, there should be acaused by
record containing an exception describing the problem. Give the entire stack path, possibly hibernate config. - zRrrhibernate.show_sql=true
(this is the date of the resource or just when creating the session factor) and SQL will appear in the logs that sends the hibernate and already see what it is wrong with. - Vartlok