I don't think anyone could try to point your mistake if you don't post some code ;-)
I thing that just by using CMR you don't guarantee integreity, you also have to do it yourself (or by configuration or by coding). I'd leave fk the referencial integrity problem to the db, i don't see much problem on that.
Anyway, i don't have much experience yet, but it's just an opinion.
SCJP 1.4, SCWCD 1.4
Joined: Jul 03, 2002
Posting code might not help me even. (Anyways I have to post a lot of code) It is a conceptual problem and I need advice on how to do it.
It's a simple problem. ejbCreate attempts to insert the record given only simple CMP fields and the primary key. CMR fields are set in ejbPostCreate -- which is done after the database field is inserted by the container. So, your referential integrity has already been violated, and the database won't allow the initial insert after ejbCreate to be successful.
There is another solution, however. I think that container-specific deployment descriptors may allow you to do something akin to what you want, but you would have to consult your server's documentation. Or you can try and enforce your referencial integrity through your business logic.