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 a caused by record containing an exception describing the problem. Give the entire stack path, possibly hibernate config. - zRrr
  • [2015-11-30T14: 20: 01.330 + 0600] [glassfish 4.1] [INFO] [] [AVAYAcmCDRParseManager] [tid: _ThreadID = 124 _ThreadName = __ ejb-thread-pool5] [timeMillis: 1448871601330] [levelValue: 800] [ [Exception in task AVAYAcmCDRParseManager.ParseNewCDRs () time = 11/30/15 2:20 PM. Exception message = org.hibernate.exception.SQLGrammarException: could not execute statement.]] All that is in the logs - Pavel
  • Configure hibernate.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
  • And mine problem in a particular line that you want to commit. ParseNewCDRs () time = 11/30/15 2:20 PM. Check better the correctness of the data. - Riĥard Brugekĥaim

0