0 Replies Latest reply on Jul 22, 2004 9:54 AM by Matthias Fraass

    Solved: Firebird, XDoclet and autoincrement

    Matthias Fraass Newbie


      maybe this could come in hand for anyone who wants to use Firebird-incremented IDs with CMP and XDoclet:

      Supposing you have a table with the PK "ID" as an int:

      1. You have to create a generator for each table:

      create generator gen_TABLENAME;

      2. Tell jBoss via XDoclet that the new ID is generated via the generator:
       * @jboss.unknown-pk
       * class = "java.lang.Integer"
       * column-name="id"
       * auto-increment = "true"
       * @jboss.entity-command
       * name="pk-sql"
       * @jboss.entity-command-attribute
       * name="pk-sql"
       * value="SELECT gen_id( gen_TABLENAME, 1 ) from RDB$DATABASE;"

      That's it!

      1. There's no Firebird-Keygen-Plugin like "mysql-get-generated-keys" plus "org.jboss.ejb.plugins.cmp.jdbc.keygen.JDBCMySQLCreateCommand".
      2. The "get-generated-keys"-method does not work because the Firebird JDBC driver is not JDBC30-ready yet:
       public synchronized PreparedStatement prepareStatement(String param1, int param2)
       throws SQLException
       throw new SQLException("not yet implemented");

      But in the future this would be the better solution.