0 Replies Latest reply on Sep 23, 2003 7:13 PM by bontempo

    Oracle CMP : auto-increment template not found

    bontempo Newbie

      I'm using JBoss 3.2.1 & Oracle 9i + DataDirect JDBC 3.3 and i'm getting an error when deploying a bean wiith the <auto-increment/> option.


      EJB CODE :

      ...
      public Integer ejbCreate(SiteImageDTO data) throws CreateException {
      // Just to force ejbPostCreate call
      this.setId(new Integer(0));
      this.setIdSite(new Integer(data.getIdSite()));
      return null;
      }


      public void ejbPostCreate(SiteImageDTO data) throws CreateException {
      data.setId(getId());
      }

      // SETTERS ---------------------------------------------------
      public abstract Integer getId();
      public abstract Integer getIdSite();

      // SETTERS ---------------------------------------------------
      public abstract void setId(Integer id);
      public abstract void setIdSite(Integer idSite);
      ...


      EJB-JAR.XML :


      <display-name>SiteImages</display-name>
      <ejb-name>SiteImages</ejb-name>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.Integer</prim-key-class>
      False
      <cmp-field>
      <field-name>id</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>idSite</field-name>
      </cmp-field>
      <primkey-field>id</primkey-field>



      JBOSSCMP-JDBC.XML :


      java:/OracleDS
      <datasource-mapping>Oracle9i</datasource-mapping>
      <preferred-relation-mapping>foreign-key</preferred-relation-mapping>



      <ejb-name>SiteImages</ejb-name>
      <table-name>SITEIMAGES</table-name>
      <entity-command name="get-generated-keys" class="org.jboss.ejb.plugins.cmp.jdbc.jdbc3.JDBCGetGeneratedKeysCreateCommand" />
      <cmp-field>
      <field-name>id</field-name>
      <column-name>ID</column-name>
      <jdbc-type>INTEGER</jdbc-type>
      <sql-type>INTEGER</sql-type>
      <auto-increment/>
      </cmp-field>
      <cmp-field>
      <field-name>idSite</field-name>
      <column-name>ID_SITE</column-name>
      </cmp-field>



      I get an error on deployment :
      java.lang.IllegalStateException: auto-increment template not found

      The ID column primary key is generated using a trigger in the database.

      If I remove the <auto-increment/> does the normal deployment but when run, I get a ClassCastException because Jboss is getting the ROWID instead of the ID column.

      I could find this in the logs by :

      2003-09-24 01:44:08,021 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.jdbc3.JDBCGetGeneratedKeysCreateCommand.SiteImages] Created: pk=AAAG8pAAJAAAAEuAAK
      2003-09-24 01:44:08,151 ERROR [org.jboss.ejb.plugins.LogInterceptor] TransactionRolledbackLocalException, causedBy:
      java.lang.ClassCastException
      at com.oecm.base.ejb.beans.site.SiteImagesBean$Proxy.getId()



      Can anyone please give me a help on this ? I working on this for 3 days...


      THANKS