• 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

[CMP] no default value for nullable foreign key

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
In one of my table, there are few foreign keys (of type NUMBER) which can be NULL. I have a CMP for that table and no value is set for the attributes corresponding to the foreign keys in its create method. During the invocation of create, it is throwing Constraint Violation on this Foreign Key. On decompiling the container generated code for this CMP, I found these values being set to 0. Is there any solution for this problem.
TIA
-deepak
(I am using WLS 8.1, EJBGen, Oracle 8, EJB 2.0)
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Go to http://edocs.bea.com/wls/docs81/ejb/entity.html and look for "Delaying Database Inserts".
 
deepak yadav
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Lasse,
that isn't the answer I am looking for. I have foreign keys which can be NULL but the portion you pointed is talking about delaying database insert because of NON-NULL foreign keys.
regards
-deepak
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmm. You could try changing the Java variable from int to Integer if you haven't already. Another thing you could do would be to use a Collection (i.e. one-to-many relationship).
If you do figure out the solution, please share it with the rest of us.
 
deepak yadav
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
that int to Integer thing worked.
thanks
-deepak
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good for you
 
Too many men are afraid of being fools - Henry Ford. Foolish tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic