JBoss/ CMR: Entity-Bean where a FK is a PK

Discussions

EJB programming & troubleshooting: JBoss/ CMR: Entity-Bean where a FK is a PK

  1. JBoss/ CMR: Entity-Bean where a FK is a PK (2 messages)

    Hi!

    I want to develope 2 Entity-Beans that are in
    a 1-0..1 Relation unsing the Primary Key of on Bean
    as Foreign Key.

    My Beans look like this:
    Document (documentId [PK], name)
    HtmlDocument (documentId [PK and FK], htmlCode)

    Please note, that HtmlDocument.documentId is a PK and a FK.

    When I create a new HtmlDocument, JBoss reports an error, as it tries to run the following query against the DB:
    INSERT INTO htmldocument (documentId, htmlText, documentid) VALUES (-1, 'test-html-code', null)

    (Note, that the columun documentId is mentioned twice in the query).

    Is there a solution for this Problem ?

    I use JBoss 3.2.1/ PostgreSQL and XDoclet.

    Best Regards,
    Manfred
  2. Hi

      I really cannot get the situation you are dealing with. Explain in more detail the relationship that you want to have between a Document and a HtmlDocument. Maybe if you describe the tables you are using and the relation between them.
  3. Sorry - The Bug was between the screen and the chair ...

    The problem was, that I used documentId as the
    column-name of the PK and documentid (lower-case id) for
    the column-name of the FK.

    Therefore, JBOSS created a SQL-INSERT like this:
    insert into htmldocument(documentId, name, documentid) values ...

    Best Regards,
    Manfred