码迷,mamicode.com
首页 > 其他好文 > 详细

What does addScalar do?

时间:2014-06-17 21:28:36      阅读:236      评论:0      收藏:0      [点我收藏+]

标签:class   code   java   ext   com   string   

The JavaDoc says:

SQLQuery org.hibernate.SQLQuery.addScalar(String columnAlias, Type type)

Declare a scalar query result

I know what executeScalar is in C#, but this scalar and C# scalar seem to be absolutely different.

 

This is declaring that you want the result of the query to return objects for individual named columns, rather than entities. For instance

createSQLQuery("SELECT COUNT(*) AS c FROM Users").addScalar("c").uniqueResult()

Will return a single Long. If you specify multiple scalars, the result will come back as an array of Object. Its similar to executeScalar except that it works on named columns, and can return a composite result.

 

What does addScalar do?,布布扣,bubuko.com

What does addScalar do?

标签:class   code   java   ext   com   string   

原文地址:http://www.cnblogs.com/reynold-lei/p/3792079.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!