Be careful! My concern is that you may be fixing the symptom and have not addressed the root cause.
Very rarely do we see reports of entities being saved to the database with negative parmanent ids. This can be a very serious problem, and the problem can propagate and go worse over time. One way that this could happen would be if you had a grandparent-parent-child relationship and failed to include all 3 relationships in the Object Mapper. In any case, I would strongly recommend that you try to prevent this error from occurring during the save (perhaps with a DB constraint).