There was a problem when I encountered the modulation code today, that is, After I deleted all the records of the database, I registered through the registration page of the front page.
But SQL Error: 1452, SQLState: 23000; Other errors are as follows:
[tomcat HTTP — – 5] WARN org. Hibernate. Engine. The JDBC. Spi. SqlExceptionHelper – SQL Error: 1452, SQLState: 23000
the 2017-03-31 12:27:35 [tomcat HTTP — – 5] WARN org. Hibernate. Engine. The JDBC. Spi. SqlExceptionHelper – SQL Error: 1452, SQLState: 23000
2017-03-31 12:27:35 [tomcat-http–5] ERROR org.hibernate.engine.jdbc.spi.SqlExceptionHelper – Cannot add or update a child row: a foreign key constraint fails (`chatwork`.`user_role`, CONSTRAINT `FK_02dcca8f72554a62bdec8067a49` FOREIGN KEY (`role_id`) REFERENCES `role` (`id`))
2017-03-31 12:27:35 [tomcat-http–5] ERROR org.hibernate.engine.jdbc.spi.SqlExceptionHelper – Cannot add or update a child row: a foreign key constraint fails (`chatwork`.`user_role`, CONSTRAINT `FK_02dcca8f72554a62bdec8067a49` FOREIGN KEY (`role_id`) REFERENCES `role` (`id`))
2017-03-31 12:27:35 [tomcat-http–5] ERROR org.hibernate.engine.jdbc.batch.internal.BatchingBatch – HHH000315: Exception executing batch [could not perform addBatch]
2017-03-31 12:27:35 [tomcat-http–5] ERROR org.hibernate.engine.jdbc.batch.internal.BatchingBatch – HHH000315: Exception executing batch [could not perform addBatch]
org.springframework.dao.DataIntegrityViolationException: could not perform addBatch; SQL [insert into user_role (nickName, role_id) values (?, ?)] ; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: could not perform addBatch
This error occurs because the foreign key is null, so an error is reported. Because it’s a test database, there’s nothing important in it so I just delete the database and restart the project and create the table.
Solution: first check the relationship of their own table, can be set in the background through the set method, or directly in the database to add this foreign key; One more thing is not to delete the library!!
But SQL Error: 1452, SQLState: 23000; Other errors are as follows:
[tomcat HTTP — – 5] WARN org. Hibernate. Engine. The JDBC. Spi. SqlExceptionHelper – SQL Error: 1452, SQLState: 23000
the 2017-03-31 12:27:35 [tomcat HTTP — – 5] WARN org. Hibernate. Engine. The JDBC. Spi. SqlExceptionHelper – SQL Error: 1452, SQLState: 23000
2017-03-31 12:27:35 [tomcat-http–5] ERROR org.hibernate.engine.jdbc.spi.SqlExceptionHelper – Cannot add or update a child row: a foreign key constraint fails (`chatwork`.`user_role`, CONSTRAINT `FK_02dcca8f72554a62bdec8067a49` FOREIGN KEY (`role_id`) REFERENCES `role` (`id`))
2017-03-31 12:27:35 [tomcat-http–5] ERROR org.hibernate.engine.jdbc.spi.SqlExceptionHelper – Cannot add or update a child row: a foreign key constraint fails (`chatwork`.`user_role`, CONSTRAINT `FK_02dcca8f72554a62bdec8067a49` FOREIGN KEY (`role_id`) REFERENCES `role` (`id`))
2017-03-31 12:27:35 [tomcat-http–5] ERROR org.hibernate.engine.jdbc.batch.internal.BatchingBatch – HHH000315: Exception executing batch [could not perform addBatch]
2017-03-31 12:27:35 [tomcat-http–5] ERROR org.hibernate.engine.jdbc.batch.internal.BatchingBatch – HHH000315: Exception executing batch [could not perform addBatch]
org.springframework.dao.DataIntegrityViolationException: could not perform addBatch; SQL [insert into user_role (nickName, role_id) values (?, ?)] ; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: could not perform addBatch
This error occurs because the foreign key is null, so an error is reported. Because it’s a test database, there’s nothing important in it so I just delete the database and restart the project and create the table.
Solution: first check the relationship of their own table, can be set in the background through the set method, or directly in the database to add this foreign key; One more thing is not to delete the library!!