package com.wzkj.web.entity; import java.sql.Timestamp; import java.util.Date; import java.util.List; import org.apache.ibatis.type.Alias; public class Route { private Long id; private Long type_id; private String route_name; private String route_profile; private Float distance; private String tips; private boolean is_top; private String cover_img; private Long view_count; private Timestamp create_time; private List<RoutePoint> list; public String getRoute_name() { return route_name; } public void setRoute_name(String route_name) { this.route_name = route_name; } public String getRoute_profile() { return route_profile; } public void setRoute_profile(String route_profile) { this.route_profile = route_profile; } public Float getDistance() { return distance; } public void setDistance(Float distance) { this.distance = distance; } public String getTips() { return tips; } public void setTips(String tips) { this.tips = tips; } public boolean isIs_top() { return is_top; } public void setIs_top(boolean is_top) { this.is_top = is_top; } public Timestamp getCreate_time() { return create_time; } public void setCreate_time(Timestamp create_time) { this.create_time = create_time; } public Long getId() { return id; } public void setId(Long id) { this.id = id; } public Long getType_id() { return type_id; } public void setType_id(Long type_id) { this.type_id = type_id; } public Long getView_count() { return view_count; } public void setView_count(Long view_count) { this.view_count = view_count; } public String getCover_img() { return cover_img; } public void setCover_img(String cover_img) { this.cover_img = cover_img; } public List<RoutePoint> getList() { return list; } public void setList(List<RoutePoint> list) { this.list = list; } }
package com.wzkj.web.entity; public class RoutePoint { private Long id; private Long route_id; private String point_name; private Long priority; private Float longitude; private Float latitude; private String point_profile; private Route route; public String getPoint_name() { return point_name; } public void setPoint_name(String point_name) { this.point_name = point_name; } public Float getLatitude() { return latitude; } public void setLatitude(Float latitude) { this.latitude = latitude; } public String getPoint_profile() { return point_profile; } public void setPoint_profile(String point_profile) { this.point_profile = point_profile; } public Float getLongitude() { return longitude; } public void setLongitude(Float longitude) { this.longitude = longitude; } public Long getId() { return id; } public void setId(Long id) { this.id = id; } public Long getRoute_id() { return route_id; } public void setRoute_id(Long route_id) { this.route_id = route_id; } public Long getPriority() { return priority; } public void setPriority(Long priority) { this.priority = priority; } public Route getRoute() { return route; } public void setRoute(Route route) { this.route = route; } }
Mapper
package com.wzkj.manage.mapper; import java.util.List; import org.apache.ibatis.annotations.DeleteProvider; import org.apache.ibatis.annotations.InsertProvider; import org.apache.ibatis.annotations.Options; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Result; import org.apache.ibatis.annotations.ResultMap; import org.apache.ibatis.annotations.SelectProvider; import org.apache.ibatis.annotations.UpdateProvider; import org.apache.ibatis.annotations.Many; import com.wzkj.manage.mapper.provider.RouteProvider; import com.wzkj.web.entity.Route; public interface RouteMapper { @SelectProvider(type = RouteProvider.class, method = "getById") @Options(flushCache = true, timeout = 20000) @ResultMap(value ="RouteResult") public Route getById(@Param("id") int id); }
xml 文件
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN" "http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd"> <mapper namespace="com.wzkj.manage.mapper.RouteMapper"> <resultMap id="RouteResult" type="com.wzkj.web.entity.Route"> <id property="id" column="id" javaType="long" jdbcType="NUMERIC" /> <id property="type_id" column="type_id" javaType="long" jdbcType="NUMERIC" /> <id property="route_name" column="route_name" javaType="string" jdbcType="VARCHAR" /> <id property="route_profile" column="route_profile" javaType="string" jdbcType="VARCHAR" /> <id property="distance" column="distance" javaType="float" jdbcType="FLOAT" /> <id property="tips" column="tips" javaType="string" jdbcType="VARCHAR" /> <id property="is_top" column="is_top" javaType="boolean" jdbcType="TINYINT" /> <id property="cover_img" column="cover_img" javaType="string" jdbcType="VARCHAR" /> <id property="view_count" column="view_count" javaType="long" jdbcType="NUMERIC" /> <id property="create_time" column="create_time" javaType="java.sql.Timestamp" jdbcType="TIMESTAMP" /> <collection property="list" select="RoutePointResult" column="id" ></collection> </resultMap> <select id="RoutePointResult" parameterType="int" resultType="com.wzkj.web.entity.RoutePoint"> select * from wz_route_point where route_id = #{id} </select> </mapper>