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.

 

相关文章:

  • 2022-02-18
  • 2021-10-13
  • 2022-12-23
  • 2021-06-11
  • 2021-07-31
  • 2021-05-27
  • 2022-01-19
  • 2021-09-26
猜你喜欢
  • 2021-12-08
  • 2021-11-11
  • 2021-05-20
  • 2021-12-30
  • 2021-07-28
  • 2021-06-24
  • 2021-11-14
相关资源
相似解决方案