Hibernate Questions

10 Questions | Total Attempts: 3355

SettingsSettingsSettings
Please wait...
Hibernate Quizzes & Trivia

This is hibernate quiz


Questions and Answers
  • 1. 
    Which of the following are most common configuration methods of Hibernate Configuation
    • A. 

      Mapping files

    • B. 

      Http.conf

    • C. 

      XML Configuration hibernate.cfg.xml

    • D. 

      Web.config

  • 2. 
    Which of the following is FALSE about Session in hibernate
    • A. 

      Session is a light weight non-threadsafe object

    • B. 

      You can share the session between threads

    • C. 

      Session represents a single unit-of-work with the database

    • D. 

      Session is the primary interface for the persistence service

    • E. 

      A session loads database connections using lazy-loading

  • 3. 
    __________ 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
  • 4. 
    Which of the following are tags of hibernate.cfg.xml? Select all that apply
    • A. 

      DTD

    • B. 

      JDBC connection

    • C. 

      SQL variant to generate

    • D. 

      Mapping files

    • E. 

      Size of the database

  • 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
    • A. 

      Configuration interface

    • B. 

      Session interface

    • C. 

      Query and Criteria interfaces

    • D. 

      User Interface

    • E. 

      Configuration interface

  • 6. 
    Which of the following is NOT a role of the session interface? Select only ONE
    • A. 

      Holds a mandatory (first-level) cache of persistent objects, used when navigating the object graph or looking up objects by identifier

    • B. 

      Created during application initialization

    • C. 

      Wraps a JDBC connection

    • D. 

      Act as Factory for Transaction

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

      Create HQL Query

    • B. 

      Execute query to get list containing Java objects

    • C. 

      Create session from configuration object

    • D. 

      Load the Hibernate configuration file and create configuration object

    • E. 

      Get one session from the session factory

  • 8. 
    Which of the following is not a Session method? Select ONE
    • A. 

      Session.save()

    • B. 

      Session.remove()

    • C. 

      Session.saveorupdate()

    • D. 

      Session.persist()

    • E. 

      Session.load()

  • 9. 
    What is the method name Session.____() that would re-load an object and all its collections
  • 10. 
    Which of the following is NOT a best practice for defining your Hibernate persistent classes?
    • A. 

      You must have a default no-argument constructor for your persistent classes and there should be getXXX() (i.e accessor/getter) and setXXX( i.e. mutator/setter) methods for all your persistable instance variables.

    • B. 

      You should implement the equals() and hashCode() methods based on your business key and it is important not to use the id field in your equals() and hashCode() definition if the id field is a surrogate key (i.e. Hibernate managed identifier). This is because the Hibernate only generates and sets the field when saving the object.

    • C. 

      It is recommended to implement the Serializable interface. This is potentially useful if you want to migrate around a multi-processor cluster.

    • D. 

      The persistent class should be final because if it is final then lazy loading can be used by creating proxy objects.

Related Topics
Back to Top Back to top