Hibernate Nitin Bansal

download Hibernate Nitin Bansal

of 10

Transcript of Hibernate Nitin Bansal

  • 8/4/2019 Hibernate Nitin Bansal

    1/10

    HIBERNATE

    BY:NITINBANSAL

  • 8/4/2019 Hibernate Nitin Bansal

    2/10

    What is Hibernate is a framework that provides tools for object-

    relational mapping (ORM) library for the Java language, formapping an object -oriented domain model to atraditional relational database.

    Hibernate solves object-relational impedancemismatch problems.

    Hibernate's primary feature is mapping from Java classes todatabase tables.

    We need to write a simple Java code and create an XMLmapping file that describes the relationship betweendatabase and class attributes.

  • 8/4/2019 Hibernate Nitin Bansal

    3/10

    Application RDBMS

    Used forstorage andretrieval

    We have to store the data of Application in tables for multiple

    use. But there is a mismatch in mapping object orientedprogramming and Relational Database.

    Why HIBERNATE?

  • 8/4/2019 Hibernate Nitin Bansal

    4/10

    Hibernate is introduced to overcome this mismatch.

    It can be used to perform operations on the database likeselect, insert, update and delete the records in the tableautomatically and creates the query to perform these

    operations.

    Hibernate generates the SQL on the fly and thenautomatically executes the necessary SQL statements.

    The main drawback of JDBC is that itdoesnt

    allow to storeobjects directly to the database, we have to convert theobjects to a relational format.

    Why HIBERNATE?

  • 8/4/2019 Hibernate Nitin Bansal

    5/10

    Hibernat is highly configurable through two types ofconfiguration files.

    The first type of configuration file isnamed hibernate.cfg.xml.

    The second type of configuration file is a mapping

    description file (file extension *.hbm)

    HIBERNATE ARCHITECTURE

  • 8/4/2019 Hibernate Nitin Bansal

    6/10

    Hibernate provides a query language HQL similar to thestandard SQL and is extremely powerful query language.

    Hibernate automatically generates the SQL query andexecute it against underlying database if HQL is used in the

    application.

    Hibernate Query Language is extremely powerful and itsupports Polymorphism, Associations, Much less verbose thanSQL.

    HQL uses Classes and properties instead of tables andcolumns.

    HIBERNATE QUERY LANGUAGE

  • 8/4/2019 Hibernate Nitin Bansal

    7/10

    Less Development Time

    Database independence: Easy database switch withoutchanging any code.

    Transparent Persistence: It is the automatic mapping of Javaobjects with database tables and vice versa using runtimereflection.

    Lazy Loading: This feature enable us to get only the required

    object instead of fetching all the entities associated withthat.

    Hibernate provides Cache mechanism: It provides first levelcache (By Session object) and second level cache (By Sessionfactory object)

    Features of HIBERNATE

  • 8/4/2019 Hibernate Nitin Bansal

    8/10

    HIBERNATE Example

  • 8/4/2019 Hibernate Nitin Bansal

    9/10

    Extensibility

    Reliability and Scalability

    Productivity

    Maintainability Hibernate can work with Tomcat Application Server.

    Lots of API to learn

    Difficulty in Debugging

    Slower than JDBC

    ADVANTAGES

    DISADVANTAGES

  • 8/4/2019 Hibernate Nitin Bansal

    10/10