Uploaded image for project: 'Infinispan'
  1. Infinispan
  2. ISPN-4072

JPA Cache Store fails to clear entity which contains ElementCollection

XMLWordPrintable

      When entity stored by JPA Cache Store contains ElementCollection, clear() operation fails with foreign key constraint violation.

      Stack trace in case of MySQL:

      org.infinispan.persistence.jpa.JpaStoreException: Exception caught in clear()
              at org.infinispan.persistence.jpa.JpaStore.clear(JpaStore.java:143)
              at org.infinispan.persistence.jpa.BaseJpaStoreTest.setUp(BaseJpaStoreTest.java:85)
              at java.util.concurrent.FutureTask.run(FutureTask.java:262)
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
              at java.lang.Thread.run(Thread.java:744)
      Caused by: javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute statement
              at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1387)
              at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1310)
              at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:1397)
              at org.hibernate.ejb.AbstractQueryImpl.executeUpdate(AbstractQueryImpl.java:108)
              at org.infinispan.persistence.jpa.JpaStore.clear(JpaStore.java:128)
              ... 23 more
      Caused by: org.hibernate.exception.ConstraintViolationException: could not execute statement
              at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:74)
              at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
              at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
              at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)
              at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:136)
              at org.hibernate.hql.internal.ast.exec.BasicExecutor.execute(BasicExecutor.java:103)
              at org.hibernate.hql.internal.ast.QueryTranslatorImpl.executeUpdate(QueryTranslatorImpl.java:413)
              at org.hibernate.engine.query.spi.HQLQueryPlan.performExecuteUpdate(HQLQueryPlan.java:282)                                                                                                               
              at org.hibernate.internal.SessionImpl.executeUpdate(SessionImpl.java:1290)                                                                                                                               
              at org.hibernate.internal.QueryImpl.executeUpdate(QueryImpl.java:116)                                                                                                                                    
              at org.hibernate.ejb.QueryImpl.internalExecuteUpdate(QueryImpl.java:194)                                                                                                                                 
              at org.hibernate.ejb.AbstractQueryImpl.executeUpdate(AbstractQueryImpl.java:99)                                                                                                                          
              ... 24 more                                                                                                                                                                                              
      Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (`ispn_jpa_test`.`Person_nickNames`, CONSTRAINT `FK_ne1r4l90nve6426b7c7ws198i` FOREIGN KEY (`Person_id`) REFERENCES `Person` (`id`))                                                                                                                                  
              at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)                                                                                                                                                  
              at com.mysql.jdbc.Util.getInstance(Util.java:386)                                                                                                                                                        
              at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1039)                                                                                                                                        
              at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4098)                                                                                                                                            
              at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4030)                                                                                                                                            
              at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2490)                                                                                                                                                 
              at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2651)                                                                                                                                              
              at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2677)                                                                                                                                       
              at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2134)                                                                                                                         
              at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2434)                                                                                                                           
              at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2352)                                                                                                                           
              at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2337)                                                                                                                           
              at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:133)                                                                                                    
              ... 31 more
      

              vjuranek@redhat.com Vojtech Juranek
              vjuranek@redhat.com Vojtech Juranek
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: