Why does a persist method on a removed instance makes it managed , while a merge operation on a removed instance throws an exception.
I am confused as the spec says that a removed instance is still associated with the persistence context.
So why different behavior from persist and merge on a removed entity?
Basic confusion is how to decide when a particular operation will throw an exception.Can we decide it on the basis of an ID conflict , or on the basis of presence of a persistence context?
That is just what the specifications specify, but I guess you were not asking for such an answer. Just look at it like this: persist on a removed instance is a sort of "undo my previous removal".
Merging detached state into a removed instance just sounds strange, why would you do that? What is the practical use? If you really want this kind of feature you can still manage to do it by the sequence of em.persist() and em.merge().
You know it is dark times when the trees riot. I think this tiny ad is their leader:
Devious Experiments for a Truly Passive Greenhouse!