I want to update the key in a table and this key is FK in other tables.
em.createNativeQuery("SET FOREIGN_KEY_CHECKS=0").getResultList().
em.createNativeQuery("update user set name = ?1 where name = ?2").executeUpdate();
query.setParameter(1, "aa");
query.setParameter(2, "bb");
However i get an exception even if I disabled the foreign key checks.
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (
test_import_1
.assessment_user
, CONSTRAINTFK32kg3rlqty5i2i729a22icn7q
FOREIGN KEY (user_name
) REFERENCESuser
(name
))