<?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="dao.IHouseDao">
<resultMap type="bean.House" id="houseMap">
<id property="id" column="hid"/>
<result property="title" column="title"/>
<result property="price" column="price"/>
<result property="contact" column="contact"/>
<result property="pubDate" column="pubdate"/>
<result property="description" column="description"/>
<result property="floorAge" column="floorage"/>
<association property="type" javaType="bean.Type">
<id property="id" column="tid"/>
<result property="name" column="tname"/>
</association>
<association property="user" javaType="bean.User">
<id property="id" column="usid"/>
<result property="name" column="uname"/>
<result property="userName" column="username"/>
<result property="telePhone" column="telephone"/>
<result property="isAdmin" column="isadmin"/>
<result property="passWord" column="password"/>
</association>
<association property="street" javaType="bean.Street">
<id property="id" column="sid"/>
<result property="name" column="sname"/>
<association property="district" javaType="bean.District">
<id property="id" column="did"/>
<result property="name" column="dname"/>
</association>
</association>
</resultMap>
<select id="getByUserId" resultMap="houseMap" parameterType="int">
<!-- 这里的SQL结尾不能加分号,否则报"ORA-00911错误" -->
select h.id as hid,t.id as tid,s.id as sid,d.id as did, u.id as usid,
t.name as tname,s.name as sname,u.name as uname,d.name as dname,
h.*,s.*,u.*,d.*,t.*
from house h,users u,types t,street s,district d
where h.user_id=u.id
and h.type_id=t.id
and h.street_id=s.id
and s.district_id=d.id
and h.user_id=#{uid}
</select>
</mapper>
mybatis五表连接
最新推荐文章于 2023-01-30 21:36:33 发布