[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[eclipselink-users] Optimistic lock value and cascade
|
Hello,
Please, can anybody tell me which configurations determine whether the @Version field of a
related object is set.
E.g., two entity classes
class A {
@OneToMany(cascade={CascadeType.MERGE, CascadeType.REFRESH, CascadeType.REMOVE},
fetch=FetchType.LAZY, mappedBy="parent")
private List<B> details;
...
@Version @Column(name = "jdo_version", nullable = false)
private short version;
}
class B {
@ManyToOne(fetch = FetchType.LAZY, cascade={CascadeType.PERSIST, CascadeType.MERGE,
CascadeType.MERGE, CascadeType.REFRESH})
@JoinColumn(name = "a_id")
private A parent = null;
}
When a detail (B instance) is created and inserted into the list "details", should A.version be
updated?
I guessed yes, but that's does not seem to be true.
The only hint on this issue that I found in the specification follows below, but it does _not_
determine the behaviour of the implementation regarding the version field.
"If X is a managed entity, it is synchronized to the database.
For all entities Y referenced by a relationship from X, if the relationship to Y has been
annotated with the cascade element value cascade=PERSIST or cascade=ALL, the persist operation
is applied to Y."
(see JSR 317: JavaTM Persistence API, Version 2.0, 11.1.25)
How is it done in EclipseLink?
Kind Regards, Michael