[hibernate-dev] More fun with merging : non-updatable fields

Josh Moore josh.moore at gmx.de
Wed Sep 27 10:37:36 EDT 2006


Using Hibernate with non-updatable fields can leave entities in a 
confused state.

Take an Image with a field creationEvent, not updatable. If 
Image.creationEvent is set on an instance and passed to session.merge(), 
then:

(1) Properly, no UPDATE is issued.
(2) DefaultMergeEventListener.copyValues copies the invalid 
creationEvent to the new instance
(3) The client who receives that instance thinks creationEvent has been 
successfully updated.

What are the semantics here? Should the spec specify this? Max, you 
mentioned via irc that this wasn't in the spec, but I assume

	@Column( updatable = false )


would cause the same issue.

Currently I'm writing logic in my MergeEventListener to NOT copy these 
values (difficult because of the EmbeddedComponentTypes I'm using). It 
seems, however, that this should be belong directly to 
DefaultMergeEventListener.

Opinions?



More information about the hibernate-dev mailing list