1
I have the following tables
Produto {
idproduto
nome
preco
}
Promocao {
descricao
datainicio
datatermino
id_produto_fk
}
When trying to insert a new promotion returns me the following error:
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`mercado_db`.`promocao`, CONSTRAINT `produto_id_fk` FOREIGN KEY (`id_produto_fk`) REFERENCES `produto` (`idproduto`) ON DELETE NO ACTION ON UPDATE NO ACTION)
Guy did some testing here, I have an app that sends a Promotion object to the method insert with the above data. In the app I print the promotion.id_producto_fk and appears the product id in the component but before sending to the bank in the insert method I put a print of the object to save and in id_producto_fk appears 0, I do not know what else to do to solve this.
– fabricio b.