Friday 26 July 2013

creation of Hibernate Project

creation of Hibernate  Project

  


we can create hibernate project as in two ways.

1. By creating normal java project (java perspective)
2. By creating Dynamic web project (jee perspective)


First Hibernate application with all CRUD operations


  • Let us create a Dynamic web project with JEE perspective:
  • Scenario: I want to automate Employee details. Properties like empno,empname,dateofbirth,dataofjoin,phno,should be stored in Db table.
  • i want to perform the following CRUD operation on Employee table in database
  1. INSERT employee details
  2. Select
  3. modify
  4. delete
create Dynamic Web Project "InfyEmployee" as below

1. choose new from file menu
2. choose dynamic web project
3. give project name: ex: InfyEmployee
4. click on finish
5. add all required jar files to the project:

Employee bean:

Now create a package as com.infy and create Employee class into com.infy package as shown below:

pakage com.infy;
import java.util.Date;
public class Employee
{
  private int empno;
  private String empName;
  private Date dob;
 private Date doj;
 private String phno

//setters and getters methods

}

/* here empNo is Identifier. All persistenses classes should only have T no-argument constructor or default constructor. Should not contain Parameter constructor*/









No comments:

Post a Comment