7 Replies Latest reply on Apr 18, 2002 4:54 PM by dsundstrom

    Progress on complex primary keys using one or more cmr-field

    mcauleyt

      I see this is discussed every now and then and I was wondering what the progress on it was.

      I have convinced a few people here to change our design and remove references of pk and fk within the entity beans so that we can use CMP 2.0 properly and abstract above the database layout.

      However some of our entity beans have a primary key made up of references to other beans and therefore I have hit the above problem... which is now kind of defeating the idea of abstracting above the database.

      Any help, or hints about how to get around this would be greatfully received.

      A quick description of the actual problem is below.

      Many thanks,

      Tim

      ---
      I have three entity beans (cut down for simplicity)

      Member:
      Integer memberPk
      String name

      SomeInformation:
      Long someInformationPk
      String dialog

      MemberInformation
      Member member
      SomeInformation information
      Date timeCreated

      I have created a class called MemberInformationPk to represent the key for the MemberInformation.

      JBoss is having trouble generating a suitable create statement for the table MemberInformation when formatting the constraint.

      ----
      [16:21:07,250,CMP] Start command executing: CREATE TABLE MEMBER_INFORMATION (TIME_CREATED TIMESTAMP, MEMBER_PK INT4, SOME_INFORMATION_PK INT8, CONSTRAINT pkMEMBER_INFORMATION PRIMARY KEY ())

      [16:21:07,962,PostgresDS] Pool PostgresDS [0/0/10] destroyed object org.jboss.resource.adapter.jdbc.local.JDBCManagedConnection@5b0e2c.[16:21:07,962,CMP] java.sql.SQLException: ERROR: parser: parse error at or near ")"

      [16:21:07,962,CMP] Could not create table MEMBER_DIALOG_CLUSTER
      java.sql.SQLException: ERROR: parser: parse error at or near ")"

      at org.postgresql.Connection.ExecSQL(Connection.java:533)
      at org.postgresql.jdbc2.Statement.execute(Statement.java:294)
      at org.postgresql.jdbc2.Statement.executeUpdate(Statement.java:78)
      at org.postgresql.jdbc2.PreparedStatement.executeUpdate(PreparedStatement.java:122)
      at org.jboss.resource.adapter.jdbc.local.PreparedStatementInPool.execute