• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ejb one-to-many unidirectional ques

 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic