5 Replies Latest reply on Mar 13, 2002 2:08 PM by dsundstrom

    CMP2 table name generation

    scoy

      Hi,

      In lines 261-3 of JDBCEntityMetaData.java, we have the lines:

      // we replace the . by _ because some dbs die on it...
      // the table name may be overridden in importXml(jbosscmp-jdbc.xml)
      tableName = entityName.replace('.', '_');

      As far as I can work out from the source, the entityName is the ejb-name, which typically contains '/' rather than '.' characters.

      I think this is right because the JBoss JNDI implementation uses '/' for path separators and the ejb-name is a JNDI name.

      Changing the code above fixed one problem I had, but I'm still tracking down a similar issue with composite table names.

      You only get this btw, if you run without a jbosscmp-jdbc.xml file.

        • 1. Re: CMP2 table name generation
          dsundstrom

          It is good to see that you are reading the source.

          The entityName should not contain the '/' character, as this would cause problems with JNDI. Are you putting a '/' character in your ejb-name field? If you are, you should remove it. If you are doing this to get your entity bound into a specific place in the JNDI tree, specify this in the jboss.xml file.

          • 2. Re: CMP2 table name generation
            scoy

            Thanks.

            If this is the case then the xdoclet sample code is wrong.

            For example, their AccountBean.java example contains:

            @ejb:bean name="bank/Account"

            A quick check of the J2EE spec reveals:

            "The ejb-name must be a valid Java identifier and must be unique within the ejb-jar file."

            So that's quite clear now. It looks like its time to join yet another mailing list...

            • 3. Re: CMP2 table name generation
              dsundstrom

              > "The ejb-name must be a valid Java identifier and
              > must be unique within the ejb-jar file."

              That means that dot is not a valid character either.

              • 4. Re: CMP2 table name generation
                scoy

                That depends upon whether or not packagename.Classname.memberName is considered to be a valid java identifier or not. It's a job for a language lawyer.

                I reported a bug in xdoclet for the sample code btw.

                • 5. Re: CMP2 table name generation
                  dsundstrom

                  > That depends upon whether or not
                  > packagename.Classname.memberName is considered to be
                  > a valid java identifier or not. It's a job for a
                  > language lawyer.

                  Not really. Section 3.8 of the JLS is very clear that a '.' character is not allowed in an indentifier. see http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#40625

                  > I reported a bug in xdoclet for the sample code btw.

                  cool