简体   繁体   English

基本类型的MyBatis映射巢pojo

[英]MyBatis mapping nest pojo of fundamental type

I have a POJO of type:我有一个 POJO 类型:

POJO {

int id;
int name;
List<Date> Dates;

}

Now my POJO is broken into two tables x and y, where y have dates and x have name, which are joined over the id as below:现在我的 POJO 分为两个表 x 和 y,其中 y 有日期,x 有名称,它们通过 id 连接,如下所示:

select * from x
join y on x.id = y.id

Further now I want to select from mybatis mapper and map it to the given pojo.现在我想从 mybatis 映射器中选择并将其映射到给定的 pojo。 I am getting issue in mapping the Dates.我在映射日期时遇到问题。

    <resultMap id="pojo" type="Pojo">
    <result property="id" column="id" javaType="Integer"/>
    <result property="name" column="name" javaType="String"/>
    <result property="Dates" column="date" javaType="ArrayList" typeHandler="org.apache.ibatis.type.DateTypeHandler"/>
</resultMap>

I tried using collection but I don't have any property within the Dates.我尝试使用集合,但日期中没有任何属性。 How to populate the dates field ?如何填充日期字段?

<collection property="Dates" ofType="java.util.Date">
            <result column="date" />
        </collection>

This worked这有效

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM