Return-Path: Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: (qmail 22078 invoked from network); 18 Feb 2011 10:19:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 18 Feb 2011 10:19:13 -0000 Received: (qmail 82468 invoked by uid 500); 18 Feb 2011 10:19:11 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 82457 invoked by uid 500); 18 Feb 2011 10:19:09 -0000 Mailing-List: contact user-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cayenne.apache.org Delivered-To: mailing list user@cayenne.apache.org Received: (qmail 82437 invoked by uid 99); 18 Feb 2011 10:19:08 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Feb 2011 10:19:08 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [209.85.214.171] (HELO mail-iw0-f171.google.com) (209.85.214.171) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Feb 2011 10:19:00 +0000 Received: by iwn2 with SMTP id 2so3482181iwn.16 for ; Fri, 18 Feb 2011 02:18:39 -0800 (PST) Received: by 10.231.156.1 with SMTP id u1mr399823ibw.52.1298024319154; Fri, 18 Feb 2011 02:18:39 -0800 (PST) Received: from [10.0.1.2] (ppp-70-249-218-8.dsl.stlsmo.swbell.net [70.249.218.8]) by mx.google.com with ESMTPS id d21sm1627299ibg.15.2011.02.18.02.18.37 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 18 Feb 2011 02:18:38 -0800 (PST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Apple Message framework v1082) Subject: Re: Storing information in a join table From: Robert Zeigler In-Reply-To: Date: Fri, 18 Feb 2011 04:18:36 -0600 Content-Transfer-Encoding: quoted-printable Message-Id: <9549593F-869E-4512-9F9B-E1933BE4CB7E@roxanemy.com> References: To: user@cayenne.apache.org X-Mailer: Apple Mail (2.1082) X-Virus-Checked: Checked by ClamAV on apache.org You can access the intermediate object if you choose not to flatten the = relationship. There's nothing to prevent a join table from being = represented as its own entity in cayenne. It can make your application a = little more complicated, but I've done it before when the join table = carries additional meaningful information, eg, information that somehow = modulates the join (eg: creating a createDate column on the join table = for keeping track of exactly when the association was created... stuff = like that). Cheers, Robert On Feb 18, 2011, at 2/184:10 AM , Christian Grobmeier wrote: >> What semantically is "isFresh" attribute? Is it a some business logic >> attibute, or simple "autoset" variable, like timestamp etc.? >=20 > No its business logic. In fact it defines the view-rights for the > specific apples to the plums :-) >=20 >> If former, you cannot live without ApplePlum ObjEntity. Is the = problem >> then in just setting its default value? Then you can simply set it at >> database level. >=20 > OK, I will try to change my mind on this one. I have hoped I could > somehow access the intermediate object. >=20 > THanks! >=20 > Cheers > Christian >=20 >=20 >> If the default value is dynamic, like timestamp, you can try = intercept >> Cayenne's generating of queries: >> http://cayenne.apache.org/doc30/custom-batchquerybuilder-factory.html >>=20 >> 2011/2/18 Christian Grobmeier : >>> Hello, >>>=20 >>> I have the following scenario: >>>=20 >>> Apple 1 -> n ApplePlum n : 1 Plum >>>=20 >>> I want store an additional flag in ApplePlum (lets say isFresh =3D = true/false >>>=20 >>> How can I do this? I know I should not use flattened relations, but >>> they are so nice, I would like to keep them. At least it would lead = to >>> the Method getApplePlum->getPlum which is not very neat. >>>=20 >>> In order to do so I have thought I could create a custom method in = my >>> Apple class, which copies some code from the _Apple class. >>>=20 >>> Like this: >>>=20 >>> public void addToAppleAsFreshPlum(Plum value) { >>> String relName =3D "ApplePlum"; >>> if (value =3D=3D null) { >>> throw new NullPointerException("Attempt to add null = target >>> DataObject."); >>> } >>>=20 >>> willConnect(relName, value); >>> Object holder =3D readProperty("ApplePlum"); >>>=20 >>> // Now I would like to get the object created by the holder: >>> ((ApplePlum)holder).setFresh(true); >>>=20 >>> getObjectContext().propertyChanged(this, relName, null, = value); >>>=20 >>> if (holder instanceof Collection) { >>> ((Collection) holder).add(value); >>> } >>> else if (holder instanceof Map) { >>> ((Map) holder).put(getMapKey(relName, >>> value), value); >>> } >>>=20 >>> setReverseRelationship(relName, value); >>> } >>>=20 >>> Of course this does not work. I wonder if there is another option = for >>> me? Any ideas? >>>=20 >>> Thanks in advance >>> Christian >>>=20 >>=20 >>=20 >>=20 >> -- >> Andrey >>=20 >=20 >=20 >=20 > --=20 > http://www.grobmeier.de