1.注解的方式:
@Select("select * from user_collection uc left join post p on uc.post_id = p.id ${ew.customSqlSegment}")
IPage<Post> selectPosts(Page page, @Param(Constants.WRAPPER) QueryWrapper wrapper);
使用注解方式只需添加 ${ew.customSqlSegment}和@Param(Constants.WRAPPER)即可!
2.xml方式
IPage<Post> selectPosts(Page page, @Param(Constants.WRAPPER) QueryWrapper wrapper);
<!--xml-->
<select id="selectPosts" resultType="com.example.entity.Post">
select * from user_collection uc left join
post p on uc.post_id = p.id
${ew.customSqlSegment}
</select>
动态查找:
@Select("select ${ew.SqlSelect} from ${tableName} ${ew.customSqlSegment}")
List<File> listFileByCondition(@Param("tableName") String tableName, @Param("ew") Wrapper wrapper);
ew.SqlSelect:所需要查找的字段 、tableName:使用的是那张表、ew.customSqlSegment:条件
来源:oschina
链接:https://my.oschina.net/jacklinnn/blog/3217863