db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From JDigg...@genelogic.com
Subject Re: PK-generation problems using Oracle seqs
Date Fri, 06 Dec 2002 16:42:30 GMT

Looked at MapBuilder.vm I see the below:

        #if ($table.IdMethod == "native")
        tMap.setPrimaryKeyMethod(TableMap.NATIVE);
        #elseif ($table.IdMethod == "autoincrement")
        tMap.setPrimaryKeyMethod(TableMap.AUTO_INCREMENT);
        #elseif ($table.IdMethod == "sequence")
        tMap.setPrimaryKeyMethod(TableMap.SEQUENCE);
        #elseif ($table.IdMethod == "idbroker")
        tMap.setPrimaryKeyMethod(TableMap.ID_BROKER);
        #else
        tMap.setPrimaryKeyMethod("$table.IdMethod");
        #end

        #if ($table.IdMethodParameters)
          // this might need upgrading based on what all the databases
          // need, but for now assume one parameter.
          #set ($imp = $table.IdMethodParameters.get(0) )
          tMap.setPrimaryKeyMethodInfo("$imp.Value");
        #elseif ($table.IdMethod == "idbroker")
        tMap.setPrimaryKeyMethodInfo(tMap.getName());
        #elseif ($table.IdMethod == "sequence" ||
      ($table.IdMethod == "native" && $dbprops.get("idMethod")
== "sequence"))
        tMap.setPrimaryKeyMethodInfo("$table.SequenceName");
        #elseif ($table.IdMethod == "native" && $dbprops.get("idMethod")
== "identity")
        tMap.setPrimaryKeyMethodInfo("$table.Name");
        #end

This seems to me that if one's defaultIdMethod is 'native' and one doesn't
put in any table idMethod indicators that the setPrimaryKeyMethodInfo will
never get run for this table map (which seems to be my problem). Acc. to
this logic flow one would have to manually set each table to be 'native'
and the database method to be 'sequence' which makes no sense to me at all
(not to mention a post in the archives that suggests dbprops isn't in scope
in this file on which I cannot comment) ... can someone enlighten me on
this program flow in map generation? Many thanks ...
-j

-------------------------------------------------
James Diggans
Bioinformatics Programmer
Gene Logic, Inc.
Phone: 301.987.1756
FAX: 301.987.1701




                                                                                         
                
                      JDiggans@genelogi                                                  
                
                      c.com                    To:       "Torque"                        
                
                                                <turbine-torque-user@jakarta.apache.org>
                 
                      12/05/2002 07:57         cc:                                       
                
                      PM                       Subject:  PK-generation problems using Oracle
seqs         
                      Please respond to                                                  
                
                      "Turbine Torque                                                    
                
                      Users List"                                                        
                
                                                                                         
                
                                                                                         
                




All, I have a method (in turbine) that attempts to write a new object to a
torque O/R database (using torque 3.0rc2) and it's having problems w/
primary key generation using 'native' Oracle sequences for the pk keygen
(ID_TABLE IDs work fine).

Here's the table definition (the defaultIdMethod for the <database> is
'native'):

<!-- s: C V _ S P E C I E S  T A B L E -->
<table name="CV_SPECIES" description="Controlled vocabulary for species">
      <column name="species_id" required="true" primaryKey="true"
            type="INTEGER" description="Primary key for species table"/>
      <column name="name" required="true" type="VARCHAR" size="25"
            description="Species name"/>
      <unique>
            <unique-column name="name"/>
      </unique>
</table>
<!-- e: C V _ S P E C I E S  T A B L E -->

the method:

    public void doInsert(RunData data, Context context) throws Exception {
        CvSpecies entry = new CvSpecies();
        data.getParameters().setProperties(entry);
        entry.setNew(true);
        entry.save();
    }

and the error I'm getting:

java.lang.reflect.InvocationTargetException
..... <lots of reflection stuff>
Caused by: org.apache.torque.TorqueException:
ORA-01400: cannot insert NULL into
("GX_NODEDB10"."CV_SPECIES"."SPECIES_ID")
      at org.apache.torque.util.BasePeer.doInsert(BasePeer.java:729)
      at
com.genelogic.nodedb.om.BaseCvSpeciesPeer.doInsert(BaseCvSpeciesPeer.java:192)

      at
com.genelogic.nodedb.om.BaseCvSpeciesPeer.doInsert(BaseCvSpeciesPeer.java:475)

      at com.genelogic.nodedb.om.BaseCvSpecies.save(BaseCvSpecies.java:779)
      at com.genelogic.nodedb.om.BaseCvSpecies.save(BaseCvSpecies.java:741)
      at com.genelogic.nodedb.om.BaseCvSpecies.save(BaseCvSpecies.java:721)
      at
com.genelogic.nodedb.modules.actions.admin.species.SpeciesFormActions.doInsert(SpeciesFormActions.java:45)

      ... 48 more

It looks to me like the primary key, for some reason, is not getting
generated. I have no idea why, the sequence is in the database and has not
yet been touched so whatever method the BasePeer class is supposed to run
to get the new ID doesn't seem to be happening. This is my first attempt
using native sequences w/ torque ... anyone have any suggestions? My thanks
...
-j

-------------------------------------------------
James Diggans
Bioinformatics Programmer
Gene Logic, Inc.
Phone: 301.987.1756
FAX: 301.987.1701



--
To unsubscribe, e-mail:   <
mailto:turbine-torque-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <
mailto:turbine-torque-user-help@jakarta.apache.org>







Mime
View raw message