You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Tak Fujimoto <t-...@beingcorp.co.jp> on 2003/04/17 12:55:39 UTC

problem with Postgresql and sequences for autoincrement

I sure did a heavy research on this subject 
throughout turbine-torque mail archive and all
but I still can not make it work!

I am starting to wonder if there is any bug on JDBC or Postgresql of this particular version.

Please give me any advice, suggestion on what I should do if you have time.


[setup]
jakarta-struts-1.1-b3
jakarta-tomcat-4.0.6
torque-3.0
Red Hat Linux release 7.1 (Seawolf)
apache_1.3.26
postgresql-7.2.1
pg73jdbc3.jar
mod_jk-1.3-noeapi.so

[Refered URL]
http://www.mail-archive.com/turbine-torque-user@jakarta.apache.org/msg00691.html
http://archives.apache.org/eyebrowse/ReadMsg?listName=turbine-torque-user@jakarta.apache.org&msgNo=198



This is the part of project-schema.xml which describes the table I am having a trouble with.
*****************************************************************************************
<table name="TELSUPPORT" idMethod="native">
  <column name="TELSUPPORT_ID"      type="INTEGER"  required="true"  autoIncrement="true"
primaryKey="true" />
  <column name="MEMBER_ID"      type="INTEGER"  required="true"  />
  <column name="DATE"    type="DATE"  default="now" required="true"  />
  <column name="TIME"    type="TIME" default="now" required="true"  />
  <column name="CUSTOMER_NUM"      type="INTEGER"  default="0" />
  <column name="INQUIRY_ID"      type="INTEGER"  required="true" />
  <column name="SUPPORTRESULT_ID"     type="CHAR" size="1"  required="true" />
  <column name="TELSUPPORT"      type="VARCHAR" size="10000" default="" />
  <id-method-parameter value="telsupport_telsupport_id_seq"/>
    <foreign-key foreignTable="MEMBER"><reference local="MEMBER_ID" foreign="MEMBER_ID"
/></foreign-key>
    <foreign-key foreignTable="INQUIRY"><reference local="INQUIRY_ID" foreign="INQUIRY_ID"
/></foreign-key>
    <foreign-key foreignTable="SUPPORTRESULT"><reference local="SUPPORTRESULT_ID"
foreign="SUPPORTRESULT_ID" /></foreign-key>
  </table>
*****************************************************************************************




*--------------------------------*
Tak Fujimoto
Being Co, Ltd.  
[ALLESNET]  Network Division
web   : http://www.alles.or.jp/
email : fujimoto@alles.ad.jp
tel : 03-3226-8421
fax : 03-3226-8425
*--------------------------------*

Re: problem with Postgresql and sequences for autoincrement

Posted by Rolf Jentsch <RJ...@electronicpartner.de>.
Hello,

I think you are trying to create the same sequence twice. For the primary key 
you force the creation of a squence "telsupport_telsupport_id_seq". This same 
sequence is automatically created by postgresql for the serial datatype.

So you can either remove the autoincrement="true" for your primary key, or you 
can set idMethod="none" for this table. In both cases you get in the database 
an integer column with a defaultvalue provided by a sequence.

The second approach may cause some problems with the generated java-code, so 
you probably should use the first one.

I hope this solves your problem.

Am Donnerstag, 17. April 2003 12:55 schrieb Tak Fujimoto:
...
> This is the part of project-schema.xml which describes the table I am
> having a trouble with.
> ***************************************************************************
>************** <table name="TELSUPPORT" idMethod="native">
>   <column name="TELSUPPORT_ID"      type="INTEGER"  required="true" 
> autoIncrement="true" primaryKey="true" />
...
> <id-method-parameter value="telsupport_telsupport_id_seq"/>
...
> Tak Fujimoto
> Being Co, Ltd.
> [ALLESNET]  Network Division
> web   : http://www.alles.or.jp/
> email : fujimoto@alles.ad.jp
> tel : 03-3226-8421
> fax : 03-3226-8425


Rolf Jentsch
Produktentwicklung EDV-Anwendungen für Mitglieder
ElectronicPartner GmbH & Co. KG
Düsseldorf


Re: problem with Postgresql and sequences for autoincrement

Posted by Eric Emminger <er...@ericemminger.com>.
> Now, project-schema.xml looks like this.
> I removed autoincrement attribute and id-method-parameter tag.
> I still can't make it work.
> 
>   <table name="TELSUPPORT" idMethod="native">
>     <column name="TELSUPPORT_ID"      type="INTEGER"  required="true" primaryKey="true" />
>   </table>

Perhaps I'm missing something, but the setup I use seems to work fine. I 
hope it helps you.

My schema xml file looks like this.

<database name="dbname">
   <table name="tablename" javaName="TableName" idMethod="native">
     <column name="Id" javaName="Id" required="true" primaryKey="true" 
type="INTEGER" javaType="object"/>

Here's my setup.
Torque 3.0
Turbine 2.2
TDK 2.2_01
PostgreSQL 7.3.2
Ant 1.5.1
Maven 1.0-beta-8
Java 1.4.1_01
Linux

Eric


Re: problem with Postgresql and sequences for autoincrement

Posted by Tak Fujimoto <t-...@beingcorp.co.jp>.
Now, project-schema.xml looks like this.
I removed autoincrement attribute and id-method-parameter tag.
I still can't make it work.

  <table name="TELSUPPORT" idMethod="native">
    <column name="TELSUPPORT_ID"      type="INTEGER"  required="true" primaryKey="true" />
  </table>


[setup]
jakarta-struts-1.1-b3
jakarta-tomcat-4.0.6
torque-3.0
Red Hat Linux release 7.1 (Seawolf)
apache_1.3.26
postgresql-7.2.1
pg73jdbc3.jar
mod_jk-1.3-noeapi.so

> Try this. Note no autoincrement attribute or id-method-parameter tag. I
> also use bigint columns for pk's as I believe that the sequences in pg
> cope with bigints ok. 
> 
>   <table idMethod="native" name="myname">
>    <column name="myid" primaryKey="true" required="true" type="BIGINT"/>
>   </table>



Re: problem with Postgresql and sequences for autoincrement

Posted by Peter Courcoux <pe...@courcoux.biz>.
Try this. Note no autoincrement attribute or id-method-parameter tag. I
also use bigint columns for pk's as I believe that the sequences in pg
cope with bigints ok. 

  <table idMethod="native" name="myname">
   <column name="myid" primaryKey="true" required="true" type="BIGINT"/>
  </table>

Regards,

Peter


On Thu, 2003-04-17 at 11:55, Tak Fujimoto wrote:
> I sure did a heavy research on this subject 
> throughout turbine-torque mail archive and all
> but I still can not make it work!
> 
> I am starting to wonder if there is any bug on JDBC or Postgresql of this particular version.
> 
> Please give me any advice, suggestion on what I should do if you have time.
> 
> 
> [setup]
> jakarta-struts-1.1-b3
> jakarta-tomcat-4.0.6
> torque-3.0
> Red Hat Linux release 7.1 (Seawolf)
> apache_1.3.26
> postgresql-7.2.1
> pg73jdbc3.jar
> mod_jk-1.3-noeapi.so
> 
> [Refered URL]
> http://www.mail-archive.com/turbine-torque-user@jakarta.apache.org/msg00691.html
> http://archives.apache.org/eyebrowse/ReadMsg?listName=turbine-torque-user@jakarta.apache.org&msgNo=198
> 
> 
> 
> This is the part of project-schema.xml which describes the table I am having a trouble with.
> *****************************************************************************************
> <table name="TELSUPPORT" idMethod="native">
>   <column name="TELSUPPORT_ID"      type="INTEGER"  required="true"  autoIncrement="true"
> primaryKey="true" />
>   <column name="MEMBER_ID"      type="INTEGER"  required="true"  />
>   <column name="DATE"    type="DATE"  default="now" required="true"  />
>   <column name="TIME"    type="TIME" default="now" required="true"  />
>   <column name="CUSTOMER_NUM"      type="INTEGER"  default="0" />
>   <column name="INQUIRY_ID"      type="INTEGER"  required="true" />
>   <column name="SUPPORTRESULT_ID"     type="CHAR" size="1"  required="true" />
>   <column name="TELSUPPORT"      type="VARCHAR" size="10000" default="" />
>   <id-method-parameter value="telsupport_telsupport_id_seq"/>
>     <foreign-key foreignTable="MEMBER"><reference local="MEMBER_ID" foreign="MEMBER_ID"
> /></foreign-key>
>     <foreign-key foreignTable="INQUIRY"><reference local="INQUIRY_ID" foreign="INQUIRY_ID"
> /></foreign-key>
>     <foreign-key foreignTable="SUPPORTRESULT"><reference local="SUPPORTRESULT_ID"
> foreign="SUPPORTRESULT_ID" /></foreign-key>
>   </table>
> *****************************************************************************************
> 
> 
> 
> 
> *--------------------------------*
> Tak Fujimoto
> Being Co, Ltd.  
> [ALLESNET]  Network Division
> web   : http://www.alles.or.jp/
> email : fujimoto@alles.ad.jp
> tel : 03-3226-8421
> fax : 03-3226-8425
> *--------------------------------*
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
-- 
Peter Courcoux <pe...@courcoux.biz>