I agree with you the primary key should not be updated. It is an old legacy
system that I am migrating which I never saw before until two weeks ago.  It
had been created back in 2001 by an IBM code generator for IBM Websphere
Application Developer version 3. 5 (the current version is RAD7).  Fortunately
I found out late Friday night from a project leader that the serial number
alone is sufficient to be the primary key, so I've since altered the database
to remove empNbr so it's not part of a composite primary key. That lets me use
abator to change the empNbr.

   By the way, I think abator is the greatest.  I don't know how I could get my
work done without it.  The only thing that mildly inconveniences me is that
after I have generated all the abator DAO, domain, and domain by example java
classes, I have to spend 45 minutes creating by hand all the individual entries
for "sqlMapConfig" and for the Spring context references to the DAOs.  I have
pasted these two files below so you can see them.  It would sure be nice if
abator could generate these two too:
=========================
<sqlMapConfig>
        <settings useStatementNamespaces="true" />
        <sqlMap
                
resource="frb/bsd/abator/ibatis/ATADMIN_IAT_ADS_SERIAL_NUM_SqlMap.xml" />
        <sqlMap
                resource="frb/bsd/abator/ibatis/ATADMIN_IAT_ASSET_SqlMap.xml" />
        <sqlMap
                
resource="frb/bsd/abator/ibatis/ATADMIN_IAT_AT_FUN_GRP_SqlMap.xml" />
        <sqlMap
                
resource="frb/bsd/abator/ibatis/ATADMIN_IAT_DECOM_REASON_SqlMap.xml" />
        <sqlMap
                resource="frb/bsd/abator/ibatis/ATADMIN_IAT_HR_EMP_SqlMap.xml" 
/>

        <sqlMap
                
resource="frb/bsd/abator/ibatis/ATADMIN_IAT_TIER_PRICE_USAGE_SqlMap.xml" />
        <sqlMap
                
resource="frb/bsd/abator/ibatis/ATADMIN_IAV_ASSET_INFO1_SqlMap.xml" />
        <sqlMap
                
resource="frb/bsd/abator/ibatis/ATADMIN_IAV_ASSET_INFO2_SqlMap.xml" />
        <sqlMap
                
resource="frb/bsd/abator/ibatis/ATADMIN_IAV_ASSET_INFO_SqlMap.xml" />
        <sqlMap
                
resource="frb/bsd/abator/ibatis/ATADMIN_IAV_ASSIGNED_SERIAL_SqlMap.xml" />
        <sqlMap
        
resource="frb/bsd/abator/ibatis/ATADMIN_IAV_BUDGET_ASSET_TIER_COUNT_SqlMap.xml"
/>
        <sqlMap
        
resource="frb/bsd/abator/ibatis/ATADMIN_IAV_BUDGET_ASSET_TOTAL_COUNT_SqlMap.xml"
/>
        <sqlMap
        
resource="frb/bsd/abator/ibatis/ATADMIN_IAV_BUDGET_HAVE_ASSET_LIST_SqlMap.xml"
/>
        <sqlMap
                
resource="frb/bsd/abator/ibatis/ATADMIN_IAV_BUDGET_UNIT_SqlMap.xml" />
        <sqlMap
                
resource="frb/bsd/abator/ibatis/ATADMIN_IAV_EMP_ASSET_DECOMM_SqlMap.xml" />
        <sqlMap
                
resource="frb/bsd/abator/ibatis/ATADMIN_IAV_EMP_ASSET_DETAIL_N_SqlMap.xml" />
        <sqlMap
                
resource="frb/bsd/abator/ibatis/ATADMIN_IAV_EMP_ASSET_DETIAL_SqlMap.xml" />
        <sqlMap
                
resource="frb/bsd/abator/ibatis/ATADMIN_IAV_EMP_LF_NAME_SqlMap.xml" />
        <sqlMap
                
resource="frb/bsd/abator/ibatis/ATADMIN_IAV_EMP_L_F_NAME_SqlMap.xml" />
        <sqlMap
        
resource="frb/bsd/abator/ibatis/ATADMIN_IAV_EMP_L_F_NAME_HAVE_ASSET_SqlMap.xml"
/>
        <sqlMap
                resource="frb/bsd/abator/ibatis/ATADMIN_IAV_EMP_SqlMap.xml" />
        <sqlMap
                
resource="frb/bsd/abator/ibatis/ATADMIN_IAV_FUN_ASSET_CAL_SqlMap.xml" />
        <sqlMap
                
resource="frb/bsd/abator/ibatis/ATADMIN_IAV_FUN_ASSET_LIST_SqlMap.xml" />
        <sqlMap
                
resource="frb/bsd/abator/ibatis/ATADMIN_IAV_FUN_ASSET_TIER_COUNT_SqlMap.xml"
/>
        <sqlMap
                
resource="frb/bsd/abator/ibatis/ATADMIN_IAV_FUN_ASSET_TOTAL_COUNT_SqlMap.xml"
/>
        <sqlMap
                
resource="frb/bsd/abator/ibatis/ATADMIN_IAV_FUN_HAVE_ASSET_LIST_SqlMap.xml"
/>
        <sqlMap
                
resource="frb/bsd/abator/ibatis/ATADMIN_IAV_NOT_ASSIGN_SERIAL_NUM_SqlMap.xml"
/>
</sqlMapConfig>
==========================

        <bean id="iatAdsSerialNumDAO"
                class="frb.bsd.abator.dao.IatAdsSerialNumDAOImpl">
                <property name="sqlMapClient" ref="sqlMapClient" />
        </bean>
        <bean id="iatAssetDAO" class="frb.bsd.abator.dao.IatAssetDAOImpl">
                <property name="sqlMapClient" ref="sqlMapClient" />
        </bean>
        <bean id="iatAtFunGrpDAO"
                class="frb.bsd.abator.dao.IatAtFunGrpDAOImpl">
                <property name="sqlMapClient" ref="sqlMapClient" />
        </bean>
        <bean id="iatDecomReasonDAO"
                class="frb.bsd.abator.dao.IatDecomReasonDAOImpl">
                <property name="sqlMapClient" ref="sqlMapClient" />
        </bean>
        
        

        <bean id="iatHrEmpDAO" class="frb.bsd.abator.dao.IatHrEmpDAOImpl">
                <property name="sqlMapClient" ref="sqlMapClient" />
        </bean>

         
         
        <bean id="iatTierPriceUsageDAO"
                class="frb.bsd.abator.dao.IatTierPriceUsageDAOImpl">
                <property name="sqlMapClient" ref="sqlMapClient" />
        </bean>
        <bean id="iavAssetInfo1DAO"
                class="frb.bsd.abator.dao.IavAssetInfo1DAOImpl">
                <property name="sqlMapClient" ref="sqlMapClient" />
        </bean>
        <bean id="iavAssetInfo2DAO"
                class="frb.bsd.abator.dao.IavAssetInfo2DAOImpl">
                <property name="sqlMapClient" ref="sqlMapClient" />
        </bean>
        <bean id="iavAssetInfoDAO"
                class="frb.bsd.abator.dao.IavAssetInfoDAOImpl">
                <property name="sqlMapClient" ref="sqlMapClient" />
        </bean>
        <bean id="iavAssignedSerialDAO"
                class="frb.bsd.abator.dao.IavAssignedSerialDAOImpl">
                <property name="sqlMapClient" ref="sqlMapClient" />
        </bean>
        <bean id="iavBudgetAssetTierCountDAO"
                class="frb.bsd.abator.dao.IavBudgetAssetTierCountDAOImpl">
                <property name="sqlMapClient" ref="sqlMapClient" />
        </bean>
        <bean id="iavBudgetAssetTotalCountDAO"
                class="frb.bsd.abator.dao.IavBudgetAssetTotalCountDAOImpl">
                <property name="sqlMapClient" ref="sqlMapClient" />
        </bean>
        <bean id="iavBudgetHaveAssetListDAO"
                class="frb.bsd.abator.dao.IavBudgetHaveAssetListDAOImpl">
                <property name="sqlMapClient" ref="sqlMapClient" />
        </bean>
        <bean id="iavBudgetUnitDAO"
                class="frb.bsd.abator.dao.IavBudgetUnitDAOImpl">
                <property name="sqlMapClient" ref="sqlMapClient" />
        </bean>
        <bean id="iavEmpAssetDecommDAO"
                class="frb.bsd.abator.dao.IavEmpAssetDecommDAOImpl">
                <property name="sqlMapClient" ref="sqlMapClient" />
        </bean>
        <bean id="iavEmpAssetDetailNDAO"
                class="frb.bsd.abator.dao.IavEmpAssetDetailNDAOImpl">
                <property name="sqlMapClient" ref="sqlMapClient" />
        </bean>
        <bean id="iavEmpAssetDetialDAO"
                class="frb.bsd.abator.dao.IavEmpAssetDetialDAOImpl">
                <property name="sqlMapClient" ref="sqlMapClient" />
        </bean>
        <bean id="iavEmpDAO" class="frb.bsd.abator.dao.IavEmpDAOImpl">
                <property name="sqlMapClient" ref="sqlMapClient" />
        </bean>
        <bean id="iavEmpLFNameAllDAO"
                class="frb.bsd.abator.dao.IavEmpLFNameAllDAOImpl">
                <property name="sqlMapClient" ref="sqlMapClient" />
        </bean>
        <bean id="iavEmpLfNameDAO"
                class="frb.bsd.abator.dao.IavEmpLfNameDAOImpl">
                <property name="sqlMapClient" ref="sqlMapClient" />
        </bean>
        <bean id="iavEmpLFNameHaveAssetDAO"
                class="frb.bsd.abator.dao.IavEmpLFNameHaveAssetDAOImpl">
                <property name="sqlMapClient" ref="sqlMapClient" />
        </bean>
        <bean id="iavFunAssetCalDAO"
                class="frb.bsd.abator.dao.IavFunAssetCalDAOImpl">
                <property name="sqlMapClient" ref="sqlMapClient" />
        </bean>
        <bean id="iavFunAssetListDAO"
                class="frb.bsd.abator.dao.IavFunAssetListDAOImpl">
                <property name="sqlMapClient" ref="sqlMapClient" />
        </bean>
        <bean id="iavFunAssetTierCountDAO"
                class="frb.bsd.abator.dao.IavFunAssetTierCountDAOImpl">
                <property name="sqlMapClient" ref="sqlMapClient" />
        </bean>
        <bean id="iavFunAssetTotalCountDAO"
                class="frb.bsd.abator.dao.IavFunAssetTotalCountDAOImpl">
                <property name="sqlMapClient" ref="sqlMapClient" />
        </bean>
        <bean id="iavFunHaveAssetListDAO"
                class="frb.bsd.abator.dao.IavFunHaveAssetListDAOImpl">
                <property name="sqlMapClient" ref="sqlMapClient" />
        </bean>
        <bean id="iavNotAssignSerialNumDAO"
                class="frb.bsd.abator.dao.IavNotAssignSerialNumDAOImpl">
                <property name="sqlMapClient" ref="sqlMapClient" />
        </bean>




==========================


>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 <[EMAIL PROTECTED]> 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 =  ?  )    )";


Reply via email to