Title: Troubles configuring SEQUENCE keyGen with Oracle9i

Hi,

I have defined following simple mapping:

<!DOCTYPE databases PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN" "http://castor.exolab.org/mapping.dtd">
<mapping>
 
  <!-- Mapping for LargeSenderJdo -->
  <class name="LargeSenderJdo"
         identity="id" key-generator="OPTIO_AUTOGEN">
    <map-to table="OPI_T_LARGESENDER"/>
    <field name="id" type="string">
      <sql name="ID" type="varchar"/>
    </field>        
    <field name="contractNumber" type="string">
      <sql name="CONTRACT_NO" type="varchar"/>
    </field>        
    <field name="domainName" type="string">
      <sql name="DOMAIN" type="varchar"/>
    </field>
  </class>
 
  <!-- Mapping for ApplicationGroupJdo -->
  <class name="ApplicationGroupJdo"
         identity="id">
    <map-to table="OPI_T_APPGROUP"/>
    <field name="id" type="string">
      <sql name="ID" type="varchar"/>
    </field>
    <field name="descriptionFr" type="string">
      <sql name="DESCR_FR" type="varchar"/>
    </field> 
    <field name="descriptionNl" type="string">
      <sql name="DESCR_NL" type="varchar"/>
    </field> 
  </class>
 
  <!-- Commonly used key generator -->
  <key-generator name="SEQUENCE" alias="OPTIO_AUTOGEN">
    <param name="trigger" value="true"/>
  </key-generator>

</mapping>

I also have written an OQL query for retrieving LargeSenderJdo objects. This query works fine AS LONG AS I don't include the "key-generator" attribute in

the LargeSenderJdo mapping above. However as soon as I include it, I always get following exception while executing my query:

org.exolab.castor.jdo.QueryException: Could not find mapping for class LargeSenderJdo
        at org.exolab.castor.jdo.oql.ParseTreeWalker.checkFromPart(Unknown Source)
        at org.exolab.castor.jdo.oql.ParseTreeWalker.checkErrors(Unknown Source)
        at org.exolab.castor.jdo.oql.ParseTreeWalker.<init>(Unknown Source)
        at org.exolab.castor.jdo.engine.OQLQueryImpl.create(Unknown Source)
        at org.exolab.castor.jdo.engine.DatabaseImpl.getOQLQuery(Unknown Source)
        ...

Does anybody has an idea what I'm doing wrong in the mapping configuration?
I'm using Oracle 9i and a trigger is defined on the table. This trigger generates a unique identifier for all the tables I use. In case it could be interesting, I also included the definition of the trigger below:

Thanks in advance for your help,
Christophe Vienne


The Oracle trigger creation script on the OPT_T_LARGESENDER table:

CREATE OR REPLACE TRIGGER opi_t_largesender_b_i_r
BEFORE INSERT
ON opi_t_largesender
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
BEGIN
IF :NEW.ID IS NULL THEN
  SELECT OPI_P_GUID.f_generate()
  INTO :NEW.ID
  FROM DUAL;
NULL;
END IF;
END;

where OPI_P_GUID.f_generate() is the generator algorithm.

Reply via email to