将 oracle 游标转换为 jpa 条件查询
Converting oracle cursor to jpa criteria query
我有办法在 java jpa 条件查询中写这个游标...
cursor main_1 is
select join_date,sum(tot_sal),emp_name
from emp_datail,emp_join
where emp_id=emp_join_id and join_date=to_date('14/02/2015','dd/mm/yyyy')
and per_sal>100000
group by join_date,emp_name
提前致谢。
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Object[]> cq = cb.createQuery(Object[].class);
Root<Org> orgRoot = cq.from(Org.class);
Join<Org, Dept> ord = orgRoot.join("dept");
cq.multiselect(orgRoot.get("orgname"), ord.get("deptname"),
cb.sum(ord.<Integer> get("deptamt"))).groupBy(
orgRoot.get("orgname"));
Query qry = em.createQuery(cq);
List<Object[]> orgList = qry.getResultList();
我有办法在 java jpa 条件查询中写这个游标...
cursor main_1 is
select join_date,sum(tot_sal),emp_name
from emp_datail,emp_join
where emp_id=emp_join_id and join_date=to_date('14/02/2015','dd/mm/yyyy')
and per_sal>100000
group by join_date,emp_name
提前致谢。
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Object[]> cq = cb.createQuery(Object[].class);
Root<Org> orgRoot = cq.from(Org.class);
Join<Org, Dept> ord = orgRoot.join("dept");
cq.multiselect(orgRoot.get("orgname"), ord.get("deptname"),
cb.sum(ord.<Integer> get("deptamt"))).groupBy(
orgRoot.get("orgname"));
Query qry = em.createQuery(cq);
List<Object[]> orgList = qry.getResultList();