Hello all,
Iam in the process of moving to
EJB 2 from EJB 1.1 and I have a question regarding the ejbCreate() method.
Lets say I have 2 database tables DEPT and EMP:
1) DEPT (DEPTNO primary key, DNAME, LOCATION)
2) EMP (EMPNO primary key, ENAME, ADDRESS, DEPTNO foreign key NOT NULL)
I have a one-to-many unidirectional relationship from DEPT--->EMP. These are my abstract accessor methods in DeptEJB:
1) get/set deptNo
1) get/set dname
2) get/set location
3) getEmployees / setEmployees (takes and returns a collection object)
My question is how do I create an EMP?
I tried the following steps.
1) findByPrimarykey the dept.
2) call create on EmpEJB (returns local interface)
3) call a business method in DeptEJB that calls the getEmployees and then setEmployees.
This works fine if the foreign key is declared NULLABLE!..But in case of NOT NULLS, the ejbCreate in step 2 fails. So how can I insert a EMP?
TIA