Hibernate ORM Framework
Test your knowledge of Hibernate ORM framework including configuration, session management, queries, mappings, and persistent object lifecycle.
Questions
What is the root element in hibernate.cfg.xml?
- <hibernate-configuration>
- <hibernate-config>
- <hibernate-apps>
- None of the above
Which of the following is true?
- Every table must have a separate mapping file
- Only parent table needs separate mapping fie
- Only child table need separate mapping file
- One mapping file can have mappings for one or more table.
How to get SessoionFactory from configuration object (config) ?
- config.createSessionFactory()
- config.getSessionFactory()
- config.buildSessionFactory()
- config. SessionFactory.newInstance()
Which of the following association needs
- One to one
- One to many
- Many to one
- None of the above
Which is not a basic value type in hibernate?
- integer
- character
- yes_no
- None of the above
If you intend to put instances of persistent classes in a Set, you have to
- Override equals() method
- Override hashCode() method
- Both a and b
- Neither a nor b
Which is the function call ensure that SQL statement is executed?
- commit()
- flush()
- close()
- list()
What is property name for printing all the executed SQL statements?
- echo_sql
- show_sql
- print_sql
- display_sql
Which of the following must be satisfied by a component class?
- Implements java.io.Serializable
- Override equals() method
- Override hashCode() method
- Both a, b and c
How to add ordering phrase in hibernate criteria?
- criteria.setOrder( Order.asc("name") )
- criteria.add( Order.asc("name") )
- criteria.addOrder( Order.asc("name") )
- criteria.addOrder( "name asc" )
What should be done to change the actual database system type (say, from DB2 to MySql)?
- connection.driver_class property should be changed
- connection.url property should be changed
- dialect property should be changed
- All the above
How can we map several databases in hibernate?
- Using several dialect
- Using several <session-factory>
- Using several connection properties
- Not possible to map more than one database
What kind of query standards can be used in hibernate?
- Native SQL
- HSQL
- Both
- None of the above
Which one of the following will commit session?
- session..commit()
- session.getCommitTransaction()
- session.getTransaction().commit()
- session.getTransaction().save()
What are the different states of persistent classes?
- Transient, persistent, destroyed
- Transient, stored, detached
- Transient, persistent, detached
- open, close, detached
What is the way to pass configuration properties to Hibernate?
- Pass an instance of java.util.Properties to Configuration.setProperties().
- Place hibernate.properties in a root directory of the classpath.
- Set System properties using java -Dproperty=value.
- All the above
Which is true in the following statements?
- Hibernate does not support lazy initialization for detached objects.
- Access to a lazy association outside of the context of an open Hibernate session will result in an exception.
- Lazy fetching is way to avoid unnecessary column reads.
- All the above.
Which statement is executing native query to fetch records from table?
- sess.createQuery("SELECT * FROM CATS").list();
- sess.createSQLQuery("FROM CATS").list();
- sess.createSQLQuery("SELECT * FROM CATS").list();
- sess.createSQLQuery("from CATS", com.animals.Cat.class).list();
Which are the valid values for Cascade attribute in mapping xml?
- all
- persist
- delete
- All the above
Bi-directional links between data models are possible in Hibernate?
- True
- False