在我的java BackEnd中我使用EclipseLink作为ORM。一切都很好,直到昨天。当我想从db获取数据时,ORM的查询只从mysql db获取1行,但是在调试时我得到生成的sql字符串并在MySQL Workbench中运行它,我得到200多行(正确的数字)。我不明白为什么在代码查询中没有按预期工作。这是我的问题:
String queryString = "select c from Contract c " +
"join c.contractForms cf " +
"join c.insuredPerson per " +
"join c.paymentGraphs pg " +
"join c.payments pm " +
"join cf.company com " +
"join cf.curator cur " +
"join cf.insuranceType insType " +
"where c.state = :state " +
"and cf.state = :state and pg.state = :state and pm.state = :state ";
Query query= em.createQuery(queryString).setParameter("state", "A");
这个是生成sql String:
SELECT *
FROM Contract t1 LEFT OUTER JOIN ContractForm t2 ON (t2.CONTRACT_ID = t1.ID)
LEFT OUTER JOIN PaymentGraph t4 ON (t4.CONTRACT_ID = t1.ID)
LEFT OUTER JOIN Payment t5 ON (t5.CONTRACT_ID = t1.ID)
LEFT OUTER JOIN Claim t0 ON (t0.CONTRACT_ID = t1.ID)
LEFT OUTER JOIN OfferForm t3 ON (t3.CONTRACT_ID = t1.ID)
LEFT OUTER JOIN ReinsuranceForm t6 ON (t6.CONTRACT_ID = t1.ID)
LEFT OUTER JOIN ReinsuranceOfferForm t7 ON (t7.CONTRACT_ID = t1.ID)
LEFT OUTER JOIN ReinsurerData t8 ON (t8.CONTRACT_ID = t1.ID)
LEFT OUTER JOIN Workflow t9 ON (t9.CONTRACT_ID = t1.ID)
, ReferenceData t11, InsuredPerson t10, ReferenceData t13, ReferenceData t12
WHERE (((((t1.STATE = 'A') AND (t2.STATE = 'A')) AND (t4.STATE = 'A')) AND (t5.STATE = 'A')) AND
((((t10.ID = t1.PERSON_ID) AND (t11.ID = t2.CONTRACT_COMPANY_ID)) AND (t12.ID = t2.CURATOR_ID)) AND
(t13.ID = t2.INSURANCE_TYPE)))
ORDER BY t2.CONTRACT_DATE DESC
我无法找到解决此问题的方法。谁能说出问题是什么以及如何解决?