Hi, Looking at the example in Oreilly ejb3.0 book, a customer can have a collection of phones. So lets take the implementation where the phone table includes a foreign key to the customer cable (no join table here).
My question is, when I want to save a customer (which has collection of phone objects in it), is just doing
manager.persist(customer) sufficient or I need to have a transaction and do this:
manager.persist(customer);//phones collection here is blank customer.getPhones.add(phone);
I ask because I tried only doing this: manager.persist(customer) but I get an error saying ORA-01400: cannot insert NULL into PHONE.CUSTOMER_ID.
posted 10 years ago
Ok, I tried something now.. I removed the not null constraint from the phone table for customer_id column and it works. But now I ask why.. can't I keep constraint there?