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 initialized OnDemand. The first SQL query returns identifiers only.
(The returned entity is initialized only when it is used,
Iterate:
String sql = "from Bigque where ID
Results:
Hibernate:select bigque0_.id as col_0_0_ from Cloudroom.bigque bigque0_ where bigque0_.id
Conclusion:
Lazy loading sends an SQL statement first to get all the IDs used and send SQL to the database to find each object
Two times in a session iterate the second iterate will still send a SQL get
Today, a netizen asked me the collection forgot not, this asked me to tangle a bit, and finally decided to write down this set of questions, so as not to commit a similar problem:Some elements in list and set need to be removed, while the method using edge traversal and edge deletion reported the following exception:concurrentmodificationexception in order to never forget, and also provide a reference to colleagues who meet the same problem:The code f
Scala list/sequence faq:how do I iterate over a Scala List (or more generally, a sequence) using the foreach method or for loop?There is a number of ways to iterate over a Scala List using the foreach method (which was available to Scala sequences like ,,,,
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 query the records by these IDs, that is, to execute the n+1-bar SQL statement (N Number of records that match the criteria)
Sessionfactory = new Configuration ()
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 loop through the collection of IDs, taking the records corresponding to each ID in a separate select SQL, and then filling in the Pojo to return.That is, a SQL
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 only have the OID of the object in the cache, when needed, if only the OID, directly in the cache to fetch, if you n
right side of the function, the right can only write an array//only for the index array//to map each element of the right array to the left variable$arra=Array(1,2,3,4,5,6);List($a,$b,$c,$d,$e,$f)=$arra;Echo $a; Echo";//list ($a, $b, $d, $e, $f) = $arra, or//while loops, each (), list () iterates through the array while(List
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=" Http://s5.51cto.com/wyfs02/M01/7C/A6/wKioL1bVHaPArE8EAAAN7mNGBzQ433.png "title=" 1.PNG " alt= "Wkiol1bvhapare8eaaan7mngbzq433.png" style= "float:none;"/>Employee table (employ
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, and then follow these IDs to query the records, that is, to execute the N+1 SQL statement (n is the number of records that match the criteria)Two execution of
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 query1=session.createquery ("from Books where id=7");
element to the first argument variable $key of the list () function. and assigns the value in the current array element to the second parameter variable $value in the list () function, and each () statement then moves the pointer inside the array one step back, so that the next time () statement loops, it gets the key/value pair for the next element in the array. Until the end of the array each () statemen
"alt=" Wkiol1jbysgzicf5aaa4dwhvkie239.png-wh_50 "/>The contents of the 10.Hibernate configuration file Hibernate.cfg.xml are as follows11. Create the test directory in the project to store testing files, file name Manageforum, package name (Com.mycompany.demo.bean), directory structure650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M01/8F/57/wKiom1jbYYDxYa5cAAA1zpL-j34055.png-wh_500x0-wm_ 3-wmp_4-s_2172248738.png "title=" Qq20170329152216.png "alt=" Wkiom1jbyydxya5caaa1zpl-j34055.png-wh
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.