• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Hibernate
 

Hibernate

on

  • 11,518 views

Brief Introduction about hibernate

Brief Introduction about hibernate

Statistics

Views

Total Views
11,518
Views on SlideShare
11,495
Embed Views
23

Actions

Likes
3
Downloads
623
Comments
0

3 Embeds 23

http://www.slideshare.net 21
http://swazzy.com 1
http://fix4bug.blogspot.in 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

CC Attribution-ShareAlike LicenseCC Attribution-ShareAlike License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Hibernate Hibernate Presentation Transcript

    • Hibernate An object-relational mapping solution for Java
    • Buzz Words
      • Persistence
      • O/R Mapping ( Object-Relational mapping )
    • What Is Persistence ?
      • The storage of an object on a disk or other permanent storage device or data that exists from session to session
        • as opposed to transient data
      • Persistent data typically implies that it is durable (i.e. will survive a crash or shutdown of the process) usually with some guarantee of integrity
      • Persistence generally implies use of a database
        • One could use the file system (with suitably careful procedures)
    • Persistence Class
      • Default constructor
      • Get/set pairs
      • Collection property is an interface type
      • Identifier property
      public class AuctionItem { private Long _id; private Set _bids; private Bid _successfulBid private String _description; public Long getId() { return _id; } private void setId(Long id) { _id = id; } public String getDescription() { return _description; } public void setDescription(String desc) { _description=desc; } … }
    • O/R Mapping
      • Object-Relational mapping (aka O/RM , ORM , and O/R mapping ), is a programming technique for converting data between incompatible type systems in databases and Object-oriented programming languages. In effect, this creates a "virtual object database " which can be used from within the programming language. There are both free and commercial packages available that perform object-relational mapping, although some programmers opt to create their own ORM tools.
    • O/R Mapping
      • Most business database applications use relational databases
      • Need to map the objects in the application to tables in the database
      • Sometimes be a simple matter of mapping individual classes to separate database tables
      • However, if the class structure is more complex, then the mapping must be carefully considered to allow data to be represented and accessed as efficiently as possible
    • Object Relational Mapping
    • O/R Mapping
      • .
      JavaObject int id; String name; String getName() int getId() void setName(String) void setId(int) SQL Table id [number] primary key, name [varchar(50)] Magic Happens Here (O/R Mapper – i.e. Hibernate)
    • Who, What, When
      • Officially maintained by Jboss, Inc, started in December, 2001.
      • Hibernate is an object-relational mapping (ORM) solution for the Java language. It is free, open source software that is distributed under the GNU Lesser General Public License. It provides an easy to use framework for mapping an object-oriented domain model to a traditional relational database.
    • History is Awesome!
      • Hibernate was developed by a team of Java software developers around the world led by Gavin King.
      • JBoss Group (now part of Red Hat) later hired the lead Hibernate developers and worked with them in supporting Hibernate. This move brought Hibernate development under Java EE Specifications.
      • The current version of Hibernate is Version 3.1, which enriched the platform with new features like a new Interceptor/Callback architecture, user defined filters, and JDK 5.0 Annotations (Java's metadata feature). Hibernate 3 is also very close to the EJB 3.0 specification (although it was finished before the EJB 3.0 specification was released by the Java Community Process) and serves as the backbone for the EJB 3.0 implementation of JBoss.
    • Architecture
      • Hibernate basically sits between the DB and your code
      • Can map persistent objects to tables
    • Why Hibernate ?
      • The purpose of Hibernate is to relieve the developer from a significant amount of common data persistence-related programming tasks. Hibernate adapts to the developer's development process, whether starting from scratch or from a legacy database.
      • Minimize database access with smart fetching strategies
      • Opportunities for aggressive caching
      • Structural mapping more robust when object/data model changes
    • Why Hibernate ?
      • Minimizes Code
      • Does not require a container
      • Model is not tied to persistence implementation
    • Features
      • Hibernate not only takes care of the mapping from Java classes to database tables (and from Java data types to SQL data types), but also provides data query and retrieval facilities and can significantly reduce development time otherwise spent with manual data handling in SQL and JDBC. Hibernate generates the SQL calls and relieves the developer from manual result set handling and object conversion, keeping the application portable to all SQL databases.
    • Features
        • HibernateDaoSupport – superclass, easy HibernateTemplate access
        • Database independence - sits between the database and your java code, easy database switch without changing any code
        • Object / Relational Mapping (ORM) - Allows a developer to treat a database like a collection of Java objects
        • Object oriented query language (HQL) - *Portable* query language, supports polymorphic queries etc.
        • You can also still issue native SQL, and also queries by “Criteria” (specified using “parse tree” of Java objects)
        • Hibernate Mapping - Uses HBM XML files to map value objects (POJOs) to database tables
        • Transparent persistence - Allows easy saves/delete/retrieve for simple value objects
        • Very high performance “in general” due to intelligent (2-level) caching, although in a few cases hand-written SQL might beat it
    • Hibernate's Goal
      • Remove 95% of common data persistence problems
    • Advantages
      • Support for Query Language
      • Database Dependent Code
      • Maintenance Cost
      • Optimize Performance
      • Automatic Versioning and Time Stamping
      • Open-Source, Zero-Cost Product License
      • Scalable
    • Disadvantages
      • Steep Learning Curve
      • Use of Hibernate is an overhead for the applications which are :
      • • simple and use one database that never change
      • • need to put data to database tables, no further SQL queries
      • • there are no objects which are mapped to two different tables Hibernate increases extra layers and complexity. So for these types of applications JDBC is the best choice.
    • Disadvantages
      • Support for Hibernate on Internet is not sufficient.
      • Hibernate does not allow some type of queries which are supported by JDBC. For example It does not allow to insert multiple objects (persistent data) to same table using single query. Developer has to write separate query to insert each object.