Hi Rob,
I work with Ivan, so let me answer your questions and show what I have so far:
> You don't say if it is a stateless update or if the beans were previously fetched.
Yes, we were using stateless update, now I am trying to use save(), but EBean apparently was not detecting the changes to the collection.
dbObject.getCultureLocations().add(cultureLocation);
ebeanServer().getBeanState(dbObject).isDirty(); // returns false
> Hit the DB? No, if you want that just fetch the object graph in first, apply changes and then save().
I am trying to do that. The
apply changes part was not trivial, then I found the BeanDescriptor.merge() and I am trying to make it work with an adapted version of it (sample code in anex).
Now the problem is: EBean is trying to update the new children instead of inserting it.
I have found this code in DefaultPersister:
if (publish) {
// insert if it is a new bean (as publish created it)
type = entityBean._ebean_getIntercept().isNew() ? Type.INSERT : Type.UPDATE;
} else {
// determine Insert or Update based on bean state and insert flag
type = desc.isInsertMode(entityBean._ebean_getIntercept(), insertMode) ? Type.INSERT : Type.UPDATE;
}Digite o código aqui...
The publish behavior is what I wished for, but is is returning insertMode = false -> UPDATE.
> Do those beans always have their @Id set or just for this use case?
Always, the ids are generated by the client.
> Note that you always have the ability to control exact behavior per
transaction via turning off cascade persist and traversing the graph
yourself (and calling insert or update etc). So there is always that
option.
I will try to do that for today, but after would be better to get the save working.