Hibernate ORM Framework

Test your knowledge of Hibernate ORM framework including configuration, session management, queries, mappings, and persistent object lifecycle.

20 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

What is the root element in hibernate.cfg.xml?

  1. <hibernate-configuration>
  2. <hibernate-config>
  3. <hibernate-apps>
  4. None of the above
Question 2 Multiple Choice (Single Answer)

Which of the following is true?

  1. Every table must have a separate mapping file
  2. Only parent table needs separate mapping fie
  3. Only child table need separate mapping file
  4. One mapping file can have mappings for one or more table.
Question 3 Multiple Choice (Single Answer)

How to get SessoionFactory from configuration object (config) ?

  1. config.createSessionFactory()
  2. config.getSessionFactory()
  3. config.buildSessionFactory()
  4. config. SessionFactory.newInstance()
Question 4 Multiple Choice (Single Answer)

Which of the following association needs tag element in mapping file?

  1. One to one
  2. One to many
  3. Many to one
  4. None of the above
Question 5 Multiple Choice (Single Answer)

Which is not a basic value type in hibernate?

  1. integer
  2. character
  3. yes_no
  4. None of the above
Question 6 Multiple Choice (Single Answer)

If you intend to put instances of persistent classes in a Set, you have to

  1. Override equals() method
  2. Override hashCode() method
  3. Both a and b
  4. Neither a nor b
Question 7 Multiple Choice (Single Answer)

Which is the function call ensure that SQL statement is executed?

  1. commit()
  2. flush()
  3. close()
  4. list()
Question 8 Multiple Choice (Single Answer)

What is property name for printing all the executed SQL statements?

  1. echo_sql
  2. show_sql
  3. print_sql
  4. display_sql
Question 9 Multiple Choice (Single Answer)

Which of the following must be satisfied by a component class?

  1. Implements java.io.Serializable
  2. Override equals() method
  3. Override hashCode() method
  4. Both a, b and c
Question 10 Multiple Choice (Single Answer)

How to add ordering phrase in hibernate criteria?

  1. criteria.setOrder( Order.asc("name") )
  2. criteria.add( Order.asc("name") )
  3. criteria.addOrder( Order.asc("name") )
  4. criteria.addOrder( "name asc" )
Question 11 Multiple Choice (Single Answer)

What should be done to change the actual database system type (say, from DB2 to MySql)?

  1. connection.driver_class property should be changed
  2. connection.url property should be changed
  3. dialect property should be changed
  4. All the above
Question 12 Multiple Choice (Single Answer)

How can we map several databases in hibernate?

  1. Using several dialect
  2. Using several <session-factory>
  3. Using several connection properties
  4. Not possible to map more than one database
Question 13 Multiple Choice (Single Answer)

What kind of query standards can be used in hibernate?

  1. Native SQL
  2. HSQL
  3. Both
  4. None of the above
Question 14 Multiple Choice (Single Answer)

Which one of the following will commit session?

  1. session..commit()
  2. session.getCommitTransaction()
  3. session.getTransaction().commit()
  4. session.getTransaction().save()
Question 15 Multiple Choice (Single Answer)

What are the different states of persistent classes?

  1. Transient, persistent, destroyed
  2. Transient, stored, detached
  3. Transient, persistent, detached
  4. open, close, detached
Question 16 Multiple Choice (Single Answer)

What is the way to pass configuration properties to Hibernate?

  1. Pass an instance of java.util.Properties to Configuration.setProperties().
  2. Place hibernate.properties in a root directory of the classpath.
  3. Set System properties using java -Dproperty=value.
  4. All the above
Question 17 Multiple Choice (Single Answer)

Which is true in the following statements?

  1. Hibernate does not support lazy initialization for detached objects.
  2. Access to a lazy association outside of the context of an open Hibernate session will result in an exception.
  3. Lazy fetching is way to avoid unnecessary column reads.
  4. All the above.
Question 18 Multiple Choice (Single Answer)

Which statement is executing native query to fetch records from table?

  1. sess.createQuery("SELECT * FROM CATS").list();
  2. sess.createSQLQuery("FROM CATS").list();
  3. sess.createSQLQuery("SELECT * FROM CATS").list();
  4. sess.createSQLQuery("from CATS", com.animals.Cat.class).list();
Question 19 Multiple Choice (Single Answer)

Which are the valid values for Cascade attribute in mapping xml?

  1. all
  2. persist
  3. delete
  4. All the above
Question 20 True/False

Bi-directional links between data models are possible in Hibernate?

  1. True
  2. False