title: How does JPA know that entity is new or detached?
body: <p>If entity is deleted or managed it is stored (or its hash) in current EntityManger's persistence context, so JPA know about its state. But how JPA implementation can get to know that given entity is new or detached? Checking if @ID is null will not always work. Is it JPA provider specific?
  In other words how JPA know that it need to throw <code>javax.persistence.EntityExistsException</code> during merging?</p>