I am using Oracle with native id generation without a problem.  

First, I need to make sure that you are creating a new instance of your OM object, 
populating it, and then calling the save() method.  You primary key will not be 
generated until you call the save() method.  

I have not tried getPrimaryKey() but instead I use getUserID() (depending on the 
object!).  It should work just the same though.  

If you are still having problems, check your generated om.map class for the 
corresponding object that you are having problems with.  Here is a code snippet from 
one of my map objects:

    /**
     * The doBuild() method builds the DatabaseMap
     *
     * @throws TorqueException
     */
    public void doBuild() throws TorqueException
    {
        dbMap = Torque.getDatabaseMap("default");

        dbMap.addTable("AGENT");
        TableMap tMap = dbMap.getTable("AGENT");

        tMap.setPrimaryKeyMethod(TableMap.NATIVE);   <<<<  This is the important line

        tMap.setPrimaryKeyMethodInfo("AGENT_SEQ");

If your map object is being generated incorrectly, let me know and I will help you 
track it down.

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
> Sent: Friday, February 28, 2003 5:22 AM
> To: Turbine Torque Users List
> Subject: RE: obtaining native primary keys problem
> 
> 
> Hi
> 
> I'm working on the same problem at the moment. I've had a 
> closer look at code of torque and village and as far as I can 
> see it's not possible to use 'native' pk generation right now.
> 
> The Torque code only provides AutoIncrementIdGenerator and 
> SequenceIDGenerator. Therefore as soon as you use 'native' 
> mode there's no IDGenerator available and the implementation 
> will fail with an 'IDGenerator is NULL' TorqueException.
> 
> I've just removed the check for the IDGenerator and insertion 
> now works (at least if you do NOT need the assigned primary 
> key the database provides). But I think that's exactly what 
> you want. I'm currently working on this. Looks like the 
> village code has not foreseen this situation.
> 
> Probably a workaround would be using Sequences generated by 
> your oracle database. As I'm using db2 and the db2adapter 
> implementation uses ID_METHOD.NONE this will not work for me 
> without any modifications.
> 
> The fascinating thing is: this bug has been tracked on 
> 09/29/2002 and is status is still 'new' !
> 
> 
> Cheerz
> 
> Alex
> 
> 
> 
> > The packey is automagically created using torques "native" 
> primary key 
> > selection.
> > 
> > Glen
> > 
> > 
> > 
> > -----Original Message-----
> > From: Richard Grossman [mailto:[EMAIL PROTECTED]
> > Sent: Thursday, 27 February 2003 7:05 PM
> > To: Turbine Torque Users List
> > Subject: Re: obtaining native primary keys problem 
> > 
> > 
> > How do you made the insert ??
> > How this key is generated do you use sequence object ?
> > 
> > Richard
> > ----- Original Message -----
> > From: "Trudgett, Glen" <[EMAIL PROTECTED]>
> > To: "'Turbine Torque Users List'" <[EMAIL PROTECTED]>
> > Sent: Thursday, February 27, 2003 02:24
> > Subject: RE: obtaining native primary keys problem
> > 
> > 
> > > To All,
> > >
> > >
> > > I currently have an Oracle DB that I am using for my data.
> > >
> > > I have set my tables to have natively generated primary 
> keys, which
> > > works fine.
> > >
> > > I do an insert of information into a table, and the table happily
> > > accepts the data, as expected.
> > >
> > > test.insert("blah");
> > >
> > > Table
> > > 1, blah
> > >
> > > When I try to obtain the primary key for this new entry, which I 
> > > want
> > > to
> > use
> > > to populate a foreign key link table, using
> > >
> > > Test.getPrimaryKey();
> > >
> > > I receive a value of 0. (Not the value of 1 or whatever 
> number it is
> > > allocated!!)
> > >
> > > I can not work out why I can not get these values. I have tried a
> > > number
> > of
> 
> -- 
> +++ GMX - Mail, Messaging & more  http://www.gmx.net +++
> Bitte l�cheln! Fotogalerie online mit GMX ohne eigene Homepage!
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to