Professional Documents
Culture Documents
Hibernate Framework: Traditional Way of Database Connectivity
Hibernate Framework: Traditional Way of Database Connectivity
Hibernate Framework: Traditional Way of Database Connectivity
Advantage
Developer effort reduced by 95% 1. Project Development Cost Reduced 2. Improves the performance by using best concepts of JDBC such as PreparedStatement, Batch Operation, RowSets, Connection Pooling 3. Managing Associates in Hibernate Framework is as simple as working with collection api such as List, Set, Map 4. No memory leaks in Hibernate framework since resources are released by hibernate framework 5. Hibernate provides ORM framework. So, It has to follow all ORM Rules a. Objects becomes Records and vice versa b. Support Object Query Language (HQL) c. Should Support different primary key generators d. Should configure Hash memory called 2nd level Cache 6. Hibernate used POJO (javabeans without events).
import java.io.Serializable; @SuppressWarnings("serial") public class Employee implements Serializable { private String empname; private Integer empage; private Double empsalary; private Integer empid; public Employee(String empname, Integer empage, Double empsalary, Integer empid) { this.empname = empname;
this.empage = empage; this.empsalary = empsalary; this.empid = empid; } public String getEmpname() { return empname; } public void setEmpname(String empname) { this.empname = empname; } public Integer getEmpage() { return empage; } public void setEmpage(Integer empage) { this.empage = empage; } public Double getEmpsalary() { return empsalary; } public void setEmpsalary(Double empsalary) { this.empsalary = empsalary; } public Integer getEmpid() { return empid; } public void setEmpid(Integer empid) { this.empid = empid; } @Override public String toString() { return "Employee [empname=" + empname + ", empage=" + empage + ", empsalary=" + empsalary + ", empid=" + empid + "]"; } }
Hibernate Architecture
Hibernate.cfg.xml
<?xml version="1.0" encoding="UTF-8"?> <hibernate-configuatrion> <property name="driverclassname">sun.jdbc.odbc.JdbcOdbcDriver</property> <property name="url">jdbc:odbc:hib</property> <property name="username">username</property> <property name="password">password</property> </hibernate-configuatrion>