Analysis on the wrong problem of hibernate

Source: Internet
Author: User
Tags bulk insert joins

1. In Hibernate, the following statement about the primary key generator is wrong ( C).

A Increment can be used for primary keys of type long, short, or byte

B Identity for databases that support identity columns such as SQL Server, DB2, MySQL, and so on

C Sequence for databases such as Oracle, SQL Server, and other supporting sequences

D Native by hibernate based on the underlying database to determine what the primary key generation strategy, is the use of the database to generate the value of the primary key

Parsing: C, sequence cannot be used with SQL Server database

2. Use HQL to query all department information, the following is correct (AD ).

A From Dept

B SELECT * FROM Cn.jbit.demo.entity.Dept

C Select Dept from Cn.jbit.demo.entity.Dept D

D Select D from Dept D

Parsing: The AD, b option cannot exist * this notation. The C option is followed by the alias D of the Dept table immediately after select.

3. In Hql, the method for binding parameters of the query interface is correct (ABCD).

A The Setparameter () method is used to bind arguments of any type

B Setparameter () There is an overloaded method

C SetProperties () There is an overloaded method

D The SetProperties () method is used to bind named arguments

4. In Hibernate, for the following mapping configuration, it is wrong to say ( D).

<class name= "cn.jbit.hibernatedemo.entity.Emp" table= "EMP" schema= "Scott" >

<id name= "EmpNo" column= "EmpNo" type= "Java.lang.Integer" >

<generator class= "Assigned"/>

</id>

<property name= "Salary" type= "java.lang.Double" column= "SAL"/>

<property name= "HireDate" type= "Java.util.Date"/>

<many-to-one

Name= "Dept"

Column= "DEPTNO"

Class= "Cn.jbit.hibernatedemo.entity.Dept"

/>

</class>

A This configuration information describes the mapping of the CN.JBIT.HIBERNATEDEMO.ENTITY.EMP class and the EMP table

B That describes the EMP table for Scott users.

C The name attribute value in the <many-to-one> tag dept is the property name of the Cn.jbit.hibernatedemo.entity.Emp class

D The column attribute value in the <many-to-one> tag Deptno is the primary key name of the Dept table

Parses the column attribute value in the:<many-to-one> tag Deptno refers to the foreign key in the EMP table

5. In the hibernate mapping file, the inverse attribute is said to be correct ( ACD).

A The inverse property has two values: true, False

B <many-to-one> tags have inverse properties

C <set> tags have inverse properties

D The inverse property is used to specify the party that maintains the association relationship

Parse:<many-to-one> tag does not exist inverse property

6. In the hibernate mapping file, the <component> tag statement is correct ( D).

A. <component> tags for mapping component classes

B. <component> tags by <parent> specifies the whole class to which the component class belongs

C. <component> tags by <property> specifying properties of the component class

D. <component> tag has ID, name, class attribute

Parse:<component> tag without id attribute

7. In MyBatis, the value of Executortype includes (ABD ).

A Executortype.simple

B Executortype.batch

C Executortype.execute

D Executortype.reuse

Analytical:

Public final enum Org.apache.ibatis.session.ExecutorType {

Field descriptor #8 Lorg/apache/ibatis/session/executortype;
public static final enum Org.apache.ibatis.session. ExecutortypeSimple;

Field descriptor #8 Lorg/apache/ibatis/session/executortype;
public static final enum Org.apache.ibatis.session. Executortype Reuse;

Field descriptor #8 Lorg/apache/ibatis/session/executortype;
public static final enum Org.apache.ibatis.session. Executortype BATCH;

8. The error about hibernate caching is ( CD).

A Hibernate caches generally fall into three categories: first-level cache, level two cache, and query cache

B The evict () method of the session is used to purge the specified persisted object from the cache

C The clear () method of the session is used to flush the cache

D The flush () method of the session is used to purge all persisted objects from the cache

Parse: The clear () method of the session is used to empty the cache, and the flush () method of the session is used to flush the cache

9. Regarding the connection query of HQL, it is wrong to say ( D).

A. Inner JOIN or join for inner joins

B. INNER JOIN fetch or join FETCH for urgent inner joins

C. LEFT OUTER join fetch or IEFT join fetch for an urgent right outer join

D. The right outer join fetch, or join fetch, is used to urgently use outer joins

Parse: No urgent right outer join in connection query

10. The right thing to say about Hibernate batch processing data is ( CD).

A. Batch operation with HQL, Hibernate does not support BULK INSERT

B. Using the JDBC API for bulk operations, the data involved in SQL statements is loaded into the session cache, taking up memory space

C. Use session for bulk operations, data will be loaded into session cache, attention should be paid to flush and empty cache

D. Use session for batch operations, for complex business logic scenarios that require code processing

Parse: A, hibernate support BULK INSERT. There are three ways: ① through HQL②JDBC api③session

B, using the JDBC API for bulk operations, the data involved in SQL statements will not be loaded into the session cache, so it will not take up memory space, only use the session for bulk operations will be cached

11. In the HQL subquery, it is wrong to say (C ).

A. Size () or size to get the number of elements in the collection

B. Elements () gets all the elements in the collection for the element

C. The Any keyword is used for subquery statements to return all records

D. The In keyword is the same as "=any"

parse: Any keyword used to return any record in a subquery statement

12. For native SQL queries and named queries, the right thing to say is (ABC ).

A. To execute native SQL, use the SQLQuery object

B. SQLQuery is an interface that inherits the query interface

C. Hibernate supports the definition of query statements in the form of strings in a mapping file, such as a named query statement

D. A named query statement can only be a HQL statement, not an SQL statement

Parsing: Named query statements are divided into HQL query statements and native SQL query statements. The HQL query statement uses the <query> element definition. Native SQL uses <sql-query> element definitions

13. In hibernate, the argument about the criteria method is wrong ( CD).

A. The Restrictions.ge () method is equivalent to the HQL operator >=

B. Restrictions.like ("EmpName", "s", Matchmode.start) methods are used to find employees whose names begin with S

C. The Restrictions.disjunction () method is used to specify multiple logical and

D. The Restrictions.in () method can only be used for arrays

Parsing: Therestrictions.disjunction () method is used to specify multiple logical OR. the Restrictions.in () method can be used for arrays, and can also return collection

. in Hibernate , the annotation is correct ( ABD).

A. @Id the unique identity used to declare a persisted class, corresponding to the primary key in the data table

B. @Cloumn used to map properties to columns

C. @Transient used to ignore this property and need to persist to the database

D. @GeneratedValue A build strategy for defining primary key values

Parsing:@Transient used to ignore this property, no need to persist to the database

Analysis on the wrong problem of hibernate

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.