3:53 pm - Thursday March 24, 4760

Hibernate Interview Question and Answers

Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

1. What is ORM?

ORM stands for object/relational mapping. ORM is the automated persistence of objects in a Java application to the tables in a relational database

2. What does ORM consist of?

An ORM solution consists of the following four pieces:

  • API for performing basic CRUD operations
  • API to express queries referring to classes
  • Facilities to specify metadata
  • Optimization facilities :
  • Dirty checking, lazy associations fetching

3. Why do you need ORM tools like hibernate?

The main advantage of ORM like hibernate is that it shields developers from messy SQL. Apart from this,

ORM provides the following benefits:

  • Improved productivity
  • High-level object-oriented API
  • Less Java code to write
  • No SQL to write
  • Improved performance
  • Sophisticated caching Lazy loading Eager loading Improved maintainability
  • A lot less code to write Improved portability
  • ORM framework generates database-specific SQL for you

4. What does Hibernate simplify?

Hibernate simplifies: Saving and retrieving your domain objects Making database column and table name changes Centralizing pre save and post retrieve logic Complex joins for retrieving related items Schema creation from the object model

5. What is the need for hibernate xml mapping file?

Hibernate mapping file tells Hibernate which tables and columns to use to load and store objects. Typical mapping file look as follows:

6. What are the most common methods of hibernate configuration?

The most common methods of Hibernate configuration are:

Programmatic configuration XML configuration (hibernate.cfg.xml)

7. What are the important tags of hibernate.cfg.xml?

Following are the important tags of hibernate.cfg.xml:

8. What are the Core interface are of hibernate framework?

The five core interfaces are used in just about every Hibernate application. Using these interfaces, you can store and retrieve persistent objects and control transactions. Session interface SessionFactory interface Configuration interface Transaction interface Query and Criteria interfaces

9. What role does the Session interface play in hibernate?

The Session interface is the primary interface used by Hibernate applications. It is a single-threaded, short-lived object representing a conversation between the application and the persistent store. It allows you to create query objects to retrieve persistent objects.

Session session = sessionFactory.openSession();

Session interface role: Wraps a JDBC connection Factory for Transaction Holds a mandatory (first-level) cache of persistent objects, used when navigating the object graph or looking up objects by identifier.

10. What role does the session Factory interface play in hibernate?

The application obtains Session instances from a SessionFactory. There is typically a single SessionFactory for the whole application created during application initialization. The SessionFactory caches generate SQL statements and other mapping metadata that Hibernate uses at runtime. It also holds cached data that has been read in one unit of work and may be reused in a future unit of work

SessionFactory sessionFactory = configuration.buildSessionFactory();

PARTS : >  1   2   3    4   5   6   7   8   9  10  11  12

Filed in: Z-A Interview Questions

No comments yet.

Leave a Reply