Wednesday 2 September 2015

Java Source World: Hibernate Framework


Hibernate Framework


Hibernate framework simplifies the development of java application to interact with the database. Hibernate is an open source, lightweight, ORM(Object Relational Mapping) tool.
An ORM tool simplifies the data creation, data manipulation and data access. It is a programming technique that maps the object to the data stored in the database.


The ORM tool internally uses the JDBC API to interact with the database.


Advantages of Hibernate Framework:

There are many advantages of Hibernate Framework. They are as follows:
1) Opensource and Lightweight: Hibernate framework is opensource under the LGPL license and lightweight.
2) Fast performance: The performance of hibernate framework is fast because cache is internally used in hibernate framework. There are two types of cache in hibernate framework first level cache and second level cache. First level cache is enabled bydefault.
3) Database Independent query: HQL (Hibernate Query Language) is the object-oriented version of SQL. It generates the database independent queries. So you don't need to write database specific queries. Before Hibernate, If database is changed for the project, we need to change the SQL query as well that leads to the maintenance problem.
4) Automatic table creation: Hibernate framework provides the facility to create the tables of the database automatically. So there is no need to create tables in the database manually.
5) Simplifies complex join: To fetch data form multiple tables is easy in hibernate framework.
6) Provides query statistics and database status: Hibernate supports Query cache and provide statistics about query and database status.



2 comments:

  1. why should we serialize the hibernate entity?

    ReplyDelete
  2. Hi Srinivas,

    Hibernate does not require that the object be serializable.

    And It is only required if you are going to send the detached object through wire( e.g., remote interface).

    Java has a built-in persistence mechanism: Serialization provides the ability to write a graph of objects (the state of the application) to a byte-stream, which may then be persisted to a file or database. Serialization is also used by Java’s Remote Method Invocation (RMI) to achieve pass-by value semantics for complex objects. Another usage of serialization is to replicate application state across nodes in a cluster of machines.

    In practice; however, most people do make their POJO's serializable for the following reasons:

    It allows the object to be passed to an EJB.
    It allows the object to be stored in a servlet session.
    It may be required for some implementations of clustering and/or caching.

    If suppose, if you use JPA, that time we have to implement serializable interface for an entity

    For more details go through the below link:
    http://docs.oracle.com/cd/E19159-01/819-3669/bnbpz/index.html

    Thanks And Keep Posting.

    ReplyDelete