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 15:26:57 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 think this is because you don't have it in the insert statement like
this...<br>
<br>
<pre wrap="">INSERT INTO hba_contact_hbc 
       (id, 
	hbc_contact_id, 
	hbc_tsc_name, 
	hbc_contact_name,
	hbc_contact_date,
        etc...

if the property you're trying to use as the id is hbc_contact_id you'll need the selectKey
to look like this: 
</pre>
<pre wrap="">        &lt;selectKey resultClass="long" keyProperty="hbc_contact_id"&gt;
                SELECT hba_contact_seq.NEXTVAL FROM DUAL
        &lt;/selectKey&gt;

And then have the insert as you already have it defined.
</pre>
Diran<br>
<br>
jaybytez wrote:
<blockquote cite="mid5852938.post@talk.nabble.com" type="cite">
  <pre wrap="">And if I put it into the id (from selectKey) into my parameterMap like
the
following, it does not push the result of the selectKey query into the
insert statement:

    &lt;parameterMap id="hbaContactParameters"
class="com.healthnet.hnfs.hba.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