reset object id to 0 before modifying and adding back in database

if we don't reset the id, object is not added since id already exists.