このコンテンツは選択した言語では利用できません。
10.5.2. Executing Queries
HQL and native SQL queries are represented with an instance of
org.hibernate.Query
. This interface offers methods for parameter binding, result set handling, and for the execution of the actual query. You always obtain a Query
using the current Session
:
A query is usually executed by invoking
list()
. The result of the query will be loaded completely into a collection in memory. Entity instances retrieved by a query are in a persistent state. The uniqueResult()
method offers a shortcut if you know your query will only return a single object. Queries that make use of eager fetching of collections usually return duplicates of the root objects, but with their collections initialized. You can filter these duplicates through a Set
.