I'm using JBoss 3.2.2, PostgreSQL, and xdoclet 1.2b3.
I have a one-to-many bi-directional relationship, defined as a CMR, between 'university' and 'student'. The id field in the university table has a SQL type of serial. In the student table during deployment, a universityid column is created that specifies 'not null' and defaults to the next element of university's id sequence.
If I create a new student and add that record to the appropriate university, everything works just fine.
Sometimes I need to create a student record when I don't know what the university is going to be. In this case, the insert makes up a number using the next item in the university id sequence and assigns that. Not nice!!
If I hack the schema so that the universityid in the student table is a plain integer (no 'not null'; no default) things seem to work better...at least I don't get id numbers pointing to non-existent records on the other side of the relation. Another kludge that comes to mind is putting an out-of-band value into the university table ("Unseen university") and having it assigned automatically when nothing is known.
Is there a 'right' way of allowing orphan records within CMR? ...and a way of expressing it to xdoclet?
Just noting that this is still a problem. Suggestions would be appreciated.