I have a set of entities that connect to each other forming a cycle i.e., parent entity P has two one-to-many relationships with two child entities C1 and C2 and each one of these has a one-to-many relationship with another entity A. Entity A realises the association of these entities (C1,C2) and defines the relationship's attributes (it is not just a join table). All the relationships are navigable in both directions.
The following question arises from this design: What should be the cascade strategy so that entity A can be persisted/merged, given that you always invoke entity manager operations on the root entity P? Should A be cascade reachable from both paths?
Considerations: It seems that if the application chooses to provide only one cascade path there can be scenarios that throw a TransientObjectException. If it provides both paths then these paths have to make the full cycle as for example C1 could be attempted to be saved through A.
Versions: JPA 2.0, Hibernate core 4.1.7, hibernate-jpa-2.0-api 1.0.1