<resultMap id="ProjectApprovalResultMap" type="com.hhwy.fm.projectapproval.domain.ProjectApproval" >
   <id column="id" property="id" jdbcType="VARCHAR" />
   <result column="prj_code" property="prjCode" jdbcType="VARCHAR" />
   <result column="prj_status" property="prjStatus" jdbcType="VARCHAR" />
</resultMap>

<resultMap id="testPositionResultMap" extends="ProjectApprovalResultMap" type="com.hhwy.fm.projectapproval.domain.ProjectApproval">
   <association property="prjStatusName" column="prj_status" select="projectapproval.sql.selectPrjStatusName" />
   <association property="prjName" column="prj_code" select="projectapproval.sql.selectPrjName" />
</resultMap>

<select id="testPositionSelect" resultMap="testPositionResultMap" parameterType="string">
   select
      a.id,
      a.prj_code,
      a.prj_status
   from
      t_project_approval a
   WHERE a.id = #{id}
</select>

<select id="selectPrjStatusName" resultType="string" parameterType="string">
   select
      c.item_name
   FROM
      t_sys_dictitem c
   WHERE
      c.dict_code = 'prj_status'
      and c.item_code = #{prjStatus}
</select>

<select id="selectPrjName" resultType="string" parameterType="string">
   select
      b.prj_name
   from
      t_letter_trial b
   WHERE b.prj_code = #{prjCode}
</select>
package com.hhwy.fm.projectapproval.domain;

import java.util.UUID;
import javax.persistence.*;
import com.hhwy.framework.annotation.PropertyDesc;
import com.hhwy.framework.persistent.entity.Domain;

/**
 * <br>描 述:项目立项(项目表)
 * <br>创 建 人:Jinzhaoqiang
 * <br>创建时间:
 * <br>修改备注:无
 * <br>版本:1.0.0
 */
@Entity(name="ProjectApproval")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@Table(name="t_project_approval")
public class ProjectApproval extends Domain{

   private static final long serialVersionUID = 7119079399916219284L;

   @Id
   @Column(
         name = "id",
         length = 32
   )
   private String id = UUID.randomUUID().toString().replace("-", "");

    @Column(name="prj_code", columnDefinition="varchar(15) comment '项目编号'")
    private String prjCode;

   @Column(name="prj_status", columnDefinition="varchar(2) comment '状态:1待储备、2储备中、3已储备、4形式内审中、5待函审、6项目函审中、7待立项、8终止中、9已终止、10立项中、11已立项'")
   private String prjStatus;


    @PropertyDesc("项目状态名称")
    @Transient
    private String prjStatusName;

    @PropertyDesc("工程名称")
    @Transient
    private String prjName;

   @Override
   public String getId() {
      return id;
   }

   @Override
   public void setId(String id) {
      this.id = id;
   }

   public String getPrjCode() {
      return prjCode;
   }

   public void setPrjCode(String prjCode) {
      this.prjCode = prjCode;
   }

   public String getPrjStatus() {
      return prjStatus;
   }

   public void setPrjStatus(String prjStatus) {
      this.prjStatus = prjStatus;
   }

   public String getPrjStatusName() {
      return prjStatusName;
   }

   public void setPrjStatusName(String prjStatusName) {
      this.prjStatusName = prjStatusName;
   }

   public String getPrjName() {
      return prjName;
   }

   public void setPrjName(String prjName) {
      this.prjName = prjName;
   }
}
ProjectApproval projectApproval = (ProjectApproval)dao.getOneBySQL("projectapproval.sql.testPositionSelect",id);
04-08 14:30