I also faced the same issue. Knowing fully that a master record exists in my Trainer table (PK table), I tried inserting record into the Events table (FK table). Now, the relation of Trainer-Events is 1-many.
The Trainer PK is an integer. In my events remote interface, I declared setTrainerId() as:
void setTrainerId(Integer trainerId) throws RemoteException, CreateException;
...
However, in the bean, I declared setTrainerId() as:
public abstract void setTrainerId(int trainerId) {
...
The difference is in param type (Integer Vs int).
I am using 1.5 version as my underlying JDK, which allowed autoboxing, hence didn't complain during deployment.
But it resulted in referential integrity exception from the client program of events
EJB (saying child record cannot be added/updated due to non-existing trainer).
When I changed the bean setTrainerId() as:
public abstract void setTrainerId(Integer trainerId) {
...
.. it worked fine. I still don't know the reason why it worked now. As per my understanding, primitive types like int are serializable, hence an int as the param type in the bean should work as well.
Can someone please tell me the reason?