Hibernate MCQs

Hibernate MCQs

Our experts have gathered these Hibernate MCQs through research, and we hope that you will be able to see how much knowledge base you have for the subject of Hibernate by answering these 100+ multiple-choice questions.
Get started now by scrolling down!

1: JDBC stands for_____.

A.   Jeremy Does Backflips Consistently

B.   Java Does Best Connection

C.   Java DataBase Connection

D.   Just Do Both Carefully

2: Which of the following correctly describes SessionFactory?

A.   A single-threaded, short-lived object representing a conversation between the application and the persistent store

B.   Short-lived, single threaded objects containing persistent state and business function

C.   Instances of persistent classes that are not currently associated with a org.hibernate.Session

D.   A thread-safe, immutable cache of compiled mappings for a single database

3: Hibernate will assume an instance is an unsaved transient instance if:

A.   The identifier property (if it exists) is null

B.   All of these

C.   You supply an unsaved-value in the mapping document for the class, and the value of the identifier property matches

D.   The version property (if it exists) is null

4: Which of the following statements are true about Hibernate catching:

A.   The first level caching is provided by the EntityManager

B.   The first level caching is limited to a particular user or request

C.   Hibernate provides 2 levels of caching

D.   All of these

5: Which of the following XML elements is true for Hibernate?

A.   <hibernate-hibernate>

B.   <hibernate-java-java>

C.   <hibernate-mapping>

D.   <hibernate-tabular>

6: A persistent framework is a(n) ____ service that stores and gets objects into a database.

A.   modular

B.   open

C.   ORM

D.   OS

7: Which is true:

A.   Session.Cloak()

B.   Session.Close();

C.   Session.Close

D.   Session.Cloak

A.   The API mismatch

B.   The structural mismatch

C.   The duplication mismatch

D.   All

9: The createhibernate.cfg.xml is a/an ____ configuration file.

A.   MXL

B.   LMX

C.   XXML

D.   XML

10: What instructs Hibernate how to map the classes to the database?

A.   A variable

B.   The Declare statement

C.   xpath mapping file

D.   XML mapping file

11: Java is a/an _____ language

A.   client

B.   tough

C.   javascript

D.   Object-Oriented

12: Hibernate is a high performance ORM. ORM stands for?

A.   object redundant marker

B.   object real maker

C.   object relational marker

D.   object relational mapping

13: If Hibernate does not commit the transaction it can _______.

A.   zip it up

B.   backflip

C.   rollback

D.   fallback

14: A database _____ data.

A.   stores

B.   tabs

C.   non-persists

D.   grows

15: Java is to the business logic as ____ is to the database

A.   vbscript

B.   javascript

C.   SQL

D.   perl

16: SessionFactory is _____.

A.   delayed

B.   self-orienting

C.   thread safe

D.   lousy

A.   Hibernate Search works well in clustered mode

B.   Hibernate Search provides synchronous and asynchronous index updates

C.   Hibernate Search works well in non-clustered mode

D.   All

18: An ORM solution should consist of which of the following functions:

A.   Specifying queries that refer to classes and properties of classes

B.   Performing basic CRUD operations on objects of persistent classes

C.   All of these

D.   Specifying mapping metadata

19: The reason for Hibernate is because their is a mismatch or impedance between the object model and the ____?

A.   rational database

B.   revised database

C.   relational database

D.   redundant database

20: Query objects use ____ to retrieve data from the relational database

A.   HQL

B.   C#

C.   .Net

D.   Java

21: Hibernate takes care of mapping Java to the database using ___?

A.   xpath

B.   XML

C.   PL-SQL

D.   XSLY

22: POJO stands for_____.

A.   Plain Ole Java Object

B.   Plain Old Java Object

C.   Plaine Ole Java Object

D.   Plaine Old Java Object

23: Databases represent data in a ____ format.

A.   tabular

B.   delimited

C.   reformatted

D.   delayed

24: A _______ represents a measure of work done in the database.

A.   sproc

B.   UDF

C.   transaction

D.   table

25: The Hibernate framework is stored in (a) _____.

A.   browser

B.   javascript

C.   JAR

D.   XML

26: Which of the following is TRUE about @GeneratedValue annotation?

A.   Its is used to specify the table to persist the data

B.   It is used to mark this class as an Entity bean

C.   It is used to specify the identifier property of the entity bean

D.   It is used to specify the primary key generation strategy

27: A/an ______ is a primitive data type.

A.   Variable

B.   OOP

C.   SQL

D.   Integer

28: The configuration object class is used to create a(n) ____?

A.   SessionFactory

B.   Rational Database

C.   ArrayList

D.   VariableRepository

29: Which of the followings might be able to solve N+1 problem?

A.   add @Fetch annotation and specify a FetchMode of JOIN

B.   add @Fetch annotation and specify a FetchMode of SUBSELECT

C.   use LEFT JOIN FETH clause on the HQL

D.   All of these

A.   <HTML>

B.   <JAVA>

C.   <property>

D.   <XML>

31: Which of the following correctly describes Hibernate Envers?

A.   Facilitates auditing of Hibernate mappings, which extend JPA, like custom types and collections/maps of "simple" types (Strings, Integers, etc.)

B.   Facilitates auditing of all mappings defined by the JPA specification

C.   Facilitates querying historical data

D.   All

32: Which of the following is a VALID key component of Hibernate Configuration?

A.   Both database connection and class mapping setup

B.   Class mapping setup but NOT database connection

C.   Database connection but NOT class mapping setup

D.   SessionFactory but NEITHER database connection NOR class mapping setup

33: Which of the following property makes hibernate to generate SQL as per the chosen database?

A.   dialect

B.   session

C.   transaction

D.   driver_class

34: Which of the following property needs to be defined to activate second-level caching?

A.   transactionManager

B.   hibernate-configuration

C.   sessionFactory

D.   cache.provider_class

35: Which of the following are valid Hibernate interceptors?

A.   Session-scoped

B.   Session-scoped but NOT SessionFactory-scoped

C.   Both Session-scoped and SessionFactory-scoped

D.   SessionFactory-scoped

36: Which of the following is NOT true about Metamodel?

A.   All

B.   javax.persistence.metamodel.Metamodel acts as a repository of metamodel objects and provides access to them

C.   Handle to javax.persistence.metamodel.Metamodel can be obtained from either the javax.persistence.EntityManagerFactory or the javax.persistence.EntityManagervia their getMetamodel method

D.   The metamodel is a set of objects that describe a domain model

37: Which one of the following statements is true about detached instance?

A.   An instance will be detached after it gets retrieved from the database by the execution of query.

B.   Changes made to the detached instance are still guaranteed to synchronize with the database.

C.   A persistent instance will become detached after the session is closed.

D.   Hibernate does NOT allow you to re-associate detached instances with a new persistence manager.

38: Which one of the following statement is NOT true about SessionFactory?

A.   You can use SessionFactory to create Session instance

B.   SessionFactory is not lightweight and is expensive to create

C.   One SessionFactory can manage more than one database

D.   The SessionFactory caches generated SQL statements and other mapping meta data that Hibernate uses at runtime

39: Which of the following elements is used to declare the persistent class in Hibernate configuration file?

A.   <property>

B.   <session-factory>

C.   <mapping>

D.   <hibernate-configuration>

40: Which of the following provides an interface between application and data stored in the database?

A.   Transaction

B.   Session

C.   TransactionFactory

D.   ConnectionProvider

41: Which of the following is NOT a valid value for 'hbm2ddl.auto' property in hibernate configuration?

A.   validate

B.   truncate

C.   create

D.   update

42: Which one of the following statements is true about the instance states?

A.   Detached instants can be made persistent by calling saveOrUpdate()

B.   Transient instants can be made persistent by calling delete()

C.   Transient instants are previously persistent and associated with an unique session

D.   Persistent instants can be made transient by calling update()

43: Which one of the following statements is NOT true about ordering query result?

A.   You can use asc and desc to specify ascending and descending order

B.   You cannot order query results by more than one properties

C.   The default ordering is ascending

D.   HQL provides an ORDER BY clause for ordering query result

44: Which one of the following statements is NOT true about named queries?

A.   The named query must be HQL strings. Native SQL is not supported in named query

B.   The getNamedQuery() method obtains a query instance of named query

C.   Named queries are precompiled when session factory is created

D.   Named queries allow externalizing query strings to the mapping metadata

45: Which of the following is NOT a type of hibernate cache?

A.   First Level Cache

B.   Application layer level cache

C.   Transaction layer level cache

D.   SQL cache

46: Hibernate offers an implementation of which specification?

A.   ORM

B.   JDBC

C.   JMS

D.   JPA

47: Which of the following is NOT true about Session and Transaction scope in Hibernate?

A.   Multiple instances of SessionFactory are created, usually on application startup, from a Configuration instance

B.   A Session is an inexpensive, non-threadsafe object that should be used once and then discarded for: a single request, a conversation or a single unit of work

C.   In order to reduce lock contention in the database, a database transaction has to be as short as possible

D.   A SessionFactory is an expensive-to-create, threadsafe object, intended to be shared by all application threads

48: Which one of the following statements is NOT true about persistence annotations?

A.   The @Table annotation can be used to specify mapping database schema name

B.   The @Column annotations is used to specify the column name of the foreign key

C.   The @Entity annotation indicates that the class is mapped to a table in database

D.   The @Id annotation indicates the field is the primary key for the entity

49: Which of the following is the FIRST Hibernate object that is created in any Hibernate application?

A.   Configuration

B.   Transaction

C.   Session

D.   SessionFactory

50: Which one of the following statement is NOT true about Hibernate's Query interface?

A.   If the query returns more than result for the uniqueResult() method, the first one will be returned.

B.   Both the createQuery() and createSQLQuery() method of Session interface can return a Query instance

C.   You can paging the query result by using setFirstResult() and setMaxResult() method

D.   You can use method chaining (methods return receiving object instead of void) with Query interface