• Post Reply Bookmark Topic Watch Topic
  • New Topic

[CMP] no default value for nullable foreign key

 
deepak yadav
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • 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)
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • 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
  • 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
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
that int to Integer thing worked.
thanks
-deepak
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good for you
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!