Re: reverse engineering a postgresql database: no relationships detected?

From: Cris Daniluk (cris.danilu..mail.com)
Date: Mon Mar 13 2006 - 12:23:38 EST

  • Next message: Ingo Feulner: "Re: [ANN] Cayenne entered Apache incubator"

    Actually, it looks like that was just an odd coincidence. The real issue
    here is that getExportedKeys does not return all of the FKs for a
    relationship in Postgres (In fact, I think this is true in for all drivers).
    This confirms my suspicion that we have a Cayenne problem rather than a JDBC
    problem. When doing a reverse engineer that does not overwrite every table (
    i.e. using "skip"), relationships that exist between a loaded and skipped
    table will not be loaded if the skipped table is the FK source.

    Andrus - This is a bit of a complicated issue. I think it is critical that
    we load both the source and target relationships for a table on reverse
    engineer. The current behavior only loads exported FKs for a table, relying
    on a comprehensive reverse engineer to pick up the rest. We could handle
    this by calling getImportedKeys on every table as well, and using some
    clever merge support to avoid double-loading relationships, but I think
    that's a biiig change.

    It seems like the least invasive option is to add a secondary pass to load
    target relationships for tables that were not skipped, by scanning
    relationships in tables that were skipped. This could be as simple as just
    tracking DbEntities that were skipped in a set and taking a pass through the
    relationships for matches to non-skipped entities. Thoughts?

    Cris

    On 3/13/06, Cris Daniluk <cris.danilu..mail.com> wrote:
    >
    > Very interesting... I have a little test case setup and it actually
    > appears that it successfully imports only when the PK and FK column names
    > match.
    >
    > Still too early to say if this is the problem and why, but it is
    > interesting nonetheless.
    >
    >
    > On 3/11/06, WONDER <mmmmmmmmm5..eb.de> wrote:
    > >
    > > Well, I dont know about the solution in Cayenne.
    > > this is my env.
    > > sun-jdk 1.5.0.06
    > > postgresql 8.1.3
    > > cayenne 1.2M11
    > > jdbc driver 8.2dev-501 JDBC 3 // Do you use beta? or you mean 5.01??
    > > Yours 8.2dev-510.jdbc3
    > > http://jdbc.postgresql.org/download.html
    > >
    > > Windows. // however this is java.
    > >
    > >
    > > "It works with an empty project "
    > > I have table and model wihtout relations in db. I added relations to db
    > > and reengineerd. I see now the relations in the Cayenne GUI.
    > > I alos added completely new table with relationships with an old table
    > > and reengineerd the model.
    > > It works here.
    > >
    > > I see the relations twice even now like
    > > --------------------------------------
    > > Old Table Artist
    > > New Table test
    > >
    > > After reengineer
    > >
    > > Old Table Artist
    > > toArtist
    > > toArtist1 // I think this should be cleaned in Cayenne.
    > >
    > > New Table test
    > > toArtist
    > >
    > > --------------------------------------
    > >
    > >
    > > If you mean this doesnt work for you, i would update to 1.2M11 first.
    > >
    > > Sako.
    > >
    > >
    > >
    > >
    > >
    > > ----- Original Message -----
    > > *From:* Tomi NA <hefes..mail.com>
    > > *To:* cayenne-use..bjectstyle.org
    > > *Sent:* Saturday, March 11, 2006 6:25 PM
    > > *Subject:* Re: reverse engineering a postgresql database: no
    > > relationships detected?
    > >
    > > On 3/11/06, WONDER < mmmmmmmmm5..eb.de> wrote:
    > > >
    > > > Hello,
    > > >
    > > > I am not sure if i understand you.
    > > > I am using PostgreSQL 8.1.3 with the jdbc 8.2dev-501 JDBC 3
    > > > and already imported tables with thier relationships!
    > > >
    > > > Try to update the server/jdbc and if now maybe you ask again to send
    > > > the other settings.
    > > >
    > > > Sako.
    > > >
    > >
    > > I'm updating postgresql to 8.1.3 as I write this: I'll see what I come
    > > up with.
    > > As for other relevant information, here's my environment description:
    > > sun-jdk 1.5.0.06
    > > postgresql 8.1.2
    > > cayenne 1.2M10
    > > jdbc driver 8.2dev-510.jdbc3
    > > gentoo linux, custom 2.6.15 kernel
    > >
    > > Status update:
    > > I've just upgraded pgsql from 8.1.2 to 8.1.3 and now reengineering
    > > works. Sort of. It works with an empty project (=the first time it's
    > > called). If I add a test table referencing an existing table in the database
    > > and try to reengineer, I see the same behaviour as before.
    > > I'd say this suggest that we should look for a solution in the cayenne
    > > code, instead of the pgsql-jdbc code.
    > >
    > > Tomislav
    > >
    >
    >



    This archive was generated by hypermail 2.0.0 : Mon Mar 13 2006 - 12:23:39 EST