Closed yidasanqian closed 2 years ago
unexpected token: UNION
provider:
Fenix.start() .select("t1.orgName as orgName, t1.orgType as orgType, t3.mchName as mchName") .from("OrgInfo").as("t1") .leftJoin("OrgHospital").as("t2") .on("t1.orgId = t2.hospitalId") .leftJoin("Mch").as("t3") .on("t2.mchId = t3.mchId") .whereDynamic() .andLike("t3.mchName", params.getMchName(), StringUtils.hasText(params.getMchName())) .andLike("t1.orgName", params.getOrgName(), StringUtils.hasText(params.getOrgName())) .andEqual("t1.orgType", params.getOrgType(), Objects.nonNull(params.getOrgType())) .andEqual("t1.status", params.getStatus(), Objects.nonNull(params.getStatus())) .between("t1.createDt", params.getStart(), params.getEnd(), params.getStart() != null && params.getEnd() != null) .union() .select("t1.orgName as orgName, t1.orgType as orgType, t3.mchName as mchName") .from("OrgInfo").as("t1") .leftJoin("OrgDrugstore").as("t2") .on("t1.orgId = t2.storeId") .leftJoin("Mch").as("t3") .on("t2.mchId = t3.mchId") .whereDynamic() .andLike("t3.mchName", params.getMchName(), StringUtils.hasText(params.getMchName())) .andLike("t1.orgName", params.getOrgName(), StringUtils.hasText(params.getOrgName())) .andEqual("t1.orgType", params.getOrgType(), Objects.nonNull(params.getOrgType())) .andEqual("t1.status", params.getStatus(), Objects.nonNull(params.getStatus())) .between("t1.createDt", params.getStart(), params.getEnd(), params.getStart() != null && params.getEnd() != null) .end() .setResultTypeClass(OrgInfoVo.class);
@yidasanqian 这个 SQL 点复杂,你得看看生成的 SQL 结果字符串是长啥样的,比较长的 SQL 一般都建议写到 XML 里面的,不然,后续不好维护。
长久未回复,将关闭此 issue。
issue
unexpected token: UNION
provider: