Hibernate Framework

509 views

Published on

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
509
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
13
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Hibernate Framework

  1. 1. Disclaimer: This presentation is prepared by trainees ofbaabtra as a part of mentoring program. This is not officialdocument of baabtra –Mentoring PartnerBaabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt .Ltd
  2. 2. HIBERNATE FRAMEWORKSubhin P.V111subru@gmail.comwww.facebook.com/subhinvelayudhantwitter.com/111subruin.linkedin.com/in/SubhinPv8129076039
  3. 3. INTRODUCTION• Hibernate is an Object-relational mapping(ORM) tool.• ORM is a programming method for mappingthe objects to the relational model whereentities/classes are mapped to tables,instances are mapped to rows and attributesof instances are mapped to columns of table.
  4. 4. What does Hibernate do??• Hibernate provides a solution to map databasetables to a class.• It copies one row of the database data to aclass.• In the other direction it supports to saveobjects to the database.• Saving data to a storage is called persistence.And the copying of tables to objects and viceversa is called object relational mapping.
  5. 5. DIAGRAMPresentationlayerLogical layerDatabase
  6. 6. PERSISTENT CLASS• Java classes whose objects or instances will bestored in database tables are called persistentclasses in Hibernate.
  7. 7. Example of Persisting an Object// get a Hibernate SessionFactory for Session managementsessionFactory = new Configuration().configure().buildSessionFactory();// an Event object that we want to saveLocation ku = new Location( "Kasetsart University" );ku.setAddress( "90 Pahonyotin Road; Bangkok" );Event event = new Event("Java Days");event.setLocation( ku );Session session = sessionFactory.openSession();Transaction tx = session.beginTransaction();session.save( event );tx.commit();session.close();
  8. 8. CREATING A JAVA PROJECT USINGHIBERNATE• STEPS1. Create a Java Project2. Add jar Files for Hibernate3. Create the persistent class4. Create Mapping File for Persistence Class5. Create the configuration file6. Create the class that retrieves or stores thepersistent object7. Run the application
  9. 9. CREATE JAVA PROJECT
  10. 10. DOWNLOAD JAR FILES• we can download jars related to hibernate at• http://sourceforge.net/projects/hibernate/files/hibernate3• From the above URL choose hibernate 3.2.2-ga.zip, as we are in initial stage this version will bebetter.• Unzip it, and now you can find some jar files inthe lib folder right..?, actually we doesn’t requireall the jar files, out of them just select thefollowing jar files..
  11. 11. DOWNLOAD JAR FILES• Anttr-2.7.6.jarasm.jarasm-attrs.jarcglib-2.1.3.jarcommons-collections-2.1.1.jarcommons-logging-1.0.4.jarehcash.jardom4j-1.6.1.jarhibernate3.jarjta.jarlog4j-1.2.3.jar
  12. 12. CREATE PERSISTENT CLASS
  13. 13. CREATE A MAPPING FILE FOR THEPERSISTANT CLASS
  14. 14. CREATE A CONFIGURATION FILE
  15. 15. CREATE THE CLASS THAT RETRIVESOR STORES THE PERSISTANT CLASS
  16. 16. RUN THE APPLICATION
  17. 17. ADVANTAGES OF HIBERNATE• Opensource and lightweight• Database independent querying• Automatic table creation
  18. 18. If this presentation helped you, please visit ourpage facebook.com/baabtra and like it.Thanks in advance.www.baabtra.com | www.massbaab.com |www.baabte.com
  19. 19. Contact UsEmarald Mall (Big Bazar Building)Mavoor Road, Kozhikode,Kerala, India.Ph: + 91 – 495 40 25 550NC Complex, Near Bus StandMukkam, Kozhikode,Kerala, India.Ph: + 91 – 495 40 25 550Start up VillageEranakulam,Kerala, India.Email: info@baabtra.com

×