yulichang / mybatis-plus-join

支持连表查询的mybatis-plus,mybatis-plus风格的连表操作提供wrapper.leftJoin(),wrapper.rightJoin()等操作
https://yulichang.github.io/mybatis-plus-join-doc/
Apache License 2.0
971 stars 113 forks source link

join 分页查询结果不对 #117

Closed kuaidaoqingyi1 closed 2 months ago

kuaidaoqingyi1 commented 2 months ago

当前使用版本(必填,否则不予处理)

1.4.10

该问题是如何引起的?(确定最新版也有问题再提!!!)

    MPJLambdaWrapper<PolicyEntity> wrapper = new MPJLambdaWrapper<>(PolicyEntity.class);
    wrapper.selectCollection(PolicyConditionEntity.class, Policy::getPolicyConditions)
            .leftJoin(PolicyConditionEntity.class, PolicyConditionEntity::getPolicyId, PolicyEntity::getId)
            .selectCollection(ProjectEntity.class,Policy::getProjects)
            .leftJoin(PolicyProjectsEntity.class, PolicyProjectsEntity::getPolicyId, PolicyEntity::getId)
            .leftJoin(ProjectEntity.class, ProjectEntity::getId, PolicyProjectsEntity::getProjectId)
            .selectCollection(TagEntity.class,Policy::getTags)
            .orderByAsc(PolicyEntity::getName);

IPage result = baseMapper.selectJoinPage(new Page(pageNumber,pageSize),Policy.class ,wrapper);

重现步骤(如果有就写完整)

报错信息

==> Preparing: SELECT COUNT(*) AS total FROM POLICY t WHERE (t.name LIKE ?) ==> Parameters: %%(String) <== Columns: total <== Row: 22 <== Total: 1

==> Preparing: SELECT t.id,t.include_children,t.name,t.operator,t.uuid,t.VIOLATIONSTATE,t1.id AS joina_id,t1.operator AS joina_operator,t1.subject,t1.uuid AS joina_uuid,t1.value,t3.id AS joinb_id,t3.author,t3.publisher,t3.GROUP,t3.name AS joina_name,t3.description,t3.version,t3.classifier,t3.cpe,t3.purl,t3.SWIDTAGID,t3.UUID,t3.PARENT_PROJECT_ID,t3.LAST_BOM_IMPORTED,t3.LAST_RISKSCORE,t3.active,t3.direct_dependencies,t3.external_references,t.id AS joinc_id,t.name AS joinb_name FROM POLICY t LEFT JOIN POLICYCONDITION t1 ON (t1.policy_id = t.id) LEFT JOIN POLICY_PROJECTS t2 ON (t2.policy_id = t.id) LEFT JOIN PROJECT t3 ON (t3.id = t2.project_id) WHERE (t.name LIKE ?) ORDER BY t.name ASC LIMIT ? ==> Parameters: %%(String), 10(Long) <== Columns: id, include_children, name, operator, uuid, VIOLATIONSTATE, joina_id, joina_operator, subject, joina_uuid, value, joinb_id, author, publisher, GROUP, joina_name, description, version, classifier, cpe, purl, SWIDTAGID, UUID, PARENT_PROJECT_ID, LAST_BOM_IMPORTED, LAST_RISKSCORE, active, direct_dependencies, external_references, joinc_id, joinb_name <== Row: 20, 1, 11, ALL, b9354239-d80b-4142-b8fa-c657963253b9, FAIL, 20, IS_NOT, SEVERITY, 5745bda8-e26a-40c3-8393-2b4d2f7d4599, HIGH, 27, author111, buzhongy, 1231, 12345556, 1231, 1231, APPLICATION, 1312, pkg:maven/com.example/example@1.0.0#123, 23123, 98282097-2dc8-4a48-88f8-4502a0ceef16, 1, null, 0.0, null, <>, <>, 20, 11 <== Row: 20, 1, 11, ALL, b9354239-d80b-4142-b8fa-c657963253b9, FAIL, 20, IS_NOT, SEVERITY, 5745bda8-e26a-40c3-8393-2b4d2f7d4599, HIGH, 25, author111, buzhongy, 1231, 123455, 1231, 1231, APPLICATION, 1312, pkg:maven/com.example/example@1.0.0#123, 23123, a8378e39-41cb-41e2-ae34-2cfefba1157f, 1, null, 0.0, null, <>, <>, 20, 11 <== Row: 20, 1, 11, ALL, b9354239-d80b-4142-b8fa-c657963253b9, FAIL, 20, IS_NOT, SEVERITY, 5745bda8-e26a-40c3-8393-2b4d2f7d4599, HIGH, 28, author111, buzhongy, 1231, 1234555776, 1231, 1231, APPLICATION, null, pkg:maven/com.example/example@1.0.0#123, 23123, b2fb148c-66d5-4cfa-83d5-0ada12f3b94b, 1, null, 0.0, null, <>, <>, 20, 11 <== Row: 20, 1, 11, ALL, b9354239-d80b-4142-b8fa-c657963253b9, FAIL, 20, IS_NOT, SEVERITY, 5745bda8-e26a-40c3-8393-2b4d2f7d4599, HIGH, 1, null, null, null, 123, null, 1213, APPLICATION, null, null, null, 46318785-d33a-44b2-93fb-2b433ed77fd3, null, null, 0.0, 1, <>, <>, 20, 11 <== Row: 20, 1, 11, ALL, b9354239-d80b-4142-b8fa-c657963253b9, FAIL, 20, IS_NOT, SEVERITY, 5745bda8-e26a-40c3-8393-2b4d2f7d4599, HIGH, 29, author111, buzhongy, 1231, 12345557786, 1231, 1231, APPLICATION, null, pkg:maven/com.example/example@1.0.0#123, 23123, 43aa8b40-1e6c-484f-9d0b-07d4a2cda184, 1, null, 0.0, null, <>, <>, 20, 11 <== Row: 20, 1, 11, ALL, b9354239-d80b-4142-b8fa-c657963253b9, FAIL, 20, IS_NOT, SEVERITY, 5745bda8-e26a-40c3-8393-2b4d2f7d4599, HIGH, 30, author111, buzhongy, 1231, 123455578786, 1231, 1231, APPLICATION, null, pkg:maven/com.example/example@1.0.0#123, 23123, f45cab66-4be0-4890-b4b3-c05895d356c1, 1, null, 0.0, null, <>, <>, 20, 11 <== Row: 20, 1, 11, ALL, b9354239-d80b-4142-b8fa-c657963253b9, FAIL, 20, IS_NOT, SEVERITY, 5745bda8-e26a-40c3-8393-2b4d2f7d4599, HIGH, 14, author2222, buzhongy, 1231, 12345557786, 1231, 1231, APPLICATION, 1312, pkg:maven/com.example/example@1.0.0#123123312324321412, 23123, e2c3ec6a-6bf1-4122-a46a-b08260aec7d6, 1, null, 0.0, null, <>, <>, 20, 11 <== Row: 20, 1, 11, ALL, b9354239-d80b-4142-b8fa-c657963253b9, FAIL, 20, IS_NOT, SEVERITY, 5745bda8-e26a-40c3-8393-2b4d2f7d4599, HIGH, 31, null, null, group1, testsq, afdaf, 1.21, APPLICATION, cpe1, pur1, stid, 774a51df-b8e6-4f6f-8801-49d86cb1a02c, 28, null, 0.0, null, <>, <>, 20, 11 <== Row: 20, 1, 11, ALL, b9354239-d80b-4142-b8fa-c657963253b9, FAIL, 20, IS_NOT, SEVERITY, 5745bda8-e26a-40c3-8393-2b4d2f7d4599, HIGH, 26, author111, buzhongy, 1231, 1234556, 1231, 1231, APPLICATION, 1312, pkg:maven/com.example/example@1.0.0#123, 23123, 89785662-8a51-4111-a624-7d1b7343cdbe, 1, null, 0.0, null, <>, <>, 20, 11 <== Row: 20, 1, 11, ALL, b9354239-d80b-4142-b8fa-c657963253b9, FAIL, 20, IS_NOT, SEVERITY, 5745bda8-e26a-40c3-8393-2b4d2f7d4599, HIGH, 1, null, null, null, 123, null, 1213, APPLICATION, null, null, null, 46318785-d33a-44b2-93fb-2b433ed77fd3, null, null, 0.0, 1, <>, <>, 20, 11 <== Total: 10

image
yulichang commented 2 months ago

https://github.com/baomidou/mybatis-plus/issues/5923