Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the interview questions for Hibernate?

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces what are the interview questions of Hibernate, which can be used for reference by interested friends. I hope you will gain a lot after reading this article. Let's take a look at it.

(1) in general, what is the matching relationship between the relational data model and the object model (multiple selections)

A) Table correspondence class

B) record the corresponding object

C) the fields of the table correspond to the properties of the class

D) the reference relationship between tables corresponds to the dependency relationship between classes

(2) which of the following statements about SessionFactory are true? (multiple selection)

A) for each database transaction, a SessionFactory object should be created

B) A SessionFactory object corresponds to a database storage source.

C) SessionFactory is a heavyweight object and should not be created at will. If there is only one database storage source in the system, only one needs to be created.

D) the load () method of SessionFactory is used to load persistent objects

(3) there is an orders attribute of type Set in the Customer class, which is used to store the Order order object. Which element is used to map the orders attribute in the Customer.hbm.xml file?

A) B) C) D)

(4) the element has a cascade attribute. If you want the Hibernate cascading to save the objects in the collection, what value should the casecade attribute take? (radio)

A) none

B) save

C) delete

D) save-update

(5) which of the following methods belong to Session?

A) load ()

B) save ()

C) delete ()

D) update ()

E) open ()

F) close ()

(6) what is the print result of the following program? (radio)

Tx = session.beginTransaction ()

Customer C1 = (Customer) session.load (Customer.class,new Long (1))

Customer c2 = (Customer) session.load (Customer.class,new Long (1))

System.out.println (c1==c2)

Tx.commit ()

Session.close ()

A) an error occurred and an exception was thrown

B) print false

C) print true

(7) the following program code modifies the name property of Customer twice:

Tx = session.beginTransaction ()

Customer customer= (Customer) session.load (Customer.class

New Long (1))

Customer.setName (\ "Jack\")

Customer.setName (\ "Mike\")

Tx.commit ()

How many update statements does Hibernate need to submit to the database to execute the above procedures? (radio)

A) 0 B) 1 C) 2 D) 3

(8) what states are the objects divided into in the persistence layer? (multiple selection)

A) temporary status

B) independent state

C) Free state

D) persistence status

(9) on which line does the Customer object become persistent for the following programs? (radio)

Customer customer=new Customer (); / / line1

Customer.setName (\ "Tom\"); / / line2

Session session1=sessionFactory.openSession (); / / line3

Transaction tx1 = session1.beginTransaction (); / / line4

Session1.save (customer); / / line4

Tx1.commit (); / / line5

Session1.close (); / / line6

A) line1 B) line2 C) line3 D) line4 E) line5 F) line6

(10) on which line does the Customer object become free for the following procedures? (radio)

Customer customer=new Customer (); / / line1

Customer.setName (\ "Tom\"); / / line2

Session session1=sessionFactory.openSession (); / / line3

Transaction tx1 = session1.beginTransaction (); / / line4

Session1.save (customer); / / line4

Tx1.commit (); / / line5

Session1.close (); / / line6

A) line1 B) line2 C) line3 D) line4 E) line5 F) line6

(11) which of the following retrieval strategies makes use of external link queries? (radio)

A) immediate search B) delayed search C) urgent left outer link search

(12) what happens if you use a deferred retrieval strategy for the orders collection of the Customer class to compile or run the following program (radio)

Session session=sessionFactory.openSession ()

Tx = session.beginTransaction ()

Customer customer= (Customer) session.get (Customer.class,new Long (1))

Tx.commit ()

Session.close ()

Iterator orderIterator=customer.getOrders () .iterator ()

A) compilation error B) compilation passed and running C) compilation passed, but an exception was thrown at run time

(13) which of the following statements are true about HQL and SQL? (multiple selection)

A) HQL is no different from SQL

B) HQL is object-oriented, while SQL manipulates relational databases

C) in both HQL and SQL, select,insert,update,delete statements are included

D) HQL is only used to query data and does not support insert,update and delete statements

(14) who implements the transaction isolation level? (radio)

A) Java Application B) Hibernate C) Database system D) JDBC driver

(15) which has better concurrency performance, pessimistic lock or optimistic lock? (radio)

A) pessimistic lock B) optimistic lock

Answer:

C (2) B, C (3) A (4) D (6) C (7) B (8) A, C (9) D (10) F (11) C (12) C (13) B, D (14) C (15) B

Thank you for reading this article carefully. I hope the article "what are the interview questions of Hibernate" shared by the editor will be helpful to you. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report