I displayed this class
@Entity @Table(name = "USERS") public class User { private long id; private String userName; }
and I make a request:
Query query = session.createQuery("select id, userName, count(userName) from User order by count(userName) desc"); return query.list();
How do I access the values returned by a query?
I mean, how should I handle query.list ()? As a user or what?
To strictly answer your question, queries that define a class property in a select clause (and, optionally, calls to aggregate functions) return "scalar" results, i.e. a Object[](or a List<Object[]>). See 10.4.1.3. Scalar results .
Object[]
List<Object[]>
But your current request is not working. You will need something like this:
select u.userName, count(u.userName) from User2633514 u group by u.userName order by count(u.userName) desc
, Hibernate , , . (.. "Count ( )" ), "group by" .
, Hibernate , , , , Object [], Hibernate ( ) ) " .
, , Hibernate , / /. , , Hibernate, .
Source: https://habr.com/ru/post/1741001/More articles:Why is "A & a = a" valid? - c ++ClickOnce + .NET + SQL Server Compact click template + standalone installation - c #Return DTO and DataTable from DAL - datasetWhat happened if the exception is not fixed? - c ++C ++ provides conditions for inherited classes - c ++https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1741002/r-how-to-write-out-a-dataframe-so-that-i-can-paste-it-into-so-for-others-to-read&usg=ALkJrhhgUS5qL-ITox0feFfXTDoQZCL1WwПроблема с яйцом python cx_Freeze - pythonIs there any way to name external flows? - multithreadingSharing & rest-parameters lisp - common-lispSetThreadName does not work with Visual Studio 2005 - c ++All Articles