H IBERNATE
N ETBEANS -D ATABASE -H IBERNATE D OWNLOADS 1. Download Jdk and install 2. Download Java IDE ( Netbeans,Eclipse) 3. Setup a Database (Postgresql, MySQL,Oracle..) 4. Download hibernate files from hibernate Core hibernate annotations
H OW TO CONFIGURE ? Netbeans Database Hibernate MySQL User Library hibernate.cfg.xml
U SER LIBRARY 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 Required Libraries antlr jar cglib.jar commons-collections.jar dom4j.jar ejb-3-persistence hibernate-annotation.jar hibernate-commons- annotation.jar hibernate3.jar javassist GA.jar jta-1.1.jar log4j.jar slf4j-api jar slf4j-log4j12.jar // and database connector mysql-connector-java bin.jar
C REATE A H IBERNATE L IBRARY IN E CLIPSE 1. Tools -> Libraries 3. Click "Add Library..." and select "User Library", Next> 4. Create a new user library named "Hibernate" 5. Add Jar files
HIBERNATE. CFG. XML hibernate.cfg.xml Customize, (thread) Make comment and 2 mapping lines
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
E XAMPLE 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