Wrong problem correction

Source: Internet
Author: User
Tags dname joins

This topic examines the understanding of cross-linking in Hibernate. HQL supports SQL-style cross-connect queries, cross-joins apply when no association is defined between two classes. In the WHERE clause, properties are used as filter criteria, such as statistical report data. You should avoid statements such as "from Dept,emp" when using cross joins. Executes this HQL query statement, which returns the cross combination of the Dept table and the EMP table, with the number of records for the result set being the product of the number of records in the two tables, which is the Cartesian product in the database. The result of this query is not meaningful, so option B is correct. Both A and C answers are described above and are suitable for use in cross-linking situations. D The answer is that the above three kinds are suitable, conflict with the above description. Options B, C, d are wrong because the topic requires choosing an option that is not suitable for using cross-connect.


The examination of the subject is an overview of the HQL in the HIBERNATE-HQL query. In answer a, the class name and property name in HQL's SELECT statement are case-sensitive; in answer B, hql is a statistical function; In answer d, the ordinal of the binding parameter starts at 0. So Abd is not correct, only C is correct. So the answer is C.


This topic examines: The HQL query statement, and the HQL statement alias naming rules, answer A, select can be omitted, is correct; in answer B, the expression is also correct; in answer C, HQL is a support aggregation function, so the expression of C is wrong, and in the answer D, the expression is also correct. The problem is that the wrong expression is chosen, so Abd does not conform, only C. So the answer is C.

Both load () and get () are looking for the cache first, then the database. The difference is when retrieving: Load () is a deferred retrieval, the proxy object is returned, the object is accessed when the SQL command Get () is retrieved immediately, the SQL command is issued directly, and the object is returned, so ABC is wrong, and D is the correct answer.


One-to-one configured queries, you must query to another entity


This topic examines the effects of various connections because if a right join B takes out all the data of table B, the a table data associated with the on condition is displayed, none is empty; so B is wrong;


This topic examines simple applications that are urgently connected to hibernate. The urgent connection in Hibernate is implemented by the FETCH keyword, which indicates that the property that the left object is used to associate with the right object is immediately initialized, but there may be duplicate "left" objects. In the case of multiple EMP employees under a dept department, the left outer connection returns results using a department that matches an employee, thus causing duplicate Dept department objects to appear in the result set, so option B is correct. An exception in the answer may be thrown in case the session object is null, but the problem is that the session object is normally open and not closed, and even if the HQL statement does not find the result, The Query.list method also does not throw an NullPointerException exception, so option A is wrong. c The answer is that the principle of the urgent connection is not thoroughly understood, the urgent connection returned by the list will be the "left" object of the generic, rather than object[], so option C is wrong. The D answer only considers the simple situation, in the simple case, namely a department only one employee's situation, the question code is no problem. But given the situation of multiple EMP employees under a Dept department, the topic Code returns a list collection containing duplicate Dept objects, so option D is wrong.


This topic examines the types of hibernate connection queries. INNER JOIN [FETCH] is the syntax for the inner join, left [outer] join is the syntax of the outer join, right [outer] join is the syntax of the left outer join, [inner] join fetch is the syntax of the urgent inner connection, so the correct option is C.

The subject examines the difference between the hql inner connection and the urgent inner connection. Option A is incorrect because only an urgent inner join will immediately load the connection data, and the normal inner join will not load the data immediately when the set merge is initialized. Option B is correct, and the Emps collection is not initialized. Option C is also correct, and the second sentence is urgently connected, so the data will be loaded immediately. Option d is a misleading option.
This topic examines the use of Hibernate relational mappings. Everyone has a different name. This means that one-to-two relationships are not duplicated, and many individuals can be the same name for the first relationship. So the correct option is AC.


This topic examines the simple application of implicit and explicit intra-connection in hibernate. In the HQL query statement, if the EMP class is assigned an alias "E", the Dname property of the Dept object can be accessed through E.dept.dname, and the employee information is queried by a departmental condition using an implicit inner join, so option B is correct. Alternatively, you can explicitly use the INNER JOIN keyword to connect e.dept objects, so option C is also correct. A the INNER JOIN keyword is used in the answer, but the connection object is used incorrectly, which causes the error "could not found the property Dept of EMP", that is, an attribute called Dept is not found in the EMP class. The reason is that hibernate is an ORM-based solution that has mapped tables and persisted objects before the HQL statement executes, and hibernate only knows that there are Dept properties in the EMP and not dept, so option A is wrong. b The answer is to copy the SQL statement, the wording used in the HQL will cause the "Research and Development Department" this department object and each EMP employee object matching results, the total number of records equals the number of records of EMP employees, so option B is wrong.


This topic examines where Hibernate query caching is applicable, and for frequently used query statements, if query caching is enabled, hibernate will store the query results in the second cache when the query is executed for the first time. When you execute the query statement again later, you can improve query performance by simply getting the query results from the cache. So the correct option is AB.


This topic examines the understanding of caching, fewer queries, and more, the use of caching instead degrades performance, so a, B errors. If you query by ID, you can increase the index on the ID column, but if you increase the index on each column, you may reduce the insert and modify performance, so D is wrong. Should choose c

Wrong correction

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.