Problem in a composite primary key

I have a CMP Entity Bean which has two dependent objects which have siple primary keys, but that EntityBean needs the primary key of that objects to be referenced and identify. What is the way to perform it?any help pleased.Thank you.
[262 byte] By [georba] at [2007-9-26 3:00:36]
# 1

Hi,

I understand your question as follows. You have 3 entity beans eb1, eb2 and eb3. You have primary key pk1 for eb1 and primary key pk2 for eb2. These two keys are part of eb3, and together they should be the primary key for eb3.

What I always do in those cases is to add an additional field to eb3 and concatenate pk1 and pk2. This is specifically easy when pk1 and pk2 are Strings. Perhaps this is not the best way, but I find it very useful, as it is very easy when your primary key is stored in only one field.

Hope this helps, Sponiza

sponiza at 2007-6-29 10:57:53 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

A lot of thanks, sponiza.

Well, I haven't three entity beans, but only one and two dependent objects. The entity bean has a composite pk wher two of this fields are foreing keys of that dependent objects. I'll try doing your way ....

Thank you again and sorry to answer you so late.........

georba at 2007-6-29 10:57:53 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...