Академический Документы
Профессиональный Документы
Культура Документы
(row,column)
features are:(SessionFactory,pojo classes,session,session object,config file,mapping file,persistent class) Advantages of hibernate 1) using annotation or XML file. 2) Java objects can be store directly and fetch from the database . 3) there is a change in any table or Database, you need to change only the XML file and the Java Class related to the table.. 4) need to work on familiar Java data types not sql. 5) It doesn't need any application server 6) simple query for data access.
(sess.fact is resource intensive obj.) Transaction Management : This service allows for executing a several
is created once as per database
Testemp class
package com.hibernate.chapter1; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.cfg.AnnotationConfiguration; //create table by calling hiber import org.hibernate.tool.hbm2ddl.SchemaExport; public class TestEmployee { public static void main(String[] args) { AnnotationConfiguration config=new AnnotationConfiguration(); config.addAnnotatedClass(Employee.class); config.configure("hibernate.cfg.xml"); new SchemaExport(config).create(true, true); //end create table; SessionFactory factory=config.buildSessionFactory(); Session session=factory.getCurrentSession(); session.beginTransaction(); Employee alex=new Employee(); alex.setEmpId(802); alex.setEmpName("ajay kumar"); session.save("alex"); session.getTransaction().commit();