Search your topic in Java2share
Home > FAQs
eXTReMe Tracker


Hibernate FAQs


1.what is the advantage of Hibernate over jdbc?

There are so many
1)    Hibernate is data base independent, your code will work for all ORACLE,MySQL ,SQLServer etc.
In case of JDBC query must be data base specific. So hibernate based persistance logic is database independent persistance logic and JDBC based persistance logic is database dependent logic.
2)    As Hibernate is set of Objects ,
3) No need to learn SQL language.You can treat TABLE as a Object . Only Java knowledge is need.
In case of JDBC you need to learn SQL.
3)    Dont need Query tuning in case of Hibernate. If you use Criteria Quires in Hibernate then hibernate automatically tuned your query and return best result with performance.
In case of JDBC you need to tune your queries.
4)     You will get benefit of Cache. Hibernate support two level of cache. First level and 2nd level. So you can store your data into Cache for better performance.
In case of JDBC you need to implement your java cache .
5)    Hibernate supports Query cache and It will provide the statistics about your query and database status.
JDBC Not provides any statistics.
6)    Development fast in case of Hibernate because you dont need to write queries
7)    No need to create any connection pool in case of Hibernate. You can use c3p0.
In case of JDBC you need to write your own connection pool
8)    In the xml file you can see all the relations between tables in case of Hibernate. Easy readability.
9)    You can load your objects on start up using lazy=false in case of Hibernate.
JDBC Dont have such support.
10 ) Hibernate Supports automatic versioning of rows but JDBC Not.

2.What is Hibernate?
Hibernate is an open source, light weight Object Relational Mapping tool to develop the database independent persistence login in java and j2ee based applications.
Hibernate is a pure Java object-relational mapping (ORM) and persistence framework that allows you to map plain old Java objects to relational database tables using (XML) configuration and mapping files. Its purpose is to relieve the developer from a significant amount of relational data persistence-related programming tasks

3.What is ORM ?
ORM stands for object/relational mapping, means providing the mapping between class with table and member variables with columns is called ORM. ORM is the automated persistence of objects in a Java application to the tables in a relational database.

4.hat does ORM consists 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

5.What are the ORM levels ?
The ORM levels are:

  • Pure relational (stored procedure.)
  • Light objects mapping (JDBC)
  • Medium object mapping
  • Full object Mapping (composition,inheritance, polymorphism, persistence by reachability)

.
6.Why do you need ORM tools like hibernate?
The main advantage of ORM like hibernate is that it can develop the database independent persistence logic. Apart from this, ORM provides 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