cometta
cometta

Reputation: 35679

hibernate createSQLQuery bulk insert

i try to execute these 3 statements, 1 and 2 success, but when reach 3 statement, i get error, is it because i trying to insert into same table during statement 2 and cause statement 3 fail? by the way, all 3 statement is inside one @spring transaction

session.createSQLQuery(" select groupid from group_ where groupid = 888880005").executeQuery;//executed ok 

session.createSQLQuery(" insert into layoutset (layoutsetid,groupid,companyid,privatelayout,logo,logoid,themeid,colorschemeid, wapthemeid,wapcolorschemeid,pagecount) values (888880005, 888880005, 1,0,0,0,'classic','03','mobile','01',0) ").executeUpdate();//executed ok 

session.createSQLQuery(" insert into layoutset (layoutsetid,groupid,companyid,privatelayout,logo,logoid,themeid,colorschemeid, wapthemeid,wapcolorschemeid,pagecount) values (888890005, 888880005, 1,0,0,0,'classic','03','mobile','01',0) ").executeUpdate(); //this fail with

com.liferay.portal.kernel.dao.orm.ORMException: could not execute native bulk manipulation query
            at com.liferay.portal.dao.orm.hibernate.ExceptionTranslator.translate(ExceptionTranslator.java:41)
            at com.liferay.portal.dao.orm.hibernate.SQLQueryImpl.executeUpdate(SQLQueryImpl.java:70)
            at com.company.service.companyPersistenceImpl.doTest(companyPersistenceImpl.java:53)
            at com.company.service.companyLocalServiceImpl.doTest(companyLocalServic

Upvotes: 0

Views: 7979

Answers (2)

NickDK
NickDK

Reputation: 5197

Have you included the entire stacktrace? Seems to be some lines missing there.

However besides the different layoutsetid the two last queries are the same, which is pretty pointless. Probably there are some database constraints on the table to prevent this which result in the error.

Upvotes: 1

Henrik
Henrik

Reputation: 568

the two inserts are exactly the same (same values for columns layoutsetid,groupid,companyid,privatelayout); the failure is due to a key-constraint I guess. what is the primary key of your table?

Upvotes: 1

Related Questions