我想知道HQL是否可以处理派生查询?我在这里有一些代码,它继续说它不会在第一个FROM关键字之后的'('符号)。你的帮助将非常感谢。谢谢。
"SELECT new " + Distribution.class.getName() + " (adhoc, deployment, design, development, " +
"enhancement, requirements, testing) FROM (" +
"SELECT AVG(week_adhoc) as adhoc, AVG(week_deployment) as deployment, AVG(week_design) as design," +
"AVG(week_development) as development, AVG(week_enhancement) as enhancement, AVG(week_requirements) as requirements," +
" AVG(week_testing) as testing, AVG(week_training) as training FROM " +
"(SELECT dist.id, sum(dist.adhoc) as week_adhoc, sum(dist.deployment) as week_deployment," +
"sum(dist.design) as week_design, sum(dist.development) as week_development," +
"sum(dist.enhancement) as week_enhancement, sum(dist.requirements) as week_requirements," +
"sum(dist.testing) as week_testing, sum(dist.training) as week_training from " + Distribution.class.getName() + " dist " +
"where dist.week=1 and dist.month=1 and dist.year=2010 group by dist.id))";
答案 0 :(得分:0)
您会考虑使用ICriteria而不是HQL来实现吗? 它使代码更具可读性和可编程性。