> Is this a bug? I could not find anything about this behaviour in the
documentation...
I'm not certain, but this smells of a bug to me. I couldn't find any
compelling reason why we would update all the children version fields if
they weren't dirtied. Could you perhaps come up with a unit test that shows
this behavior?

On Tue, Aug 2, 2011 at 9:58 AM, M. Walter <marc.wal...@sbb.ch> wrote:

> I have a OneToMany relationship defined like this:
>
> @Entity
> Parent {
>    @OneToMany(mappedBy = "parent", fetch = FetchType.LAZY, cascade = {
> CascadeType.PERSIST, CascadeType.REFRESH, CascadeType.MERGE})
>    private List<Child> childList;
>    // ...
>    @Version
>    private int version;
> }
>
> @Entity
> Child {
>    @ManyToOne(fetch = FetchType.EAGER)
>    @JoinColumn(name = "PARENT_ID")
>    private Parent parent;
>    // ...
>    @Version
>    private int version;
> }
>
> Now when I change ONE of the child elements and do a merge by executing
> em.merge(parent), the version of ALL children is incremented by one! I
> expected that the version of the changed child is incremented only. Is this
> a bug? I could not find anything about this behaviour in the
> documentation...
>
> -
>
-- 
*Rick Curtis*

Reply via email to