Hi,
I have classes mapped like this:
class Parent {
@Id
int parentId;
@Version
int version;
@OneToMany(...)
ListChild children;
}
class Child
{
@Id
int childId;
... // no relationship to parent, its uni-directional
}
The foreign key is on the CHILD table, but in
Hey,
we recently switched to 2.2.0 (cant go higher because we use Java8) and we
found a change in behavior.
Asumme we created a new Entity which looks like this:
Person.java
--
int oid
String name
CustomerType adress
we created the object like so:
Person p = new Person();
@Version is used to support optimistic locking semantics at the object
level and bear no implication to db row or ownership.
In what circumstances would the Parent version be bumped by one?
When an entity is changed and needs to be updated back to the database row,
the version field must be
Hi Marc,
Sorry for the troubles. Technically, it looks like you were lucky and
coding to a bug in the OpenJPA code. Since you just created this
CustomerType, we have to assume that it's unmanaged. And, we can't
automatically cascade the persist operation to this unmanaged entity. And,
in your
Hello,
We solved this by using the getReference() method.
Something like
Person p = new Person();
p.setName(foo);
p.setCustomerType(em.getReference(CustomerType.class, 1);
persist(p);
John
-Ursprüngliche Nachricht-
Von: Kevin Sutter [mailto:kwsut...@gmail.com]
Gesendet: Montag, 2.
Kevin,
thanks for fast feedback. To your questions:
1) of course we could do the em.find() and do it the way it should be done
;-)
2) no, we have not tried using em.merge(), this would be an option we could
check out.
And yes. WE dont want to persist the CustomerType since its already there.
Marc --
I'm thinking that there was a change in cascade persist behavior that you
might be running into.
http://openjpa.apache.org/builds/2.2.2/apache-openjpa/docs/jpa_2.2.html#jpa_2.2_cascadePersist
On Mon, Jun 2, 2014 at 9:53 AM, Marc Logemann marc.logem...@gmail.com
wrote:
Kevin,
thanks