I have a classA which has a one-to-one relationship to classB. The classB side of the relationship is really 0 or 1. So, not every classB has a classA. In this case setting one-to-one relationships on both side is not what I want.
Instead what I did was to create classB in the constructor of the classA. I didn't annotate any relationships in any of these two classes in this case. When I try to create classA I get following exception : org.apache.openjpa.persistence.InvalidStateException: Encountered unmanaged object "ClassB" in persistent field "ClassA.myClassB" of managed object "ClassB" during flush. However, this field does not allow cascade persist. You cannot flush unmanaged objects. Then I tried to set a one-to-one relationship on A to B. But no relationship set on the B to A. This time I get another exception : org.apache.openjpa.persistence.ArgumentException: "ClassA.myClassB" declared that it is mapped by "myClassB", but that is a not a field of the related type. So, how do I handle this type of situations with openjpa ? Again ClassA has a one-to-one relationship to ClassB, but ClassB has 0 or 1 relationship to ClassB. Gul
