Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 76298 invoked from network); 20 Sep 2007 18:39:00 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 20 Sep 2007 18:39:00 -0000 Received: (qmail 97128 invoked by uid 500); 20 Sep 2007 18:38:48 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 97121 invoked by uid 500); 20 Sep 2007 18:38:48 -0000 Mailing-List: contact user-java-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-java@ibatis.apache.org Delivered-To: mailing list user-java@ibatis.apache.org Received: (qmail 97109 invoked by uid 99); 20 Sep 2007 18:38:48 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Sep 2007 11:38:48 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of jeffgbutler@gmail.com designates 64.233.162.226 as permitted sender) Received: from [64.233.162.226] (HELO nz-out-0506.google.com) (64.233.162.226) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Sep 2007 18:38:48 +0000 Received: by nz-out-0506.google.com with SMTP id x3so508678nzd for ; Thu, 20 Sep 2007 11:38:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; bh=6w3iPRynS2tqr6aaaRibXZMUjTfA+zhWXCBU+n+r7p8=; b=BcupdQAYG57B6Ovko/3TjKsI0GA+ERjViOFyGyhuC/u8pNC/VRCs2IsOA7p001S+s1T8x7cfJhU5Y3wCRvoA6r699L6najJcnUory85Nzt2GPSHcjOiJG2QkjKWnuNp8E/NqGk9cjxpxO4f8XuOfTldJ/eWI3JdB0rX6PBQbJvY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=s7QJwFGE3wkaegGRcwTmhv3grRqUOgeOOX0HbAwbSwtdHDGx7YktmV2xuLPAsFG1PQzBFvMI5vvWrmLAKVEeZxJD9KIHI90OTwMJuV/v/RbNg2dWQkUeW9Q2kLEL0ZMcYdFVY7QmWXYjuYknLF63+XbTmfqTkNjtOyfAs2H0Xrk= Received: by 10.114.204.7 with SMTP id b7mr2451841wag.1190313506676; Thu, 20 Sep 2007 11:38:26 -0700 (PDT) Received: by 10.115.111.12 with HTTP; Thu, 20 Sep 2007 11:38:26 -0700 (PDT) Message-ID: Date: Thu, 20 Sep 2007 13:38:26 -0500 From: "Jeff Butler" To: user-java@ibatis.apache.org Subject: Re: Abator problem updating table with unique key constraint but no primary keay In-Reply-To: <576830.11999.qm@web30808.mail.mud.yahoo.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_32966_10980311.1190313506670" References: <576830.11999.qm@web30808.mail.mud.yahoo.com> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_32966_10980311.1190313506670 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline There's no way to force Abator to generate an updateByPrimaryKey method if there's not a primary key in the table. This issue has come up before - but the problem is a failure in database design more so than a failure of Abator. However, the next version of Abator will generate an updateByExample method that will overcome this issue once and for all. I'm working on that now but it's not in SVN yet. I'm trying to decide about the best way to code around an iBATIS bug before I commit anything. As far as the updateXXXSelective methods, you are correct. The selective methods will only generate set statements for non-null values in the parameter object. Jeff Butler On 9/20/07, Robert Glover wrote: > > The Abator update shown below will not compile because Abator will not > generate the "updateByPrimary" method. > > The reason Abator will not generate the "updateByPrimary" method is that > the > table has a "unique" constraint on a column but does not define that > column as > being a primary key. (The table has no primary key defined at all). > > I cannot solve this problem by dropping the "unique" constraint and > replacing it with a primary key definition on the same column. There are > two > reasons why I can't. First, because an "ALTER" statement to define a > primary > key fails because there is already a "unique" constraint defined. Second, > because an "ALTER" to drop the "unique" constraint fails due to there > being > foreign keys in other tables that reference that column. > > Here is the Abator method I cannot compile because Abator does not > generate the method due to their being no primary key: > > > getIatMidOrgStructureDAO().updateByPrimary(iatMidOrgStructure2); > > > Is there any change I can make to the Abator XML to force it to > generate > that method. > > A second question I have is that I do not fully understand the > difference between the Abator method "updateByPrimaryKey" versus the > Abator > method "updateByPrimaryKeySelective". My guess is that the latter only > creates > "SET" statements for columns that have a non-null value. > > tx (and tx for the answer to a previous question about surrounding column > names > with literals, a feature that will appear in an upcoming Abator release), > Robert > ------=_Part_32966_10980311.1190313506670 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline
There's no way to force Abator to generate an updateByPrimaryKey method if there's not a primary key in the table.  This issue has come up before - but the problem is a failure in database design more so than a failure of Abator.
 
However, the next version of Abator will generate an updateByExample method that will overcome this issue once and for all.  I'm working on that now but it's not in SVN yet.  I'm trying to decide about the best way to code around an iBATIS bug before I commit anything.
 
As far as the updateXXXSelective methods, you are correct.  The selective methods will only generate set statements for non-null values in the parameter object.
 
Jeff Butler

 
On 9/20/07, Robert Glover <robertgloverjr@yahoo.com> wrote:
  The Abator update shown below will not compile because Abator will not
generate the "updateByPrimary" method.

  The reason Abator will not generate the "updateByPrimary" method is that the
table has a "unique" constraint on a column but does not define that column as
being a primary key. (The table has no primary key defined at all).

   I cannot solve this problem by dropping the "unique" constraint and
replacing it with a primary key definition on the same column.  There are two
reasons why I can't.  First, because an "ALTER" statement to define a primary
key fails because there is already a "unique" constraint defined.  Second,
because an "ALTER" to drop the "unique" constraint fails due to there being
foreign keys in other tables that reference that column.

    Here is the Abator method I cannot compile because Abator does not
generate the method due to their being no primary key:


getIatMidOrgStructureDAO().updateByPrimary(iatMidOrgStructure2);


     Is there any change I can make to the Abator XML to force it to generate
that method.

      A second question I have is that I do not fully understand the
difference between the Abator method "updateByPrimaryKey"  versus the Abator
method "updateByPrimaryKeySelective".  My guess is that the latter only creates
"SET" statements for columns that have a non-null value.

tx (and tx for the answer to a previous question about surrounding column names
with literals, a feature that will appear in an upcoming Abator release),
Robert

------=_Part_32966_10980311.1190313506670--