Without having a reverse relationship from Children to Parent, it is not possible that to happen automatically. It is because the no JPA provider has all object graph in its cache, meaning it is very likely that the parent is simply not known to the JPA provider.
So solve the problem you can do one of the things:
- Add a reverse relationship from Children to Parent and apply a PERSIST cascading.
- Persist the parent manually (by either using the parentDao or directly with
EntityManager.persist()
).