| The static default Address is accidentally changed in DefaultMergeEventListener. In the method entityIsTransient first the default constructor of Customer is used to create a new customer object (managed by the persistence context). At this point the new customer references the static address (with city "london"). Hibernate then uses the copyValues() method of DefaultMergeEventListener to copy the values of the original customer into the newly created one. At this point it does not create a new Address object for the new customer but uses the already existing one (which is still the static default one) and thereby changes the city of the static constant address (from "london" to "paris"). |