db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Carl Ludewig <c...@cjsoftware.net>
Subject Re: Example problem
Date Mon, 23 May 2005 19:22:01 GMT
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.

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.

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.

Has this been fixed in a version since 3.1.1 or is the bug still  
outstanding? Are they any postgresql users out there that have run  
into this?

It seems that in 3.1.1 the only way to use torque is with the id  
broker, but I would rather use postgresql sequences.

In early versions of Torque, this was not an issue and things worked  
fine with Postgres.

Thanks for your help,

Carl


On May 19, 2005, at 6:49 PM, Matt Hughes wrote:

> First, I must say that I misread part of the error message you had in
> your last message, which I think may have lead to some confusion. It
> says that an implicit *index* was created, which I misread as  
> *sequence*.
>
> The problem is still that what ever the default value torque used for
> the primary key column was already used when you tried to .save() the
> object.
>
> Let me clarify that indexes and sequences are two separate things;
> sequences are used for automatically generating primary key values,  
> and
> indices are used to help speed row access.
>
> Jakub Piechnik wrote:
>
>> Oki, but can I check index value from the Torque level? If so - how?
>>
>
> You can, but you may not need to do this. See below.
>
>
>> And is it possible to switch off automate indexing in postgresql?
>>
>
> Torque does provide the id broker, but I have not used it, so I cannot
> offer any advice there. I highly recommend using PostgreSQL's  
> sequences.
>
> You can change how primary keys are managed by setting the idMethod
> (note capital M) attribute of the table tag, or by setting the
> defaultIdMethod on the database tag in the schema file.
>
> <database name="example" defaultIdMethod="native">
> <table name="Customer" idMethod="native">
> ...
> </table>
> </database>
>
> The available settings for idMethod are listed here:
> http://db.apache.org/torque/generator/schema-reference.html
>
> Try using "native". That should make Torque use PostgreSQL's sequences
> (so you should see a NOTICE that a sequence has been created, if I
> remember correctly).
>
> From the table schema you sent, and from re-reading your previous
> message, it doesn't seem that any id management was used, So give
> idMethod="native" a shot.
>
>
>>
>> I've tried such definition:
>>  <table name="publisher" description="Publisher Table"  
>> idMethod="native">
>>     <column
>>       name="publisher_id"
>>       required="true"
>>       primaryKey="true"
>>       type="INTEGER"
>>       description="Publisher Id"/>
>>     <column
>>       name="name"
>>       required="true"
>>       type="VARCHAR"
>>       size="128"
>>       description="Publisher Name"/>
>>   </table>
>>
>>
>
> -- 
>  Matt Hughes
>   + mhughe@uvic.ca
>   + http://spacemonkeys.ca/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>
>
>


---------------------------------------------------------------------
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