db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jakub Piechnik" <piech...@wp.pl>
Subject Re: Example problem
Date Thu, 19 May 2005 23:02:57 GMT
Oki, but can I check index value from the Torque level? If so - how? And is it possible to
switch off autoamte indexing in postgresql?

I've tried such definition:
 <table name="publisher" description="Publisher Table">
    <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"/>
    <index>
    	<index-column name="publisher_id"/>
    </index>
  </table>

but indexes are created automatically as well, and sequences while save() from torque casue
the same error.

Dnia 19-05-2005 o godz. 23:12 Matt Hughes napisał(a):
> Jakub Piechnik wrote:
> 
> > psql:project-schema.sql:5: ERROR:  table "book" does not exist
> > psql:project-schema.sql:18: NOTICE:  CREATE TABLE / PRIMARY KEY will 
> create implicit index "book_pkey" for table "book"
> > CREATE TABLE
> 
> > I understand errors, because table wasn't in database, so it can not 
> be dropped. But what is that NOTICE? There are another fileds created? 
> > After compiling whole programme (Strp 4 in tutorial) when I was trying 
> to perform the example programme - I counted errors - connected with 
> NOTICE information form executing sql scripts (generated by Torque). 
> These errors were:
> 
> PostgreSQL uses sequences to generate primary key values. Creating a
> table with a column defined as a primary key will automatically create
> this index. When inserting data into the database, PostgreSQL queries
> and increments the sequence so that each record has a unique primary key.
> 
> The problem is that the sequence doesn't know or care about any data
> that is already in the table. I'm not certain, but I would assume that
> the example app puts some data into the tables. It appears that the
> sequences do not get updated, so when new data is inserted, the sequence
> returns a number which is already used as a primary key.
> 
> The solution is to reset the sequence so that the next value returned
> will be greater than the primary key values currently in used. You can
> do this using a SQL statement like the following:
> 
> SELECT setval('book_pkey',
>         (SELECT max(publisher_pkey) FROM book));
> 
> This resets the value of the sequence 'book_pkey' to the largest
> publisher_pkey already in use. When an INSERT is next performed, the
> sequence will return that value + 1.
> 
> > 
> > org.apache.torque.TorqueException: org.postgresql.util.PSQLException: 
> ERROR: duplicate key violates unique constraint "publisher_pkey"
> >         at 
> org.apache.torque.util.BasePeer.throwTorqueException(BasePeer.java:200)
> >         at 
> org.apache.torque.util.BasePeer.insertOrUpdateRecord(BasePeer.java:867)
> >         at org.apache.torque.util.BasePeer.doInsert(BasePeer.java:706)
> >         at com.kazmier.om.BasePublisherPeer.doInsert(Unknown Source)
> >         at com.kazmier.om.BasePublisherPeer.doInsert(Unknown Source)
> >         at com.kazmier.om.BasePublisher.save(Unknown Source)
> >         at com.kazmier.om.BasePublisher.save(Unknown Source)
> >         at com.kazmier.om.BasePublisher.save(Unknown Source)
> >         at com.kazmier.Bookstore.main(Unknown Source)
> > Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key 
> violates unique constraint "publisher_pkey"
> >         at 
> org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1471)
> >         at 
> org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1256)
> >         at 
> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:175)
> >         at 
> org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:389)
> >         at 
> org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:330)
> >         at 
> org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:282)
> >         at com.workingdogs.village.Record.saveWithInsert(Unknown 
> Source)
> >         at com.workingdogs.village.Record.save(Unknown Source)
> >         at com.workingdogs.village.Record.save(Unknown Source)
> >         at 
> org.apache.torque.util.BasePeer.insertOrUpdateRecord(BasePeer.java:863)
> >         ... 7 more
> > 
> > It occured when I was trying to make firs save() after creating new 
> author. (line 24 in code).
> > 
> > I have no idea what is wrong and how could I solve it out. i would be 
> grateful for any help
> 
> Hopefully that helps.
> 
> -- 
>  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
> 
> 

----------------------------------------------------
ZOBACZ SERWIS SPECJALNY "Gwiezdne Wojny" 
dla maniaków, ciekawych tego fenomenu i totalnych starwarsowych laików
Kliknij: http://klik.wp.pl/?adr=http%3A%2F%2Ffilm.wp.pl%2Fp%2Fstarwars%2Findex.html&sid=386



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