开发者

Nested Select Using HQL

I would just like to know if derived queries can be handled by HQL? I have this bit of code right here and it kept on saying that it did not expect the '(' symbol right after the first FROM keyword. Your help will be much appreciated. Thanks.

"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.require开发者_运维百科ments) 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))";


would you consider to implement using ICriteria instead of HQL? it make the code more readable and programmable.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜