Hi!
I am currently attempting to implement a container managed relationship between 2 beans. This is a many-to-one relationship between BeanA and BeanB implemented as a foreign key field, the end result being that I can call BeanA.getB() method and have it return me the related BeanBLocal instance.
So, I have beans A & B where bean A is related to a single bean B. That is...
BeanA
- id INT PK
- b_id INT FK to B.id NOT NULL
BeanB
- id INT PK
BeanB exists prior to creating a BeanA, so I pass a BeanBLocal into the ejbCreate and ejbPostCreate of BeanA. In the ejbPostCreate, I call the setBeanB method.
The first problem I came across was that the ejbCreate would fail due to the the b_id field being defined as NOT NULL in the database - something we DO want. To get around this, I found the insert-after-ejb-post-create tag and defined this to be true!
With this set to true, I am now having the problem that I simply cannot create any entities. They all fail with a javax.ejb.CreateException: Primary key for created instance is null. The reason (I think it is anyway) is that all my objects have an id primary key field defined to come from a database sequence "automagically". That is, I never pass in a primary key to any ejbCreate methods, but rather use the @jboss.persistence auto-increment="true" tag.
Does this make sense?
Any ideas on how to achieve this result?
I am using jboss 3.2.5 and oracle 9i.
Any help MUCH appreciated.