4 Replies Latest reply on Oct 24, 2002 10:27 AM by satria

    Create/Insert is incorrect. jboss3.0 RC1

    pandawong007 Newbie

      in my server.log i can see

      INSERT INTO ticket (ticket_id, org_id, assig
      ned_id, submitter_id, service_object_id, notified_date, last_mod_date, status, category, type, item, summary, priority, org_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
      2002-04-26 12:44:18,652 ERROR [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.TicketEJB] Could not create entity
      java.sql.SQLException: ERROR: Attribute 'org_id' specified more than once.


      My jbosscmp-jdbc has the following relation
      <ejb-relation>
      <ejb-relation-name>Org-Tickets</ejb-relation-name>
      <foreign-key-mapping />
      <ejb-relationship-role>
      <ejb-relationship-role-name>org-has-tickets</ejb-relationship-role-name>
      <key-fields>
      <key-field>
      <field-name>orgId</field-name>
      <column-name>org_id</column-name>
      </key-field>
      </key-fields>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>tickets-belongs-to-org</ejb-relationship-role-name>
      <key-fields />
      </ejb-relationship-role>
      </ejb-relation>


      Does anyone know whats going on?

        • 1. Re: Create/Insert is incorrect. jboss3.0 RC1
          pandawong007 Newbie

          I can create an entity bean if there is no relation. but i cant if a relationship exists.

          • 2. Re: Create/Insert is incorrect. jboss3.0 RC1
            Dain Sundstrom Master

            Change the name of the column.

            You can not map a cmr field to a cmp field or a cmr field to a pk column. Don't try it. It doesn't work.

            • 3. Re: Create/Insert is incorrect. jboss3.0 RC1
              satria Newbie

              > Change the name of the column.
              >
              > You can not map a cmr field to a cmp field or a cmr
              > field to a pk column. Don't try it. It doesn't work.

              hi dsundstrom,

              can you explain in more detail about your statement, because i got a similar problem and haven't been able to solve it, the problem is like this:
              in the server.log:
              2002-10-24 21:12:03,119 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.ProductInsEJB] Executing SQL: INSERT INTO tbl_prod_ins (prod_ins_id, invst_typ_id, principal_id, prod_ins_nm, investmentType, thePrincipal) VALUES (?, ?, ?, ?, ?, ?)

              while actually my tbl_prod_ins consist only the first 4 fields, and i dont have any idea where the last 2 fields are coming from.

              it happens since i tried to have a relationship between tbl_prod_ins and tbl_invst_typ(invst_typ_id, dscp) and tbl_principal(principal_id, dscp).

              fyi, i put in the jbosscmp-jdbc.xml:
              <ejb-relation>
              <ejb-relation-name>ProductIns-InvestmentType</ejb-relation-name>
              <ejb-relationship-role>
              <ejb-relationship-role-name>ProductIns-typeof-InvestmentType</ejb-relationship-role-name>
              Many
              <cascade-delete />
              <relationship-role-source>
              <ejb-name>ProductInsEJB</ejb-name>
              </relationship-role-source>
              <cmr-field>
              <cmr-field-name>investmentType</cmr-field-name>
              <cmr-field-type>java.util.Set</cmr-field-type>
              </cmr-field>
              </ejb-relationship-role>

              <ejb-relationship-role>
              <ejb-relationship-role-name>InvestmentType-has-ProductIns</ejb-relationship-role-name>
              One
              <relationship-role-source>
              <ejb-name>InvestmentTypeEJB</ejb-name>
              </relationship-role-source>
              </ejb-relationship-role>
              </ejb-relation>

              <ejb-relation>
              <ejb-relation-name>ProductIns-ThePrincipal</ejb-relation-name>
              <ejb-relationship-role>
              <ejb-relationship-role-name>ProductIns-owned-by-ThePrincipal</ejb-relationship-role-name>
              Many
              <cascade-delete />
              <relationship-role-source>
              <ejb-name>ProductInsEJB</ejb-name>
              </relationship-role-source>
              <cmr-field>
              <cmr-field-name>thePrincipal</cmr-field-name>
              <cmr-field-type>java.util.Set</cmr-field-type>
              </cmr-field>
              </ejb-relationship-role>

              <ejb-relationship-role>
              <ejb-relationship-role-name>ThePrincipal-has-ProductIns</ejb-relationship-role-name>
              One
              <relationship-role-source>
              <ejb-name>ThePrincipalEJB</ejb-name>
              </relationship-role-source>
              </ejb-relationship-role>
              </ejb-relation>

              any idea?

              .satria.

              • 4. Re: Create/Insert is incorrect. jboss3.0 RC1
                satria Newbie

                oopss sorry that one is in my ejb-jar.xml
                while in my jbosscmp-jdbc.xml:
                <ejb-relation>
                <ejb-relation-name>ProductIns-InvestmentType</ejb-relation-name>
                <foreign-key-mapping/>
                <ejb-relationship-role-name>ProductIns-typeof-InvestmentType</ejb-relationship-role-name>
                <key-fields>
                <key-field>
                <field-name>investmentType</field-name>
                <column-name>invst_typ_id</column-name>
                </key-field>
                </key-fields>

                <ejb-relationship-role-name>InvestmentType-has-ProductIns</ejb-relationship-role-name>
                <key-fields>
                </key-fields>
                </ejb-relation>

                <ejb-relation>
                <ejb-relation-name>ProductIns-ThePrincipal</ejb-relation-name>
                <foreign-key-mapping/>
                <ejb-relationship-role-name>ProductIns-owned-by-ThePrincipal</ejb-relationship-role-name>
                <key-fields>
                <key-field>
                <field-name>thePrincipal</field-name>
                <column-name>principal_id</column-name>
                </key-field>
                </key-fields>

                <ejb-relationship-role-name>ThePrincipal-has-ProductIns</ejb-relationship-role-name>
                <key-fields>
                </key-fields>
                </ejb-relation>

                .satria.