简体   繁体   中英

MyBatis mapper with DTO

Is it posible to use DTO objects in MyBatis mapper? For example, replace following never-ending signature of method findPolicy

@Mapper
public interface PolicyMapper {
    List<Policy> findPolicy(
            @Param("partnerId") Long partnerId,
            @Param("policyNo") Long policyNo,
            @Param("policyStatus") Integer policyStatus,
            @Param("policyOpenDateFrom") Date policyOpenDateFrom,
            @Param("policyOpenDateTo") Date policyOpenDateTo,
            @Param("policyFinalDateFrom") Date policyFinalDateFrom,
            @Param("policyFinalDateTo") Date policyFinalDateTo,
            // ....

with simple DTO object?

@Mapper
public interface PolicyMapper {
    List<Policy> findPolicy(@ParametersAutoBinding PolicyFilterDto filter);
)

Of course with:

List<Policy> findPolicy(PolicyFilterDto filter);

you access directly to properties of PoliceFilterDto .

Parameters have to be named when there are multiple.

List<Policy> findPolicy(@Param("filter") PolicyFilterDto filter, @Param("another") AnotherDto another);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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