4 Replies Latest reply on Nov 22, 2002 3:40 PM by Alex Bereshny

    Error: One to Many Relationship

    Alex Bereshny Newbie

      Hello,

      JBoss3.0.3
      MSSQL 7.0

      I'm trying to get a new entity bean working that has a one to many relationship...

      bidItem table
      primary keys are company_no, bid_id_no, bid_item_no

      bidHeader tables
      primary keys are company_no, bid_id_no

      The error I'm getting is saying that I have company_no twice in the column list here is the error:
      Column name 'company_no' appears more than once in the result column list.

      Can anyone help with this I will attach my jboss-cmp relationship for the two tables thanks in advance....
      Alex

        • 1. Re: Error: One to Many Relationship
          Santhana Tamil Selvan Newbie

          That's because
          You must be using the same field as CMP as well as CMR field. That's the problem.. we had the same problem a week back..
          There is a solution for this as well.
          In JBoss the foreign key u have mapped in <key-field> and <column-name> will create a CMP field automatically(default behaviour of JBoss)..

          You will have two entities having the same Key right!
          So remove the CMP-field u have specified in one of the entities, where u don't have the same key as Primary key..

          Hope this helps

          • 2. Re: Error: One to Many Relationship
            Alex Bereshny Newbie

            Thank you for your response can you post an example of your tables and the relationship in the jbosscmp-jdbc.xml because when I try your suggestion to remove the cmp-field I get an
            error saying that Invalid column name 'bidIdNo' but bid_id_no is the column name not bidIdNo thats the field name....

            thanks for your help

            • 3. Re: Error: One to Many Relationship
              Alex Bereshny Newbie

              Well I'm still having a problem with two column names being the same name....

              Well I have attached my jbosscmp-jdbc.xml, and ejb-jar.xml.

              I have a compoud primary so I have a primary key class everything deploys fine but when I run the client which is supposed to enter a item for the header it fails and says I have two companyNo columns listed. The relationship I have an entity bean called bidHeader and a bidItem entity bean it's a one to many relationship....

              I also don't like I have a cmr field mapped to a cmp-field you can look at the attached files I just posted the code that I'm working with in this example thanks for any help.
              Alex

              • 4. Re: Error: One to Many Relationship
                Alex Bereshny Newbie

                Sorry this are the files....