Re: Newbie: AUTO_PK_SUPPORT problem

From: Mike Kienenberger (mkienen..mail.com)
Date: Mon Jan 02 2006 - 14:03:21 EST

  • Next message: Mike Kienenberger: "Re: strange cgen behavior"

    toDepPk means "to dependent primary key". This means that the value
    for the primary key for the target entity on the other side of the
    relationship depends on (is copied from the primary key of the source
    entity) the source entity, instead of generating a primary key.

    As an example,

    table Employer
     int idPerson (PFK) = Person's primary key
     int idcompany (PFK) = Company's primary key

    On 1/2/06, Andrea Borgogelli Avveduti <borgogell..otmail.com> wrote:
    >
    >
    >
    >
    > Great Mike, it works.
    >
    > But what does it mean toDepPk ???
    >
    >
    > ________________________________
    >
    > From: Mike Kienenberger <mkienen..mail.com>
    > Reply-To: cayenne-use..bjectstyle.org
    > To: cayenne-use..bjectstyle.org
    > Subject: Re: Newbie: AUTO_PK_SUPPORT problem
    > Date: Mon, 2 Jan 2006 13:21:26 -0500
    >
    > > > b) My Cayenne mapping is
    > > >
    > > > DbEntity Employer's relationships:
    > > > toPerson (toDepPk checked)
    > > > toCompany (toDepPk checked)
    > >
    > >It sounds like the problem is that you've marked the toDep
    > >relationships in reverse.
    > >
    > >Instead, you want Person's toEmployer and Company's toEmployer
    > >relationships to be marked toDepPk, and leave Employer's relationships
    > >unchecked (toMasterPK implied).
    > >
    > >I always find this confusing, so maybe I'm the one with it backwards,
    > >but it should be an easy thing for you to try.
    > >
    > >
    > >On 1/2/06, Andrea Borgogelli Avveduti <borgogell..otmail.com> wrote:
    > > >
    > > > Hi boys
    > > >
    > > > I'm a newbie with Cayenne and have a little problem with auto pk
    > generation.
    > > > I have read the page and watched the table at
    > > >
    > http://objectstyle.org/cayenne/userguide/design/autopk.html
    > > > but it's not so easy to understand
    > > > I have read the document at
    > > >
    > http://www.objectstyle.org/confluence/display/CAY/Generated+Columns
    > > > and watched the pictures but I can't find the "PK Generation Strategy"
    > > > combobox in the Modeler.
    > > >
    > > > a) My Schema is
    > > >
    > > > table Employer
    > > > int idPerson (PFK)
    > > > int idcompany (PFK)
    > > >
    > > > table Person
    > > > int idPerson (PK)
    > > >
    > > > table Company
    > > > int idCompany (PK)
    > > >
    > > > b) My Cayenne mapping is
    > > >
    > > > DbEntity Employer's relationships:
    > > > toPerson (toDepPk checked)
    > > > toCompany (toDepPk checked)
    > > >
    > > > ObjectEntity Employer's relationships:
    > > > toPerson ("used for locking" not checked)
    > > > toCompany ("used for locking" not checked)
    > > >
    > > > c) My Java code is like:
    > > >
    > > > public Employer employer;
    > > > // note: person and company objects are fetched from two comboboxes of
    > > > DataObjects
    > > > .....
    > > > employer.setToPerson(person);
    > > > employer.setToCompany(company);
    > > > // I haven't registered employer. Did I have ?
    > > > dataContext.commitChanges();
    > > >
    > > > d) The error is:
    > > >
    > > > INFO QueryLogger: --- will run 2 queries.
    > > > INFO QueryLogger: --- transaction started.
    > > > INFO QueryLogger: SELECT NEXT_ID FROM AUTO_PK_SUPPORT WHERE TABLE_NAME
    > =
    > > > 'EMPLOYER'
    > > > INFO QueryLogger: *** error.
    > > > org.firebirdsql.jdbc.FBSQLException: GDS Exception.
    > > > 335544569. Dynamic SQL Error
    > > > SQL error code = -204
    > > > Table unknown
    > > > AUTO_PK_SUPPORT
    > > > At line 1, column 37.
    > > > at
    > > >
    > org.firebirdsql.jdbc.AbstractPreparedStatement.<init>(AbstractPreparedStatement.java:88)
    > > > ....
    > > >
    > > > e) Question is:
    > > >
    > > > Really I dont need to generate any pk because the table Employer has
    > only
    > > > two primary foreign keys, so I haven't create the AUTO_PK_SUPPORT table
    > in
    > > > my DB.
    > > > Well, I don't need that table but cayenne is looking for it, why ?
    > > > How I can solve that problem ?
    > > >
    > > >
    > > > Best wishes for the new year
    > > >
    > > > Andrea
    >



    This archive was generated by hypermail 2.0.0 : Mon Jan 02 2006 - 14:03:23 EST