fix a wrong behaviour with insert and update of same entity