IMRAN DAUDFOUNDATION UNIVERSITYINSTITUTE OF MANAGEMENT ANDCOMPUTER SCIENCESImran DaudFUIMCSWeb EngineeringHibernate
What is Hibernate? Hibernate is an object-relational mapping (ORM)library for the Java language, providing a frameworkfor...
Hibernate Life Cycle
Steps In Creating Hibernate Application1. Create Database(preferably MySQL)2. Create Web Project and select Hibernate opti...
Database Connection
3. Once Project is created, explore “hibernate.cfg.xml” file, located insource package, for configuration. (This file cont...
5. Add “hibernate.show_sql” property by setting vlaue “true”.6. Now expand ‘Miscellaneous Properties’ node and add“hiberna...
Generating Hibernate Mapping Files andPOJOs Classes9. First Create Hibernate Reverse Engineering File For Hibernate Mappi...
 Select Tables you want to load in reverse engineering file.
Caution: In Netbeans edit hibernate.cfg.xml file and changefollowing:
Creating the Hibernate Mapping Files andPOJOs12. Select Hibernate Mapping Files and POJOs from a Database in theHibernate ...
Creating the FilmHelper.java Helper Class15. will be used to perform Hibernate queries on the database.16. Create new java...
Adding helper functions in helper file
Reference http://www.csl.mtu.edu/cs2321/ Netbeans.org Roseindia.net Jsptut.com tutorialspoint.com/jsp http://java.su...
Próxima SlideShare
Cargando en…5
×

6. hibernate

430 visualizaciones

Publicado el

JSP (Java Server Pages) Lecture # 6
If you want to learn the jsp's Framework (Hibernate) then it is definatly the best lecture to learn in 15 mins

Publicado en: Educación, Tecnología
  • Sé el primero en comentar

  • Sé el primero en recomendar esto

6. hibernate

  1. 1. IMRAN DAUDFOUNDATION UNIVERSITYINSTITUTE OF MANAGEMENT ANDCOMPUTER SCIENCESImran DaudFUIMCSWeb EngineeringHibernate
  2. 2. What is Hibernate? Hibernate is an object-relational mapping (ORM)library for the Java language, providing a frameworkfor mapping an object-oriented domain model to atraditional relational database.Source: WikiPedia
  3. 3. Hibernate Life Cycle
  4. 4. Steps In Creating Hibernate Application1. Create Database(preferably MySQL)2. Create Web Project and select Hibernate option in Framework.
  5. 5. Database Connection
  6. 6. 3. Once Project is created, explore “hibernate.cfg.xml” file, located insource package, for configuration. (This file contains details of DB connection)4. Add property that enables thread and sql within application. To add property double click “hibernate.cfg.xml” file and go to design view. Expand Configuration property and Miscellaneous Property.
  7. 7. 5. Add “hibernate.show_sql” property by setting vlaue “true”.6. Now expand ‘Miscellaneous Properties’ node and add“hibernate.current_session_context_class” with value „thread‟.7. Add another property “hibernate.query.factory_class” with value setto “org.hibernate.hql.classic.ClassicQueryTransactionFactory”.8. Creating the “HibernateUtil.java” Helper File (For session factory).
  8. 8. Generating Hibernate Mapping Files andPOJOs Classes9. First Create Hibernate Reverse Engineering File For Hibernate Mapping Files and POJOs from a Database wizard you need„hibernate.reveng.xml‟ file. The Hibernate Mapping Files and POJOs from a Database wizard requires„hibernate.reveng.xml‟ and „hibernate.cfg.xml‟.10. Right-click the Source Packages node in the Projects window andchoose New > Other to open the New File wizard.11. Select Hibernate Reverse Engineering Wizard in the Hibernatecategory.
  9. 9.  Select Tables you want to load in reverse engineering file.
  10. 10. Caution: In Netbeans edit hibernate.cfg.xml file and changefollowing:
  11. 11. Creating the Hibernate Mapping Files andPOJOs12. Select Hibernate Mapping Files and POJOs from a Database in theHibernate category. Click Next.13. Ensure that the „hibernate.cfg.xml‟ and „hibernate.reveng.xml‟ filesare selected in the drop down lists. (This will make java files for each table present in DB)
  12. 12. Creating the FilmHelper.java Helper Class15. will be used to perform Hibernate queries on the database.16. Create new java file and append file with following java code.
  13. 13. Adding helper functions in helper file
  14. 14. Reference http://www.csl.mtu.edu/cs2321/ Netbeans.org Roseindia.net Jsptut.com tutorialspoint.com/jsp http://java.sun.com

×