Thomas Dudziak schrieb:

Hello,

> Both your references use a primarykey part as their foreignkey. Is
> this really what you want ? The referenced objects must then have the
> same primarykey value (part) as the ProfileMenuCategory object, and
> that before you store the ProfileMenutCategory object, otherwise you
> would overwrite your primarykey, which you definitly don't want.
> IMO it is easier to have separate fields in ProfileMenuCategory that
> are only used as foreignkey holders. And for references you can even
> use anonymous fields, i.e. you don't need real java fields, you can
> simply add two field descriptors with access="anonymous".

Thanks for your answer.
I think you hit the point, but i don't exactly know how i would correct 
it.

The code (snippet) is used to figure out where the problem was, is:

var pc = new Packages.papillon.ProfileMenuCategory();
pc.setCategory_id(13);
pc.setProfile_id(15);
pc.setSortNr(1);
dao.insert(pc);

I get the following exception:

ERROR: DAO (org.apache.ojb.broker.PersistenceBrokerSQLException: SQL 
failure while insert object data for class 
papillon.ProfileMenuCategory, PK of the given object is [ profile_id=20 
category_id=16], object was [EMAIL PROTECTED], 
exception message is [FEHLER:  Einfügen oder Aktualisieren in Tabelle 
»rel_profiles_menu_categories« verletzt Fremdschlüssel-Constraint »$1«
])

I try to explain what i wanted to acomplish:

Profile has a primary Key
MenuCategory has a primary key

ProfileMenuCategory has (in the database) a primary key (to ensure the 
relationship can only exist once) consisting of both of these with a 
foreign key constraint.

When i do this,

pc.setCategory_id(13);
pc.setProfile_id(15);

i want the fields in the database stored, and the instances of category 
and profile in profilemenucategory populated by the objects 
corresponding to these ids.
How can i accomplish this? (Can you show me how the repository.xml for 
ProfileMenuCategory should look like?)

Thx for your help so far,
Christoph

Attachment: pgpTR8Cod7fG7.pgp
Description: PGP signature

Reply via email to