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

Emmanuel Bernard emmanuel at hibernate.org
Wed Sep 27 12:43:58 EDT 2006


This is consistent with the way saveOrUpdate works

Josh Moore wrote:
>
> 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?
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>



More information about the hibernate-dev mailing list