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 14:38:20 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">
I don't see where you're inserting id in your insert statement.&nbsp; You'll
need to add it as a parameter even if you use selectKey.<br>
<br>
Diran<br>
<br>
<br>
jaybytez wrote:
<blockquote cite="mid5843646.post@talk.nabble.com" type="cite">
  <pre wrap="">When I use a selectKey in conjunction with a parameterMap...the selectKey
does not appear to work in mapping its value into the insert statement.  I
originally did not have an id field in my object, so I added one and
included it in the parameterMap thinking this would help.  I then made the
selectKey output map to the id parameter thinking it would populate id with
the result from selectKey...it doesn't.  I tested the selectKey separate and
it works.  But in this example below...I keep getting integrity constraint
violations because the selectKey and insert are trying to insert 0...or
something.  Any help on this?

Thanks,

jay

    &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 resultClass="long" 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;


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

Mime
View raw message