Thomas Dudziak schrieb: Hello,
> No, you misunderstood me. OJB can handle multi-column primarykeys > without problems. The issue here is that the value of the primarykey > of this relationship object is given by the primarykey values of the > two related objects. So neither OJB nor the Database can fill the > primarykey value in automatically, you have to do it manually before > inserting the object into the database. > My objection was simply to abuse the primarykey concept for this, but > if it works for you, just go ahead. Ok :-) My Problem is that i don't get it working ;) I insert a Profile and fetch its id. Same for category. Then i create a ProfileMenuCategory and assign the values for the primary keys. If i try to store the Object then, i get an exception because my database refuses the insertion. What confuses me, is that in the exception errormessage i get other values for the primary keys than the ones i set. As i wrote before: var pc = new Packages.papillon.ProfileMenuCategory(); pc.setCategory_id(13); pc.setProfile_id(15); pc.setSortNr(1); dao.insert(pc); Here i have set the ids to 13 and 15. 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� ]) here there is used 16 and 20. Why? I think ojb tries to set the PK itself and uses the sequence of the corresponding database tables to get the PK Values. (The error message means that the FK Constraint is violated because of course the corresponding entries do not exist.) Is there a way to prevent this, or how would i do it "the right way"? Christoph
pgpXcnhHhMbWB.pgp
Description: PGP signature
