Re: does Cayenne creates objects by hisself?

From: Mike Kienenberger (mkienen..mail.com)
Date: Sat Apr 22 2006 - 08:16:26 EDT

  • Next message: Jeff de Vries: "Re: PK problem with Postgre"

    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 <mmmmmmmmm5..eb.de> 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" <mkienen..mail.com>
    > To: <cayenne-use..ncubator.apache.org>
    > 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 <mmmmmmmmm5..eb.de> 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 = new Visitor();
    > >
    > > and calling
    > >
    > > visitor.user()
    > >
    > > will Cayenne here creates the object User automatically, or I have to do
    > it by myself?
    > >
    > > Thanks.
    > >
    >
    >



    This archive was generated by hypermail 2.0.0 : Sat Apr 22 2006 - 08:16:50 EDT