1 Reply Latest reply on Mar 24, 2003 2:02 PM by adrian.brock

    missing primkey-field not caught during deployment of EJB

    tsangcn

      Hello,

      I am using JBoss 3.0.6. I have a CMP EJB with String as primary key. I have declared it in ejb-jar.xml as:

      ......
      <prim-key-class>java.lang.String</prim-key-class>
      ......

      But at first I forgot to put the line

      <primkey-field>keyID</primkey-field>

      So that means JBoss should not know which field is the primary key.
      But when I deploy the EJB, there are no errors.
      When I access the EJB, exception thrown saying that there is an error in the generated SQL.
      The DEBUG level of server.log showing that the generated SQL is

      SELECT FROM MY-TABLE

      Of course the root of the error is the missing of primary-field in ejb-jar.xml.
      But the second error is this mistake is not caught during deployment of the EJB.
      Is this the normal behavior? Or is there a bug in the deployment stage?

      Thanks
      CN

        • 1. Re: missing primkey-field not caught during deployment of EJ

          Sounds like a bug.

          Post it at http://www.sf.net/projects/jboss

          The dtd says

          The primkey-field element is not used if the primary key maps to
          multiple container-managed fields (i.e. the key is a compound key). In
          this case, the fields of the primary key class must be public, and
          their names must correspond to the field names of the entity bean
          class that comprise the key.

          The problem is that String has no public fields
          so it should fail. But this check is not present :-(

          Regards,
          Adrian