Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / JavaBeans / May 2004

Tip: Looking for answers? Try searching our database.

Relationships on EJB CMP 2.0

Thread view: 
Joan - 24 May 2004 23:06 GMT
Hi,

I need some help on managing relationships on Entity Beans CMP 2.0.

I have two Entity Beans: Person and Gender. "Person" is stored on a
table that has a foreign key for the "Gender" table. "Person" has an
one-to-one relationship (CMR field) to "Gender". The foreign key
column for "Gender" in the "Person" table is NOT NULL.

The problem occurs when I try to create a new "Person" on the
database. The container tries to insert a NULL value on the foreign
key column and this causes a contraint exception. If I change the
foreign key column to allows NULL, everything works: the container
inserts a NULL value in the foreign key column but then updates the
column with the correct value.

Is this the only way to solve the problem? Can't I have NOT NULL
foreign key columns for CMR fields?

Thanks in advance,

Joan
Frank Langelage - 25 May 2004 00:00 GMT
> Hi,
>
[quoted text clipped - 18 lines]
>
> Joan

AFAIK there are only AppServer specific solutions.
JBoss supports flag
  <insert-after-ejb-post-create>false</insert-after-ejb-post-create>
in the container configuration. Default value is false.
Other Servers will support similar solutions.

Setting this to true delays the SQL-insert until ejbPostCreate() is
called. There you have to set the gender in your case.

If you want to do setting the gender later with setGender(...) this
probably won't help you.

Then the only solution will be to allow NULL values for this field.

Regards
Frank


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.