I have the same problem. I'm saving rather complicated entities on a single form. The entity has a collection of subentities which in turn has again a collection of sub sub entities. It something like this:
class Entity extends Model {
public String field;
@OneToMany(cascade = CascadeType.ALL)
public List<SubEntity> subEntities;
}
class SubEntity extends Model {
public String subField;
@OneToMany(cascade = CascadeType.ALL)
public List<SubSubEntity> subSubEntities;
}
class SubSubEntity extends Model {
public String subSubField;
}
My edit form uses Controller method update to save the entities:
public static void update(Entity entity) {
...
}
I send parameters like:
entity.id = 1;
entity.field = fieldValue;
entity.subEntity[0].id = 10
entity.subEntity[0].subField = subFieldValue0
entity.subEntity[1].id = 11
entity.subEntity[1].subField = subFieldValue1
entity.subEntity[0].subSubEntity[0].id = 100
entity.subEntity[0].subSubEntity[1].id = 101
entity.subEntity[1].subSubEntity[0].id = 110
entity.subEntity[1].subSubEntity[1].id = 111
.. and so on.
The JPAPlugin does good job in fetching the Entity[1] and its collections from the database and applying the change to entity.field. It however, cannot properly apply the changes to the collections. The entity.subEntities list is originally a Hibernate PersistentBag, but it is replaced by a regular ArrayList. Same happens to subSubEntities lists. This causes problems with saving, i.e. the changes are not saved on entity.save()
What do you think, is this a bug in JPAPlugin binding, which needs to be fixed? Or do I possibly have a too complicated approach for saving my entity and its sub entities and sub sub entities?