3 Replies Latest reply on Sep 9, 2003 2:01 PM by Juha Lindfors

    Auto-increment / jboss 3.2.1 / Hypersonic / template no foun

    webguy Newbie

      Hi, I'm just messing about with the Jboss-ejb-workbook from O'reilly, and I'm changing one of the entitybeans to use a auto-increment, with the Hypersonic SQL database.

      I've added the <auto-increment/> and

      <!-- retrieves generated key of the record inserted into hsql db -->
      <entity-command name="hsqldb-fetch-key"
      class="org.jboss.ejb.plugins.cmp.jdbc.hsqldb.JDBCHsqldbCreateCommand"/>

      to the jbosscmp-jdbc.xml

      I'm getting the error "Template not found" in the console when I deploy it to Jboss.

      I'm guessing I'm missing a jar in the servers/default/lib?
      That right? What one?

      2 more questions on key generation. Is there a classes with Jboss that I can use to do

      a)HIGH-LOW
      b)GUID/UUID

      I'm guessing uuid-key-generator.sar has something to do with that..

      Also if I want to plugin a custom class that does generation, what do I need to do?

      Thanks WG

        • 1. Re: Auto-increment / jboss 3.2.1 / Hypersonic / template no
          webguy Newbie

          Ok here is an update. It seems you need to overwrite the defult Hypersonic settings adding the pk-template .

          In addition the XML declaration for the DTD (jboss-jdbc 3.2) need to be commented out as the it doesn't include the pk entity and will cause deployment to fail, with a XML Validation error.

          You can just use <entity-command name="hsqldb-fetch-key"/> in place of the longer declaration as above..

          • 2. Re: Auto-increment / jboss 3.2.1 / Hypersonic / template no
            brian_lind Newbie

            Had this problem as well. The error says exactly what it means. I had to add an <auto-increment-template>?1 IDENTITY</auto-increment-template> tag to the <type-mapping> section for Hypersonic SQL in the standardjbosscmp-jdbc.xml file. This isn't documented in the JBoss 3.2.1 Admin Devel book, so I looked at the other database type-mappings and the docs for Hypersonic SQL. You also have to make sure the "pk-constraint" attribute for your entity bean, with an auto-incrementing primary key, is set to "false" or Hypersonic will complain that you're trying to create more than one primary key when JBoss goes to auto create your database table. After that you need to add <auto-increment/> to your PK field and <entity-command name="hsqldb-fetch-key"/> to your entity bean and it should work for Hypersonic SQL. Worked for me.
            By the way the MySQL type-mapping already has the auto-increment-template setup and ready to go, while the database that comes with JBoss doesn't. Sounds like an big oversite.

            • 3. Re: Auto-increment / jboss 3.2.1 / Hypersonic / template no
              Juha Lindfors Master

              Please submit a patch for the hypersonic configuration for this on sourceforge: http://sourceforge.net/tracker/index.php?func=detail&aid=551165&group_id=22866&atid=376687

              -- Juha