5 Replies Latest reply on Jun 30, 2002 2:46 PM by dsundstrom

    CMR doesn't work for me.

    abezafar

      I get the following error when trying to create a bean:

      14:58:04,751 ERROR [entity/License] Could not create entity
      java.sql.SQLException: Unexpected token: / in statement [INSERT INTO LICENSE (id, license_number, entity/User_license) VALUES (1, NULL, NULL)]
      at org.hsqldb.Trace.getError(Trace.java:180)
      at org.hsqldb.Result.(Result.java:175)
      at org.hsqldb.jdbcConnection.executeHSQL(jdbcConnection.java:907)
      at org.hsqldb.jdbcConnection.execute(jdbcConnection.java:718)
      at org.hsqldb.jdbcStatement.fetchResult(jdbcStatement.java:686)
      at org.hsqldb.jdbcStatement.executeUpdate(jdbcStatement.java:85)
      at org.hsqldb.jdbcPreparedStatement.executeUpdate(jdbcPreparedStatement.java:152)
      at org.jboss.resource.adapter.jdbc.local.LocalPreparedStatement.executeUpdate(LocalPreparedStatement.java:308)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.insertEntity(JDBCCreateEntityCommand.java:196)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.execute(JDBCCreateEntityCommand.java:131)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.createEntity(JDBCStoreManager.java:450)
      at org.jboss.ejb.plugins.CMPPersistenceManager.createEntity(CMPPersistenceManager.java:253)



      from ejb-jar:
      <ejb-relation>
      <ejb-relation-name>User-License</ejb-relation-name>
      <ejb-relationship-role>
      <ejb-relationship-role-name>user-has-license</ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>entity/User</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>license</cmr-field-name>
      </cmr-field>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>license-belongsto-user</ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>entity/License</ejb-name>
      </relationship-role-source>
      </ejb-relationship-role>
      </ejb-relation>


      from jbosscmp-jdbc.xml

      <ejb-relation>
      <ejb-relation-name>User-License</ejb-relation-name>
      <foreign-key-mapping>
      <ejb-relationship-role>
      <ejb-relationship-role-name>user-has-license</ejb-relationship-role-name>
      <foreign-key-fields/>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>license-belongsto-user</ejb-relationship-role-name>
      <foreign-key-fields>
      <foreign-key-field>
      <field-name>id</field-name>
      <column-name>license_id</column-name>
      </foreign-key-field>
      </foreign-key-fields>
      </ejb-relationship-role>
      </foreign-key-mapping>
      </ejb-relation>


      When I remove this relation from the two xml files the bean is created just fine. Please help because the error does not make much sense at all. I am attaching the xml files as well.

      Thank you,

        • 1. Re: CMR doesn't work for me.
          gzhong

          Wow, I am not alone. I also get a similar exception using Oracle. My JBoss container assumes a column name (god knows how) that is similar to the relationship name in my table! I don't know how to get rid of it and it is annoying.

          I am guessing that when JBoss3.0 or any software is released, developers must have tested the functionalities. So is there a list of things JBoss is compliant with EJB 2.0? If so, can developers show us their test samples as examples to follow? Because I have no idea how to do most of the things specific to JBoss and the JBoss doc is not available for JBoss 3 yet. All I have is a generic EJB book.

          G

          • 2. Re: CMR doesn't work for me.
            lcranford

            This is your problem...

            Defined in your ejb-jar file

            <ejb-name>entity/License</ejb-name>

            remove the forward slash

            <ejb-name>entityLicense</ejb-name>



            • 3. Re: CMR doesn't work for me.
              lcranford

              Oops,

              Sorry about that. Please ignore. I see it now

              • 4. Re: CMR doesn't work for me.
                abezafar

                The forward slash is not a problem. I have tested it without the forward slash, and I still get the same error. The problem is in the underlying mapping code. It is putting the foreign key in the wrong table.

                Please whoever did the coding for this part fix it, and let us know, because this is a major functionality of ejb2.0 and is simply not working.

                • 5. Re: CMR doesn't work for me.
                  dsundstrom

                  The problem is you have the keys on the wrong side of the relationship.