• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

ejb one-to-many unidirectional ques  RSS feed

 
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?
 
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?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!