<insert id="insert_News" parameterClass="News">  
  <![CDATA[
    insert into table(id, classtype, content) 
         values (#id#, #?????#, #content#)
  ]]>
</insert>其中“?????”的部分应该怎么写呢?试过写Class.Name是不行的,因为这个属性不是serialize的

解决方案 »

  1.   

    给你看一个完整例子吧,希望对你有用:<?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd" >
    <sqlMap namespace="APP_A_PERSON" >
      <typeAlias type="com.ccid.app.phms.pojo.Person" alias="personInfo" />
      <resultMap id="personMap" class="personInfo" >
        <result column="ID"                    property="id"              jdbcType="DECIMAL"  />
        <result column="XM"                property="xm"           jdbcType="VARCHAR" />
        <result column="SFZH"              property="sfzh"        jdbcType="VARCHAR" />
        <result column="XB"             property="xb"       jdbcType="VARCHAR" />
        <result column="CSRQ"            property="csrq"       jdbcType="VARCHAR" />
        <result column="GJ"              property="gj"         jdbcType="VARCHAR" />
        <result column="MZ"                property="mz"           jdbcType="VARCHAR" />
        <result column="NL"              property="nl"        jdbcType="DECIMAL" />
        <result column="HYZK"             property="hyzk"       jdbcType="VARCHAR" />
        <result column="WHCD"            property="whcd"       jdbcType="VARCHAR" />
        <result column="CSD"              property="csd"         jdbcType="VARCHAR" />
        <result column="CJWH"                property="cjwh"           jdbcType="VARCHAR" />
        <result column="DWBH"              property="dwbh"        jdbcType="VARCHAR" />
        <result column="PTBH"             property="ptbh"       jdbcType="VARCHAR" />
        <result column="XZZ"            property="xzz"       jdbcType="VARCHAR" />
        <result column="CZLX"              property="czlx"         jdbcType="VARCHAR" />
        <result column="LXRXM"                property="lxrxm"           jdbcType="VARCHAR" />
        <result column="XQ"              property="xq"        jdbcType="VARCHAR" />
        <result column="ZZDH"             property="zzdh"       jdbcType="VARCHAR" />
        <result column="LXDH"            property="lxdh"       jdbcType="VARCHAR" />
        <result column="LXRDH"              property="lxrdh"         jdbcType="VARCHAR" />
        <result column="ZY"              property="zy"        jdbcType="VARCHAR" />
        <result column="GZDW"             property="gzdw"       jdbcType="VARCHAR" />
        <result column="JTBH"            property="jtbh"       jdbcType="VARCHAR" />
        <result column="JDBH"              property="jdbh"         jdbcType="VARCHAR" />
        <result column="JDXX"              property="jdxx"         jdbcType="VARCHAR" />
        
        <result column="SQBH"                property="sqbh"           jdbcType="VARCHAR" />
        <result column="HZGX"              property="hzgx"        jdbcType="VARCHAR" />
        <result column="ZNS"             property="zns"       jdbcType="DECIMAL" />
        <result column="FQXM"            property="fqxm"       jdbcType="VARCHAR" />
        <result column="MQXM"              property="mqxm"         jdbcType="VARCHAR" />
        <result column="YLFYZFFS"                property="ylfyzffs"           jdbcType="VARCHAR" />
        <result column="YLZKH"              property="ylzkh"        jdbcType="VARCHAR" />
        <result column="ZRYS"             property="zrys"       jdbcType="VARCHAR" />
        <result column="MZTCDW"            property="mztcdw"       jdbcType="VARCHAR" />
        <result column="YKTH"            property="ykth"       jdbcType="VARCHAR" />
        <result column="CJ_USERID"         property="cjUserid"        jdbcType="DECIMAL" />
        <result column="CJ_USERNAME"        property="cjUsername"    jdbcType="VARCHAR" />
        <result column="CJ_TIME"         property="cjTime"    jdbcType="DATE"    />
        <result column="CJ_GROUPID"         property="cjGroupid"    jdbcType="DECIMAL" />
        <result column="CJ_GROUPNAME"         property="cjGroupname"    jdbcType="VARCHAR" />
        <result column="JDMC"         property="jdmc"    jdbcType="VARCHAR" />
        <result column="SQMC"         property="sqmc"    jdbcType="VARCHAR" />
      </resultMap>
     
     <!-- 慢病高危人群 -->
     <select id="getListOfMbgw" parameterClass="java.util.HashMap" resultMap="personMap">
    select * from app_a_person where id in (
    select distinct id from (select p.id from app_a_person p,app_a_gxy g,app_a_health h where (g.hid=p.id and h.pid=p.id) and 
    (
        <isNotEmpty property="queryCondition">
            <![CDATA[ $queryCondition$ ]]>
            </isNotEmpty> 
    )
    )
    )
          <isNotEmpty property="query">
            <![CDATA[ $query$ ]]>
          </isNotEmpty> 
          order by id desc
      </select>
      
      <select id="getCountOfMbgw" parameterClass="java.util.HashMap" resultClass="java.lang.Integer">
    select count(*) from app_a_person where id in (
    select distinct id from (select p.id from app_a_person p,app_a_gxy g,app_a_health h where (g.hid=p.id and h.pid=p.id) and 
    (
        <isNotEmpty property="queryCondition">
            <![CDATA[ $queryCondition$ ]]>
            </isNotEmpty> 
        )    
    )
    )
          <isNotEmpty property="query">
            <![CDATA[ $query$ ]]>
          </isNotEmpty> 
          order by id desc
      </select>
      
       <!-- 高血压高危人群 -->
     <select id="getListOfGxygw" parameterClass="java.util.HashMap" resultMap="personMap">
    select * from app_a_person where id in(
    select distinct id from(
    select p.id from app_a_person p,app_a_randominfo r,app_a_health h,app_a_jzs j where (r.hzbh=p.dwbh or (h.pid=p.id and j.hid=p.id)) and 
    (
          <isNotEmpty property="queryCondition">
              <![CDATA[ $queryCondition$ ]]>
              </isNotEmpty> 
    )
    )
    )
          <isNotEmpty property="query">
            <![CDATA[ $query$ ]]>
          </isNotEmpty> 
          order by id desc
      </select>
      
      <select id="getCountOfGxygw" parameterClass="java.util.HashMap" resultClass="java.lang.Integer">
    select count(*) from app_a_person where id in(
    select distinct id from(
    select p.id from app_a_person p,app_a_randominfo r,app_a_health h,app_a_jzs j where (r.hzbh=p.dwbh or (h.pid=p.id and j.hid=p.id)) and 
    (
            <isNotEmpty property="queryCondition">
            <![CDATA[ $queryCondition$ ]]>
            </isNotEmpty> 
    )
    )
    )
          <isNotEmpty property="query">
            <![CDATA[ $query$ ]]>
          </isNotEmpty> 
          order by id desc
      </select>
     
      <select id="getList" parameterClass="java.util.HashMap" resultMap="personMap">
          select * from app_a_person where 1=1 
          <isNotEmpty property="query">
            <![CDATA[ $query$ ]]>
          </isNotEmpty> 
          order by id desc
      </select>
      
      <select id="getListCount" parameterClass="java.util.HashMap" resultClass="java.lang.Integer">
          select count(*) from app_a_person where 1=1
          <isNotEmpty property="query">
            <![CDATA[ $query$ ]]>
          </isNotEmpty> 
      </select>
      
      <!-- 
         1)没有随访信息,并且登记日期距今已超过90天
         2)病人有一个或多个随访信息(无论高血压,糖尿病随访),查询最近一次随访日期(上一次)大于90天的记录
       -->
      <select id="getRemainList" parameterClass="java.util.HashMap" resultMap="personMap">
      select * from app_a_person where dwbh not in (select hzbh from app_a_randominfo) and cj_time+90 <![CDATA[ < ]]> sysdate
      union
      select * from app_a_person where dwbh in (select hzbh from (select hzbh,max(sfrq) sfrq from app_a_randominfo  where sfrq is not null 
      group by hzbh) where sfrq+90 <![CDATA[ < ]]> sysdate)
      </select>
      
      <select id="getRemainListCount" parameterClass="java.util.HashMap" resultClass="java.lang.Integer">
      select count(*) from (
      select * from app_a_person where dwbh not in (select hzbh from app_a_randominfo) and cj_time+90 <![CDATA[ < ]]> sysdate
      union
      select * from app_a_person where dwbh in (select hzbh from (select hzbh,max(sfrq) sfrq from app_a_randominfo  where sfrq is not null 
      group by hzbh) where sfrq+90 <![CDATA[ < ]]> sysdate))
      </select>
     
     <delete id="delByIds" parameterClass="java.util.HashMap">
         delete from app_a_person where id in ( $personIds$ )
     </delete>
     
     <select id="getCountBySfzh" parameterClass="java.util.HashMap" resultClass="java.lang.Integer">
        select count(*) from app_a_person where sfzh= #sfzh#
     </select>
     
     <select id="getListByXm" parameterClass="java.util.HashMap" resultMap="personMap">
        select * from app_a_person where xm= #xm#
     </select>
     
     <select id="getCountByXm" parameterClass="java.util.HashMap" resultClass="java.lang.Integer">
        select count(*) from app_a_person where xm= #xm#
     </select>
     
     <!-- 根据ID查询信息 -->
      <select id="getInfo" resultMap="personMap" parameterClass="personInfo" >
        select * from APP_A_PERSON where ID = #id:DECIMAL#
      </select>
      

  2.   

    老兄你说的我都懂,可是你没看清我的需求呀,我插入的不是一般的属性,而是实体类名呀现在已经解决了。原因是Object没有实现Serializable接口,所以iBatis是没法反射到Object.getClass()方法的。目前只好在实体基类中重新定义一个get方法,并返回getClass().getName()