Hi, I debugged the OJB source code, and indeed the foreign key value itself will be set to null if the related object is not filled in. (PersistenceBrokerImpl -> assertFkAssignment) So my example works when the related object is filled in : ar.setProductGroup(pg) Is there a workaround for this ? I hope so, otherwise we have to 'lookup' each foreign key property before storing it in the database. (Performance!!!)
Greetings, Frank -----Original Message----- From: Frank Renaers [mailto:[EMAIL PROTECTED] Sent: woensdag 3 december 2003 10:37 To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Upgrade form 0.9.5 to 1.0rc4 : foreign key problem Hi, I upgraded from ojb0.9.5 to 1.0 rc4. Some of my unit tests fail because sometimes foreign key values (1 - N relationship) are not stored : Example : ------------------------- // Create productgroup ProductGroup pg = new ProductGroupBean(); pg.setGroupName("TESTPRODUCTGROUP"); pg.setGroupDescription("DESCRIPTION"); broker.store(pg); // Create 2 articles for this productgroup for (int j = 1; j <= 2; j++) { Article ar = new ArticleBean(); ar.setArticleName("ARTICLE " + j); ar.setProductGroupId(pg.getGroupId()); -------> NOT stored in the database broker.store(ar); } Is this a bug ? Thanks, Frank Renaers --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
