ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brandon Goodin <brandon.goo...@gmail.com>
Subject Re: Duplicate Key in Db
Date Wed, 23 Feb 2005 15:38:38 GMT
you should not specify your primary key in the update values of your
update statement. It should be part of your where criteria.

BAD:
UPDATE SOMETABLE 
(somePrimaryKey,columnA,columnB,columnC)
VALUES(#somePrimaryKey#,#'valueA#,#valueB#,#valueC#)
WHERE somePrimaryKey = 1

GOOD:
UPDATE SOMETABLE 
(columnA,columnB,columnC)
VALUES(#valueA#,#valueB#,#valueC#)
WHERE somePrimaryKey =  #somePrimaryKey#

Brandon

On Wed, 23 Feb 2005 12:00:34 +0000, Tim Christopher
<tim.christopher@gmail.com> wrote:
> Hi,
> 
> Apologies is this question is trivial for the group but I'm very new
> to using iBATIS.
> 
> I've managed to successfully integrate iBATIS into my Struts
> application, using a structure much like the sample JPetStore project
> - this acted as my tutorial.
> 
> Can someone let me know if it is possible for iBATIS to deal with
> problems such as an update containing a primary key which is the same
> as on already in the table?
> 
> I tested this out this morning on got a huge stack trace (summarised
> below), so I'm guessing it isn't done by default.
> 
> >>>>
> Cause: com.borland.datastore.driver.SqlState: Runtime Error: [line 1,
> col 6] Duplicate key value for $UNIQUE$1 sort order in "MODULE".
> <<<<
> 
> Any advice or even just a link would be much appreciated.
> 
> Regards,
> 
> Tim Christopher
>

Mime
View raw message