What versions of PostgreSQL and Torque are you using? For PostgreSQL 7.3.x the sequence name would be: <id-method-parameter name="seqName" value="hospital_hospital_id_seq"/>
Scott -- Scott Eade Backstage Technologies Pty. Ltd. http://www.backstagetech.com.au Hassan Abolhassani wrote: >I tried to follow your advises but still have the same problem. > >Here is the situation right now: > >1- In xml schema: ><database name="m3c" defaultIdMethod="native"> ><table name="HOSPITAL" idMethod="native"> ><column name="ID" required="true" autoIncrement="true" primaryKey="true" >type="INTEGER" /> ><column name="NAME" required="true" size="30" type="VARCHAR" /> >... ><id-method-parameter name="seqName" value="hospital_id_seq"/> ></table> > >2- In Postgres i see that a sequence with the name "hospital_id_seq" is >created. > >3- In postgres the hospital table has following schema: >-- Table: public.hospital >CREATE TABLE public.hospital ( > id int4 DEFAULT nextval('public.hospital_id_seq'::text) NOT NULL, > name varchar(30) NOT NULL, > ... > CONSTRAINT hospital_pkey PRIMARY KEY (id) >) WITH OIDS; > >4- In HospitalMapBuilder.java there are following lines: > dbMap.addTable("HOSPITAL"); > TableMap tMap = dbMap.getTable("HOSPITAL"); > > tMap.setPrimaryKeyMethod(TableMap.NATIVE); > > // this might need upgrading based on what all the databases > // need, but for now assume one parameter. > tMap.setPrimaryKeyMethodInfo("hospital_id_seq"); > > >The problem is when inserting, following exception happens: >.[Ljava.lang.StackTraceElement;@763f5d >org.apache.torque.TorqueException: IdGenerator for table 'HOSPITAL' is null > at org.apache.torque.util.BasePeer.doInsert(BasePeer.java:708) > at com.m3c.dm.BaseHospitalPeer.doInsert(BaseHospitalPeer.java:320) > at com.m3c.dm.BaseHospitalPeer.doInsert(BaseHospitalPeer.java:736) > at com.m3c.dm.BaseHospital.save(BaseHospital.java:1832) > at com.m3c.dm.BaseHospital.save(BaseHospital.java:1796) > at com.m3c.dm.BaseHospital.save(BaseHospital.java:1776) > at com.m3c.dm.OMFacade.insertHospital(OMFacade.java:107) > at com.m3c.dm.OMFacade.insertHospital(OMFacade.java:95) > at com.m3c.junit.dm.OMFacadeTest.testInsert(OMFacadeTest.java:33) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. >java:39) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces >sorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:324) > at junit.framework.TestCase.runTest(TestCase.java:154) > at junit.framework.TestCase.runBare(TestCase.java:127) > at junit.framework.TestResult$1.protect(TestResult.java:106) > at junit.framework.TestResult.runProtected(TestResult.java:124) > at junit.framework.TestResult.run(TestResult.java:109) > at junit.framework.TestCase.run(TestCase.java:118) > at junit.framework.TestSuite.runTest(TestSuite.java:208) > at junit.framework.TestSuite.run(TestSuite.java:203) > at junit.textui.TestRunner.doRun(TestRunner.java:116) > at junit.textui.TestRunner.doRun(TestRunner.java:109) > at junit.textui.TestRunner.run(TestRunner.java:72) > at com.m3c.junit.dm.OMFacadeTest.main(OMFacadeTest.java:23) > > >I appreicate any help to repair the problem. > >Hassan Abolhassani > >--- > >Scott Wrote: > > > >>In the previous mail subject was not appropriate, I resend with more >>appropriate subject. Sorry for any inconvenience. >> >>Hi, >> >>When I try to insert a row in a table with autoincrement id I get the >>following exception: >> >>org.apache.torque.TorqueException: IdGenerator for table 'HOSPITAL' is null >> >>It was working before in mysql but when I moved to postgresql it is not >>working anymore. >> >>I have following definition in schema for table hospital: >><column name="ID" required="true" autoIncrement="true" primaryKey="true" >>type="INTEGER" /> >> >>and in postgresql there are two sequences cretared by ant task: >> >>hospital_id_seq, and hospital_seq >> >> >> >> >The following is cut directly from a message I sent to this very list >only yesterday: > > > >>For PostgreSQL I recommend that you specify include: >> >><id-method-parameter name="seqName" >>value="addr_groups_addr_group_id_seq"/> >> >> > >In your case this would be: hospital_hospital_id_seq > > > >>within your table element. >> >>You should also be sure to check out: >> >>http://nagoya.apache.org/wiki/apachewiki.cgi?TorqueProjectPages/PostgreSQLFAQ >> >> >> > > >Scott > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
