Now I study to work with a database, with Hibernate. On the Internet I found examples for reading data from a database, for example:

String hql = "select * from table_name"; SQLQuery query = session.createSQLQuery(hql); List results = query.list(); 

So here is the question. I cannot find the value of the list() method anywhere, what is it doing in this case? and how does it work?

    2 answers 2

    The first search result for the "hibernate query list":

    Queries are executed by calling list () ...

    In other words, the query is executed by calling the list() method.

    It differs from executeUpdate() in that executeUpdate() used in INSERT , DELETE , UPDATE queries, and list() also used in SELECT queries.

    • Thank you) I did not write the correct query in the search engine) I will now read) - Vorobey.A
    • one
      @ Vorobey.A good luck) if you were given the correct answer, do not forget to check it so that other visitors to this page see the correct answer. - Denis

    The SQLQuery.list method returns the result of the query in the form of a List , or Object [] .