0
請在jpql中有此查詢我想遷移到條件。你怎麼樣?如何將jqpl查詢遷移到Criteria API
查詢:
SELECT c FROM Cartera c,Cliente cli WHERE c.aseId = :aseId and cli.aseId=c.aseId
感謝
請在jpql中有此查詢我想遷移到條件。你怎麼樣?如何將jqpl查詢遷移到Criteria API
查詢:
SELECT c FROM Cartera c,Cliente cli WHERE c.aseId = :aseId and cli.aseId=c.aseId
感謝
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Cartera> query = cb.createQuery(Cartera.class);
Root<Cartera> cartera = query.from(Cartera.class);
Root<Cliente> cliente = query.from(Cliente.class);
query.select(cartera);
query.where(cb.equal(cartera.get(Cartera_.aseId), theAseId),
cb.equal(cliente.get(Cliente_.aseId), theAseId));
應該做的伎倆。雖然沒有測試過。
JB Nizet的答案後,你還必須有
TypedQuery<Cartera> tq = em.createQuery(query);
tq.setFirstResult(offset); // how many records to skip
tq.setMaxResults(pageSize); // don't want to fetch a million records
List<Cartera> list = tq.getResultList();
是的,它的工作對我來說謝謝 – ArokLair