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>

直接用括号扩起 加上别名就可以了

转载于:https://my.oschina.net/superise/blog/675162

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值