You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Robert Glover <ro...@yahoo.com> on 2007/09/07 23:32:16 UTC

Abator update problem

  I am trying to use Abator to do the equivalent of the following SQL
statement, which as you can see is changing the "EMP_ID".  "EMP_ID" and
"SERIAL_NUM" together comprise the primary key.

"UPDATE    ATADMIN.IAT_ASSET
SET EMP_ID =  ? , 
BUDGET_UNIT =  ? ,  
ASSET_COMMENT =  ? ,  
DECOMM_REQ_FLG =  ? 
WHERE   
(      ( ATADMIN.IAT_ASSET.EMP_ID =  ?  ) 
AND ( ATADMIN.IAT_ASSET.SERIAL_NUM =  ?  )    )";

   The only two methods Abator created in the "IatAssetDAO" are the following
two, which do not provide me any way to change the value of the primary key
because it is used in the where clause.  Please advise-- am I out of luck or is
there a way to coax Abator into doing this update.

    /**
     * This method was generated by Abator for iBATIS.
     * This method corresponds to the database table ATADMIN.IAT_ASSET
     *
     * @abatorgenerated Fri Sep 07 17:08:13 EDT 2007
     */
    int updateByPrimaryKey(IatAsset record);

    /**
     * This method was generated by Abator for iBATIS.
     * This method corresponds to the database table ATADMIN.IAT_ASSET
     *
     * @abatorgenerated Fri Sep 07 17:08:13 EDT 2007
     */
    int updateByPrimaryKeySelective(IatAsset record);



    



Re: Abator update problem

Posted by Jeff Butler <je...@gmail.com>.
Abator generated code won't do this now.  I am working on an
"updateByExample" method for the next release of Abator that will allow
this.

BTW...relational purists would frown on this anyway.  Changing the primary
key of a record is problematical if there are any foreign keys related to
the table.  Also, it's not clear what the intent is when changing a primary
key - was the record related to the wrong employee, or did the employee id
change?

Jeff Butler


On 9/7/07, Robert Glover <ro...@yahoo.com> wrote:
>
> I am trying to use Abator to do the equivalent of the following SQL
> statement, which as you can see is changing the "EMP_ID".  "EMP_ID" and
> "SERIAL_NUM" together comprise the primary key.
>
> "UPDATE    ATADMIN.IAT_ASSET
> SET EMP_ID =  ? ,
> BUDGET_UNIT =  ? ,
> ASSET_COMMENT =  ? ,
> DECOMM_REQ_FLG =  ?
> WHERE
> (      ( ATADMIN.IAT_ASSET.EMP_ID =  ?  )
> AND ( ATADMIN.IAT_ASSET.SERIAL_NUM =  ?  )    )";
>
>   The only two methods Abator created in the "IatAssetDAO" are the
> following
> two, which do not provide me any way to change the value of the primary
> key
> because it is used in the where clause.  Please advise-- am I out of luck
> or is
> there a way to coax Abator into doing this update.
>
>    /**
>     * This method was generated by Abator for iBATIS.
>     * This method corresponds to the database table ATADMIN.IAT_ASSET
>     *
>     * @abatorgenerated Fri Sep 07 17:08:13 EDT 2007
>     */
>    int updateByPrimaryKey(IatAsset record);
>
>    /**
>     * This method was generated by Abator for iBATIS.
>     * This method corresponds to the database table ATADMIN.IAT_ASSET
>     *
>     * @abatorgenerated Fri Sep 07 17:08:13 EDT 2007
>     */
>    int updateByPrimaryKeySelective(IatAsset record);
>
>
>
>
>
>
>