db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Hughes <mhu...@uvic.ca>
Subject Re: Example problem
Date Mon, 23 May 2005 20:29:58 GMT
Carl Ludewig wrote:
> I'm using Torque 3.1.1 and Postgresql and have run into a problem 
> related to this thread of discussion. Something seems to be wrong in 
> this version regarding primary keys and sequences.

I'm still using 3.1 because it works and I never bothered to upgrade, so
the rest of this is in part rampant speculation.

>From Torque 3.1 to Torque 3.1.1, the stuff to create PostgreSQL
sequences used by Torque has been removed. Instead, PostgreSQL is used
to automatically generate sequences by setting the column type to serial
instead of int, but this only happens when autoIncrement="true".

This thread on the dev list discusses it a bit:
http://nagoya.apache.org/eyebrowse/BrowseList?listName=torque-dev@db.apache.org&by=thread&from=871983

> 
> If I set my table to use idMethod="native", then torque generates sql 
> that refers to a non-existence sequence and I can't insert any rows.

Because of the number of options that have to be set, it seems to be
really easy to select a set which results in a non-working system.

> 
> If I add autoIncrement="true" to my primary key, then I get working  sql
> and I can insert rows via psql. BUT I can't insert any rows via  the
> peer objects, because the generated Java code refers to a  sequence that
> does not exist.

Try using id-method-param to tell Torque about the autogenerated
sequence, as suggested by Scott
(http://nagoya.apache.org/eyebrowse/ReadMsg?listName=torque-dev@db.apache.org&msgNo=4108):


 <table name="category" idMethod="native">
    <column name="category_id" required="true" autoIncrement="true"
        primaryKey="true" type="INTEGER"/>
    <column name="name" size="100" type="VARCHAR"/>
    <id-method-parameter name="seqName" value="CATEGORY_CATEGORY_ID_SEQ"/>
  </table>

Use psql and '\ds' to find out what the generated sequences are named.

-- 
 Matt Hughes
  + mhughe@uvic.ca

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


Mime
View raw message