ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Diran Ayandele <Adediran.Ayand...@Sun.COM>
Subject Re: selectKey and parameterMap issue
Date Thu, 17 Aug 2006 16:30:15 GMT
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000099">
One other thing to check would be to make sure you're calling
SqlMap.insert and not SqlMap.update.&nbsp; I know this causes issues with
the selectKey.<br>
<br>
<br>
<br>
jaybytez wrote:
<blockquote cite="mid5854352.post@talk.nabble.com" type="cite">
  <pre wrap="">Thanks for your help.  I am using iBatis 2.1.7.

If I use the following configuration (just the keyProperty attribute), I get
a unique key constraint violation because it still is not putting the
keyProperty value into the parameter property.  "id" is set to 0 (since its
a long in ContactTO), and that is the value being pushed to the database. 
But if I run my nextval query against the sequence separately...I get the
next sequence number.  I can't figure out where the miss fire is happening.

    &lt;parameterMap id="hbaContactParameters" class="com.foo.to.ContactTO"&gt;  
        &lt;parameter property="id" jdbcType="NUMERIC"/&gt;        
        &lt;parameter property="tscName" jdbcType="VARCHAR"/&gt;
        &lt;parameter property="contactName" jdbcType="VARCHAR"/&gt;
        &lt;parameter property="contactDate" jdbcType="DATE"
javaType="dateTime"/&gt;
        &lt;parameter property="issueResolvedIndicator" jdbcType="NUMERIC"/&gt;
        &lt;parameter property="followUpRequiredIndicator" jdbcType="NUMERIC"/&gt;
        &lt;parameter property="followUpRequiredDescription"
jdbcType="VARCHAR"/&gt;
        &lt;parameter property="contactTypeDescription" jdbcType="VARCHAR"/&gt;
        &lt;parameter property="contactReasonTypeDescription"
jdbcType="VARCHAR"/&gt;
        &lt;parameter property="contactType" jdbcType="NUMERIC"
javaType="com.foo.to.ContactType"/&gt;
        &lt;parameter property="contactMethodType" jdbcType="NUMERIC"
javaType="com.foo.to.ContactMethodType"/&gt;
        &lt;parameter property="contactReasonType" jdbcType="NUMERIC"
javaType="com.foo.to.ContactReasonType"/&gt;
    &lt;/parameterMap&gt;
    
    &lt;insert id="insertHBAContact"
        parameterMap="hbaContactParameters"&gt;
        &lt;selectKey keyProperty="id"&gt;
            &lt;![CDATA[
                SELECT hba_contact_seq.NEXTVAL FROM DUAL
            ]]&gt;
        &lt;/selectKey&gt;
        
        &lt;![CDATA[    
            INSERT INTO hba_contact_hbc 
                ( hbc_contact_id, hbc_tsc_name, hbc_contact_name,
hbc_contact_date,
                  hbc_issue_resolved_ind, hbc_follow_up_required_ind, 
                  hbc_follow_up_required_desc, hbc_contact_type_desc, 
                  hbc_reason_desc, hbc_fk_contact_type_id,
hbc_fk_contact_method_id,
                  hbc_fk_contact_reason_id ) 
            VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
        ]]&gt;
    &lt;/insert&gt;

Thanks,

jay
  </pre>
</blockquote>
</body>
</html>

Mime
View raw message