Following quiz provides Multiple Choice Questions (MCQs) related to Hibernate Framework. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.
Q 1 - What ORM stands for?
ORM stands for Object-Relational Mapping (ORM) is a programming technique for converting data between relational databases.
Q 2 - Which of the following is true about Transaction object in hibernate?
A Transaction represents a unit of work with the database and most of the RDBMS supports transaction functionality. Transactions in Hibernate are handled by an underlying transaction manager and transaction (from JDBC or JTA).This is an optional object and Hibernate applications may choose not to use this interface, instead managing transactions in their own application code.
Q 3 - Which of the following is true about persistent state of a persistent entity?
You can make a transient instance persistent by associating it with a Session. A persistent instance has a representation in the database, an identifier value and is associated with a Session.
Q 4 - Which method is used to save or update the state of the given instance from the underlying database?
Session.saveOrUpdate either saves(Object) or updates(Object) the given instance.
Q 5 - Which of the following is true about <generator> element?
B - Set the class attribute of the generator element is set to native to let hibernate pick up either identity, sequence or hilo algorithm to create primary key depending upon the capabilities of the underlying database.
The <generator> element within the id element is used to automatically generate the primary key values. Set the class attribute of the generator element is set to native to let hibernate pick up either identity, sequence or hilo algorithm to create primary key depending upon the capabilities of the underlying database.
Q 6 - What is lazy loading?
Lazy loading is a technique in which objects are loaded on demand basis.
Q 7 - Which of the following is true about HQL?
HQL takes java objects in the same way as SQL takes tables. HQL is a Object Oriented Query language and is database independent.
Q 8 - When a Read-write concurrency strategy is to be used?
Use Read-write strategy for read-mostly data where it is critical to prevent stale data in concurrent transactions.
Q 9 - Which of the following is true about @Entity annotation?
@Entity annotation marks a class as an entity bean, so it must have a no-argument constructor that is visible with at least protected scope.
Q 10 - Which of the following is true about @GeneratedValue annotation?
By default, the @Id annotation will automatically determine the most appropriate primary key generation strategy to be used but you can override this by applying the @GeneratedValue annotation which takes two parameters strategy and generator.