Return-Path: Delivered-To: apmail-incubator-cayenne-user-archive@locus.apache.org Received: (qmail 60091 invoked from network); 22 Apr 2006 12:16:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 22 Apr 2006 12:16:49 -0000 Received: (qmail 71606 invoked by uid 500); 22 Apr 2006 12:16:49 -0000 Delivered-To: apmail-incubator-cayenne-user-archive@incubator.apache.org Received: (qmail 71584 invoked by uid 500); 22 Apr 2006 12:16:48 -0000 Mailing-List: contact cayenne-user-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cayenne-user@incubator.apache.org Delivered-To: mailing list cayenne-user@incubator.apache.org Received: (qmail 71575 invoked by uid 99); 22 Apr 2006 12:16:48 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 22 Apr 2006 05:16:48 -0700 X-ASF-Spam-Status: No, hits=0.3 required=10.0 tests=MAILTO_TO_SPAM_ADDR,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of mkienenb@gmail.com designates 64.233.182.191 as permitted sender) Received: from [64.233.182.191] (HELO nproxy.gmail.com) (64.233.182.191) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 22 Apr 2006 05:16:47 -0700 Received: by nproxy.gmail.com with SMTP id p48so518291nfa for ; Sat, 22 Apr 2006 05:16:26 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=g+k6ae81nl36H1lzNR76RRzh1yrezI1NAFeXFvxqKgDcwq84gkzb2gbnvtvsueTHiLk29ZYn0sxkQlD8PewqRnzNTslvLUBBIGvukjRx3hDNj7cKkli75YK/ljwPES4uRxQ7zWmHqINZqfhAPfZ6rjX9fimwAAvbc4VkcGgMK5M= Received: by 10.49.57.3 with SMTP id j3mr1727494nfk; Sat, 22 Apr 2006 05:16:26 -0700 (PDT) Received: by 10.48.216.7 with HTTP; Sat, 22 Apr 2006 05:16:26 -0700 (PDT) Message-ID: <8f985b960604220516v5cfb70afqefb11c1dd4a5d885@mail.gmail.com> Date: Sat, 22 Apr 2006 08:16:26 -0400 From: "Mike Kienenberger" To: cayenne-user@incubator.apache.org Subject: Re: does Cayenne creates objects by hisself? In-Reply-To: <004101c66605$86259f40$14b2a8c0@PC> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <570FE5C299B4CC4587C95EF5680619C1867DD6@FNHH-SVMEXDB003.Freenet-AG.de> <57E6EEB0-BA45-46CD-9341-2FDDF51D1156@objectstyle.org> <006f01c66480$b7323430$14b2a8c0@PC> <45B7A54B-6F3D-4918-BAB5-2C8F711D3194@pfrog.com> <76A40C7C-14CD-447B-ACCA-48771D909181@objectstyle.org> <000f01c665f0$5c751050$14b2a8c0@PC> <002801c665fe$8991f360$14b2a8c0@PC> <8f985b960604220457i7d71feb7qd554736598e9d0ea@mail.gmail.com> <004101c66605$86259f40$14b2a8c0@PC> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N setUser() or addToVisitorList() are standard cgen-created wrapper methods which call setToOneTarget() or addToManyTarget(). They provide you with type-checking. Also, in theory, if you ever had to migrate away from Cayenne (undoubtably due to some political decision rather than a technical one (-: ), it's easier to write code-generated wrapper methods than to replace code that calls Cayenne classes directly in your application classes. public void setDependentIndividual(SecIndividual dependentIndividual) { setToOneTarget("dependentIndividual", (com.gvea.admindb.entity.cayenne.SecIndividual)dependentIndividual, true); } public void addToParentRoleList(SecGroup obj) { addToManyTarget("parentRoleList", (com.gvea.admindb.entity.cayenne.SecGroup)obj, true); } On 4/22/06, WONDER wrote: > Ok. thx > > ps: why do you use setUser() or addToVisitorList() methods? > Is it not better to use setToOneTarget() or addToManyTarget()? I thought > this will saves you to create the inverse relationship! > > > peaSakoe > ----- Original Message ----- > From: "Mike Kienenberger" > To: > Sent: Saturday, April 22, 2006 1:57 PM > Subject: Re: does Cayenne creates objects by hisself? > > > No, you'd have to associate the visitor with a particular user > somehow. By default the relationship will be null. > > visitor.setUser(user) > > or > > user.addToVisitorList(visitor) > > > > On 4/22/06, WONDER wrote: > > Hi, > > > > I have the folloging situation. > > > > Entity "User" has relation toMany "Visitor" its name is visitors. > > > > Usually if I "Fetch" the object Visitor from DB and then call > > > > visitor.user() > > > > Cayenne fetches the object User from the DB automatically. > > > > > > Now, creating a Visitor object. > > > > Visitor visitor =3D new Visitor(); > > > > and calling > > > > visitor.user() > > > > will Cayenne here creates the object User automatically, or I have to d= o > it by myself? > > > > Thanks. > > > >