标签: mappers

在多个mapper.xml中重用MyBatis ResultMap

我想重新使用来自不同*Mapper.xml文件的特定文件,这些文件都以某种方式读取相同的对象.

我有一个名为Project的数据库表,我创建了以下resultMap:

<resultMap id="ProjectMap" type="com.model.Project">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="client_prj_no" jdbcType="VARCHAR" property="clientPrjNo" />
    <result column="notes" jdbcType="VARCHAR" property="notes" />
    <result column="start_date" jdbcType="TIMESTAMP" property="startDate" />
    ...
<resultMap>
Run Code Online (Sandbox Code Playgroud)

它在ProjectMapper.xml中工作得很好,但是,现在我想创建一个ClientWithProjectsMapper.xml,我想要SELECT*FROM CLIENT,PROJECT,其中PROJECT.CLIENT_ID = CLIENT.ID并且Client对象返回一个List对象.换句话说,我想用一个SQL获取ClientWithProjects.

在我的映射中,我想重用我在ProjectMapper.xml中定义的ProjectMap(没有复制/粘贴),但我不知道如何实现这一点.

我可以将ProjectMap分解为一个单独的文件,但我没有在MyBatis中找到#include其他文件的任何工具.

关于如何做到这一点的任何想法?(我正在使用Maven,是否有任何插件可以过滤寻找#include等文件,并将文件内容直接包含在正在处理的文件中?).

谢谢.

-AP_

refactoring resultset mappers mybatis

17
推荐指数
1
解决办法
2万
查看次数

Mappers,Reducers,FIlters

我知道map/reduce alghoritm及其用途.它使用的是名为Mappers和Reducers的函数,但我也发现人们使用的是Filters.

过滤器与Mappers相同还是有一些显着差异?

mapreduce filter mappers reducers

1
推荐指数
1
解决办法
286
查看次数

标签 统计

mappers ×2

filter ×1

mapreduce ×1

mybatis ×1

reducers ×1

refactoring ×1

resultset ×1