您的位置:首页 > 其它

mybatis 多层select示例

2016-05-14 00:00 232 查看
摘要: mybatis 多层select示例

实体类

package com.yonyou.iuap.entity.quotation;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

public class IpuQuotation implements Serializable {

private static final long serialVersionUID = -9169987729255268660L;

private String ipuquotaionid;

private Date buyoffertime;

private String contact;

private Date createtime;

private String description;

private String phone;

private Date processtime;

private String processor;

private Date qtexpiredate;

private String subject;

private Date ts;

private Short dr;

private List<IpuQuotationDetail> datailentitylist;

public String getIpuquotaionid() {
return ipuquotaionid;
}

public void setIpuquotaionid(String ipuquotaionid) {
this.ipuquotaionid = ipuquotaionid == null ? null : ipuquotaionid.trim();
}

public Date getBuyoffertime() {
return buyoffertime;
}

public void setBuyoffertime(Date buyoffertime) {
this.buyoffertime = buyoffertime;
}

public String getContact() {
return contact;
}

public void setContact(String contact) {
this.contact = contact == null ? null : contact.trim();
}

public Date getCreatetime() {
return createtime;
}

public void setCreatetime(Date createtime) {
this.createtime = createtime;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description == null ? null : description.trim();
}

public String getPhone() {
return phone;
}

public void setPhone(String phone) {
this.phone = phone == null ? null : phone.trim();
}

public Date getProcesstime() {
return processtime;
}

public void setProcesstime(Date processtime) {
this.processtime = processtime;
}

public String getProcessor() {
return processor;
}

public void setProcessor(String processor) {
this.processor = processor == null ? null : processor.trim();
}

public Date getQtexpiredate() {
return qtexpiredate;
}

public void setQtexpiredate(Date qtexpiredate) {
this.qtexpiredate = qtexpiredate;
}

public String getSubject() {
return subject;
}

public void setSubject(String subject) {
this.subject = subject == null ? null : subject.trim();
}

public Date getTs() {
return ts;
}

public void setTs(Date ts) {
this.ts = ts;
}

public Short getDr() {
return dr;
}

public void setDr(Short dr) {
this.dr = dr;
}

public List<IpuQuotationDetail> getDatailentitylist() {
return datailentitylist;
}

public void setDatailentitylist(List<IpuQuotationDetail> datailentitylist) {
this.datailentitylist = datailentitylist;
}
}

Xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yonyou.iuap.repository.quotation.IpuQuotationMapper">
<resultMap id="BaseResultMap" type="com.yonyou.iuap.entity.quotation.IpuQuotation">
<id column="ipuquotaionid" property="ipuquotaionid" jdbcType="CHAR"/>
<result column="buyoffertime" property="buyoffertime" jdbcType="TIMESTAMP"/>
<result column="contact" property="contact" jdbcType="VARCHAR"/>
<result column="createtime" property="createtime" jdbcType="TIMESTAMP"/>
<result column="description" property="description" jdbcType="VARCHAR"/>
<result column="phone" property="phone" jdbcType="VARCHAR"/>
<result column="processtime" property="processtime" jdbcType="TIMESTAMP"/>
<result column="processor" property="processor" jdbcType="VARCHAR"/>
<result column="qtexpiredate" property="qtexpiredate" jdbcType="TIMESTAMP"/>
<result column="subject" property="subject" jdbcType="VARCHAR"/>
<result column="ts" property="ts" jdbcType="TIMESTAMP"/>
<result column="dr" property="dr" jdbcType="SMALLINT"/>
</resultMap>

<sql id="Base_Column_List">
ipuquotaionid, buyoffertime, contact, createtime, description, phone, processtime,
processor, qtexpiredate, subject, ts, dr
</sql>

<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select test.ipuquotaionid from
(select
<include refid="Base_Column_List"/>
from ipuquotation
where ipuquotaionid = #{ipuquotaionid}) as test
</select>
</mapper>

直接用括号扩起 加上别名就可以了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: