So what is that detached entity the message talks about? a detached object) is an object that has the same ID as an entity in the persistence store but that is no longer part of a persistence context (the scope of an a problem to persist the same object twice within one transaction.The second invocation will just be ignored, although the persist operation might be cascaded to any associations of the entity that were added since the first invocation.But next week we'll handle a number of common entity retrieval pattern first. Because the method returns Object, you should always use the one returned; sometimes, it will be the same instance given (in the case of a transient object being made newly persistent), and others, it will return a copy of the instance given (if the given instance was detached).JDO also takes care to ensure that bidi associations are maintained.From section 15.3 of the JDO 2.2 specification: ===== If two relationships (one on each side of an association) are mapped to the same column, the field on only one side of the association needs to be explicitly mapped.
Or a similar message when we use a different JPA provider than the Hibernate Entity Manager.In the first case the entity is saved, in the latter case it is updated.When switching from Hibernate to JPA a lot of people are dismayed to find that method missing. And figuring out what piece of code persisted (or merged or retrieved) that other entity is harder than figuring out why we get a "detached entity passed to persist" message.The major problem was with the compound IDs and complex relationships between entities (and both simultaneously), but those were sorted eventually...Though, at this stage there's a high risk for application to lose its independence from the JPA provider (for example, ours now works with Open JPA only).