Hi,
 
Maybe you made an errer with the jdoSetTimestamp, and jdoGetTimestamp methods.
If the timestamp returned by jdoGetTimestamp is 0 castor assumes to object is "new" and tries to create it in the database.
 
hope this helps,
 
julian
----- Original Message -----
Sent: Wednesday, January 16, 2002 10:47 PM
Subject: [castor-dev] castor and postgresql UPDATE problem, why is SQL INSERT being called

 

Hey,

I am using castor 0.9.3.9 with postgresql 7.1.  I am attempting to use long transactions by creating an object in the first transaction and then updating (Database.update(Object))the database in the second transaction.  But my attempts to update generate a

java.sql.SQLException: ERROR:  Cannot insert a duplicate key into unique index.  Viewing debugging messages in postgresql I see that INSERT rather than UPDATE is being called and thus the SQL error.  Any ideas anyone?  If a developer could point me in the right direction I would appreciate it; Info

---------

The object I am trying to persist looks like: Persistent and TimeStampable interface are implemented

 

MyObj implements Persistent, TimeStampable{

            public String getId();

            public void setId(String id)

            public String getVar()

            public void setVar(String var);

//TimeStampInterfaces

………..

//Persistent Interfaces

……………

}

Code looks like:

------------------

MyObj obj = new MyObj(id,var);

Database Db = new Database();

Db.begin();

Db.create(obj);

Db.commit();

Db.close();

 

Obj.setVar(newVar);

Db = new Database();

Db.begin();

Db.update(obj);

Db.commit();

Db.close();

 

Database schema

---------------

Create table myobj {

Id  varchar(20) not null,

Var varchar(20)

};

create unique index myobj_pk on myobj ( id );

 

 

 

Reply via email to