1 / 8

Hibernate

Hibernate. Netbeans-Database-Hibernate Downloads. Download Jdk and install Download Java IDE ( Netbeans ,Eclipse) Setup a Database ( Postgresql , MySQL , Oracle ..) Download hibernate files from http :// sourceforge.net/projects/hibernate/files/ hibernate Core hibernate annotations.

csilla
Télécharger la présentation

Hibernate

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Hibernate

  2. Netbeans-Database-Hibernate Downloads • Download Jdk and install • Download Java IDE (Netbeans,Eclipse) • Setup a Database (Postgresql,MySQL,Oracle..) • Download hibernate files from http://sourceforge.net/projects/hibernate/files/ • hibernate Core • hibernate annotations

  3. How to configure? MySQL Database Netbeans User Library hibernate.cfg.xml Hibernate

  4. User library Required Libraries antlr-2.7.6.jar cglib.jar commons-collections.jar dom4j.jar ejb-3-persistence hibernate-annotation.jar hibernate-commons-annotation.jar hibernate3.jar javassist-3.9.0.GA.jar jta-1.1.jar log4j.jar slf4j-api-1.5.8.jar slf4j-log4j12.jar // and database connector mysql-connector-java-5.1.13-bin.jar • User library is a folder for required hibernate jar files • In your IDE: • create a Hibernate "library" • add JARs to the library • better than copying JAR files to your project

  5. Create a Hibernate Library in Eclipse 1. Tools -> Libraries 3. Click "Add Library..." and select "User Library", Next> 4. Create a new user library named "Hibernate" 5. Add Jar files

  6. hibernate.cfg.xml • hibernate.cfg.xml • Customize, • <!-- Database connection settings --> • <!-- SQL dialect --> • <!-- Enable Hibernate's current session context --> (thread) • Make comment <!-- Drop and re-create the database schema on startup --> and 2 mapping lines

  7. example • Example 1: Employee Example • Setup Eclipse-Database-Hibernate • Create a table out of a class • Insert an object as a record • Example 2 : Employee Example • Other annotations • Generate primary key

  8. Example • Example 3 : how to split one class to two tables • Example 4 : two classes one table • Example 5 : compound primary key • Example 6 : inheritance mapping • Example 7: one to one mapping • Example 8: one to many • Example 9: many to many

More Related