Why don't they make the entity be attached if needed? Is there any design issues prevent that?
It won't be tough for container provider to implement it. But container provider (entity manager implementor) need to follow what spec says to them.
I think it doesn't make sense that if I want to refresh, or remove I need to merge first, and merging is updating, right? Moreover, I think it's very confusing that to refresh or remove I need to call merge *to update the entity first*( before I can refresh (reset) or remove it.
There is no point to merge (update) if I want to refresh or remove an entity.
I had same doubt
in this thread, and I was answer by Ralph Jaus that requirement is entity should be attached before refresh/ remove is called and that is possible by calling find() before refresh/ remove is called
em.refresh(em.find(Item.class, item.id));