Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

ejb one-to-many unidirectional ques  RSS feed

 
Raj Bhandari
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Tks,
Raj
 
Raj Bhandari
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Mrinal K Shahi
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am facing same problem. Is there any other solution apart from making nullable field?
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!