db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Trudgett, Glen" <Glen.Trudg...@det.nsw.edu.au>
Subject RE: obtaining native primary keys problem
Date Sun, 02 Mar 2003 22:38:48 GMT
Thanks Eric,

That appears to solve my problems, as I am able to populate the foreign key
table.

I understand now why the key was not accessible. 

Thanks to all the others for the contributions.

Regards,

Glen Trudgett 
Unix system administration 
Information Technology Bureau 
Department of Education and Training 
Level 2, 39A Herbert St, St Leonards, NSW 2065 Australia 
Tel: 61+ (2) 99429970 Fax: 61+ (2) 99429600 

**********************************************************************
This message is intended for the addressee named and may contain
privileged information or confidential information or both. If you
are not the intended recipient please delete it and notify the sender.
**********************************************************************



-----Original Message-----
From: Eric Emminger [mailto:eric@ericemminger.com] 
Sent: Saturday, 1 March 2003 1:50 AM
To: Turbine Torque Users List
Subject: Re: obtaining native primary keys problem


Glen

If I'm reading your code correctly, your method
public void insert(String filename)
is on Pac. Is that right?

The reason your code isn't working is that the "insert" instance of Pac 
in the insert() method is a local variable. So, when you call

test.insert("blah");
test.getPrimaryKey();

getPrimaryKey() returns 0 because it is 0.

You can fix this by changing your method signature to return an int 
value of the new primary key.

     public int insert(String filename)
     {
         Pac insert = new Pac();
         try
         {
             insert.setFilename(filename);
             insert.save();
         }
         catch (Exception e)
         {
             e.printStackTrace();
         }
         return insert.getPrimaryKey();
     }

Does that help?

Eric


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org

**********************************************************************
This message is intended for the addressee named and may contain
privileged information or confidential information or both. If you
are not the intended recipient please delete it and notify the sender.
**********************************************************************

Mime
View raw message