Hibernate Questions

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Kushin
K
Kushin
Community Contributor
Quizzes Created: 1 | Total Attempts: 3,840
| Attempts: 3,840 | Questions: 10
Please wait...
Question 1 / 10
0 %
0/100
Score 0/100
1. __________ objects can be passed across layers all the way up to the presentation layer without having to use any DTOs (Data Transfer Objects). You can later re-attach them to another session

Explanation

Detached objects can be passed across layers all the way up to the presentation layer without having to use any DTOs. These objects are not associated with any particular session and can be re-attached to another session later. This allows for more efficient and streamlined communication between different layers of an application, as there is no need to convert the data into DTOs for transfer.

Submit
Please wait...
About This Quiz
Java Quizzes & Trivia

This Hibernate quiz assesses knowledge on configuration methods, session management, and core interfaces. It evaluates understanding of Hibernate's XML tags and object states, crucial for developers working with... see moreJava persistence layers. see less

2. What is the method name Session.____() that would re-load an object and all its collections

Explanation

The method name "refresh" or "Refresh" is used to reload an object and all its collections. This method is commonly used in programming to retrieve the latest data from a database or to update the state of an object with the most recent information. By calling this method, the object and its associated collections are refreshed and any changes made since the last retrieval or update are reflected.

Submit
3. Which of the following is not a Session method? Select ONE

Explanation

The method Session.remove() is not a valid Session method because there is no such method in the Session class. The other options, Session.save(), Session.saveorupdate(), Session.persist(), and Session.load() are all valid Session methods that are used for various operations such as saving or updating an object, persisting an object, and loading an object respectively.

Submit
4. Which of the following is FALSE about Session in hibernate

Explanation

The statement "You can share the session between threads" is FALSE. In Hibernate, a Session is not designed to be shared between multiple threads. It is a light weight non-threadsafe object that represents a single unit-of-work with the database. Each thread should have its own Session object to ensure thread safety and avoid potential issues with concurrent access to the database. Sharing a Session between threads can lead to unpredictable behavior and data integrity problems.

Submit
5. There are core interfaces are used in just about every Hibernate application. Using these interfaces, you can store and retrieve persistent objects and control transactions. Select all the interfaces that you see

Explanation

The given correct answer is Configuration interface, Session interface, Query and Criteria interfaces. These interfaces are commonly used in Hibernate applications. The Configuration interface is used to configure Hibernate and provide necessary information for the SessionFactory. The Session interface represents a single unit of work and is used to perform database operations. The Query and Criteria interfaces are used for querying the database and retrieving data. Therefore, these interfaces are essential in Hibernate applications for managing persistent objects and controlling transactions.

Submit
6. Which of the following are most common configuration methods of Hibernate Configuation

Explanation

The most common configuration methods of Hibernate Configuration are mapping files and XML Configuration hibernate.cfg.xml. Mapping files are used to define the mapping between Java objects and database tables, while hibernate.cfg.xml is an XML configuration file that contains various settings and properties for Hibernate.

Submit
7. Which of the following are tags of hibernate.cfg.xml? Select all that apply

Explanation

The hibernate.cfg.xml file is used to configure Hibernate in a Java application. It includes various tags that define the settings and properties for Hibernate. The DTD tag is used to specify the Document Type Definition for the XML file. The JDBC connection tag is used to define the database connection details. The SQL variant to generate tag is used to specify the type of SQL syntax to be generated by Hibernate. The Mapping files tag is used to specify the mapping files that define the object-relational mapping for the application. The Size of the database tag is not a valid tag for hibernate.cfg.xml, so it is not included in the correct answer.

Submit
8. Which of the following is NOT a step in the Hibernate communication with RDBMS? Select ALL than Apply (only one doesnt )

Explanation

The correct answer is "Create HQL Query, Execute query to get list containing Java objects, Load the Hibernate configuration file and create configuration object, Get one session from the session factory." These are all steps in the Hibernate communication with RDBMS. The incorrect answer would be "Create session from configuration object" as this is a step in the Hibernate communication with RDBMS.

Submit
9. Which of the following is NOT a best practice for defining your Hibernate persistent classes?

Explanation

The given answer states that a best practice for defining Hibernate persistent classes is to have a default no-argument constructor and accessor/getter and mutator/setter methods for all persistable instance variables. It also recommends implementing the equals() and hashCode() methods based on the business key, without using the id field if it is a surrogate key. Additionally, it suggests implementing the Serializable interface for potential use in migrating around a multi-processor cluster. However, the answer does not mention that the persistent class should be final in order to use lazy loading with proxy objects.

Submit
10. Which of the following is NOT a role of the session interface? Select only ONE

Explanation

The session interface does not hold a mandatory (first-level) cache of persistent objects, used when navigating the object graph or looking up objects by identifier. It does, however, have the roles of being created during application initialization, wrapping a JDBC connection, and acting as a factory for transactions.

Submit
View My Results

Quiz Review Timeline (Updated): Mar 21, 2023 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 21, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Dec 18, 2009
    Quiz Created by
    Kushin
Cancel
  • All
    All (10)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
__________ objects can be passed across layers all the way up to the...
What is the method name Session.____() that would re-load an object...
Which of the following is not a Session method? Select ONE
Which of the following is FALSE about Session in hibernate
There are core interfaces are used in just about every Hibernate ...
Which of the following are most common configuration methods of...
Which of the following are tags of hibernate.cfg.xml? Select all that...
Which of the following is NOT a step in the Hibernate communication...
Which of the following is NOT a best practice for defining your...
Which of the following is NOT a role of the session interface? Select...
Alert!

Advertisement