For the list method, hibernate actually gets all the records through a select SQL. and read it out and fill it back in the Pojo.The iterate method is to first get all the IDs of the records that meet the query criteria through a select SQL, and then
Query performance is often an important aspect of system performance, and the query mechanism determines the overall performance of the system to a large extent. This area often also has the biggest performance adjustment space.
The Session.find ()
list and iterate methods for the 1.Query interface:
Iterate () Method:
Return the query results as an Iterator. Ifthe query contains multiple results pre row, the results is returned in Aninstance ofobject[].Entities returned as results is
Use the list () method to get the query results, each time a query statement, get all the data using the iterate () method to get the results of the query, first issued an SQL statement to query the ID that satisfies the condition data, and then to
There are two ways to execute a HQL query, one is the list method and the other is the iterate method. What's the difference between the two methods, let's illustrate the difference by example.Company table:650) this.width=650; "src="
1. Use the list () method to get the results of the query, issuing a statement each time to get all the data.2. Use the iterate () method to get the results of the query, first issue an SQL statement to query the ID that satisfies the condition data,
Both list () and iterate () can be used to obtain the HQL results obtained by query.The list () uses an instant load. The query will be preceded by a database query hql and all results present in the cache.Iterate () uses a delay load. Queries will
---- Start
Anyone who has learned any programming language is familiar with continue and break. In SQL PL, iterate and leave play the same role. Return serves the same purpose as most programming languages and is used to return the results to the
List and iterate:1 list is to query iterate immediately using lazy loading, it is possible to generate N+1 queriesSession session=hibernatesessionfactory.getsession ();System.out.println ("1:" +session);Session.begintransaction ();Query
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.