In the first case the entity is saved, in the latter case it is updated.
There are 2 references on each side of the association and these 2 references both represent the same association but can change independently of one another.
Of course, in a correct application the semantics of the bidirectional association are properly maintained by the application developer (that’s his responsibility).
SQL] (default task-9) select dept0_as id1_0_0_, dept0_Name as dept Name2_0_0_ from Dept dept0_ where dept0_.id=? Basic Binder] (default task-9) binding parameter  as [BIGINT] -  ,951 DEBUG [org.hibernate. Basic Binder] (default task-9) binding parameter  as [BIGINT] -  ,957 DEBUG [org.hibernate.
SQL] (default task-9) select employees0_.dept_id as dept_id5_0_0_, employees0_as id1_1_0_, employees0_as pos4_0_, employees0_as id1_1_1_, employees0_.dept_id as dept_id5_1_1_, employees0_.first Name as first Nam2_1_1_, employees0_Name as last Name3_1_1_, employees0_as pos4_1_1_ from Employee employees0_ where employees0_.dept_id=? Basic Binder] (default task-9) binding parameter  as [BIGINT] -  ,956 DEBUG [org.hibernate.
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.
We kicked off our hunt for JPA implementation patterns with the Data Access Object pattern and continued with the discussion of how to manage bidirectional associations.
This week we touch upon a subject that may seem trivial at first: how to save an entity..
Note “Owning side” and “inverse side” are technical concepts of the ORM technology, not concepts of your domain model.