WITH Clause: Subquery Factoring Using Hibernate

WITH dept_count AS (
  SELECT deptno, COUNT(*) AS dept_count
  FROM   emp
  GROUP BY deptno)
SELECT e.ename AS employee_name,
       dc.dept_count AS emp_dept_count
FROM   emp e,
       dept_count dc
WHERE  e.deptno = dc.deptno;

      

How can we map the data obtained from the previous query (the average temporary table dept_count created due to the use of WITH CLAUSE ) into the following java class?

My Java class has the following attributes: employee_name, emp_dept_count.

+3


source to share


1 answer


Use your own SQL query with AliasToBeanResultTransformer ( http://docs.jboss.org/hibernate/orm/3.3/api/org/hibernate/transform/AliasToBeanResultTransformer.html ).



0


source







All Articles