Hibernarte Note

  • Upload
    md-imam

  • View
    224

  • Download
    0

Embed Size (px)

Citation preview

  • 8/3/2019 Hibernarte Note

    1/30

    Hibernate 3.0

    1. Features of Hibernate are:-

    1) Automatic primary key generation2) High performance3) J2EE integration4) Object / Relational Mapping5) Object-Oriented Query Language

    2. Advantages of Hibernate:-

    1) Hibernate is data base independent, same code will work for all data bases like Oracle, MySQL, SQLServer etc.

    2) High Performance3) Development fast in case of Hibernate because you dont need to write queries.4) Automatic primary key generation5) In the xml file you can see all the relations between tables in case of Hibernate. Easy readability.6) Hibernate Support automatic versioning of rows but JDBC not.

    3. Disadvantages of Hibernate:-

    1) Everything is an object. If you need only a portion of data (say, for a search), you would still have toretrieve the object.

    2) Sometimes debugging and performance tuning becomes difficult.3) For complex data, mapping from object to tables and vice versa reduces performances.4) It is something difficult for the beginners.

    4. First application in Hibernate:-

    1) First we create a hibernate cfg.xml file2) Write first java persistence class.3) Mapping the Emp Object to the Database emp table4) SessionProvider is created for creating the object of session.

    5) Main java class

    1) First application in Hibernate

    It is a first application which persist data into database:

    Step 1:- First we create a hibernate.cfg.xml file:

    Hibernate uses the hibernate.cfg.xml to create the connection pooland setup required environment.

    // hibernate.cfg.xml

    org.hibernate.dialect.MySQLDialectjdbc:mysql://localhost:3306/testrootpasswordcom.mysql.jdbc.Driver

    1

  • 8/3/2019 Hibernarte Note

    2/30

    Hibernate 3.0

    Step 2:-

    write first java persistence class.

    // Emp.java

    package r4r;

    public class Emp {int id;String name,job;int salary;

    public Emp() { super();}public Emp(String name, Stringjob, int salary) { super(); this.name = name; this.job = job; this.salary = salary;}

    public int getId() { return id;}public void setId(int id) { this.id = id;}public String getName() { return name;}public void setName(String name) { this.name = name;}public String getJob() { returnjob;}public void setJob(Stringjob) {

    this.job = job;}public int getSalary() { return salary;}public void setSalary(int salary) { this.salary = salary;}

    }

    Step:3

    // Mapping the Emp Object to the Database Emp table

    The file Emp.hbm.xml is used to map Emp Object to the Emp table in the database. Here is the code forEmp.hbm.xml:

    2

  • 8/3/2019 Hibernarte Note

    3/30

    Hibernate 3.0

    Step 4:-

    //SessionProvider is created for creating the object of session.

    //sessionProvider.java

    package r4r;

    import org.hibernate.Session;import org.hibernate.SessionFactory;import org.hibernate.cfg.Configuration;

    public class SessionProvider {static SessionFactory factory;static{Configuration cfg=new Configuration().configure();factory=cfg.buildSessionFactory();}public static Session getSession() { return factory.openSession();}}

    Step5:-

    // main java class

    //PersistTest.java

    package r4r;importjava.util.*;

    import org.hibernate.Session;import org.hibernate.Transaction;public class PersistTest {

    public static void main(String[] args) { Scannerin=new Scanner(System.in);

    Session session=SessionProvider.getSession();Transaction t=session.beginTransaction();

    while(true){

    System.out.println("Enter Name:"); String n=in.nextLine(); System.out.println("Enter Job:"); Stringj=in.nextLine(); System.out.println("Enter Salary:"); int s=in.nextInt(); in.nextLine();// to remove unread newline character.

    Emp e=new Emp(n,j,s);session.save(e);

    System.out.println("want to persist more objects yes/no?"); String ans=in.nextLine();

    if(ans.equals("no")) break;

    }t.commit();session.close();

    System.out.println("successfully persisted.");}

    }

    Commonly used classes and interfaces exposed by hibernate for application developer:-

    Configuration: - Configuration object is used by the hibernate to stored configuration information inobject form.Configuration information data is required by hibernate to connect to a database andinformation of classes that are to be managed by hibernate.

    3

  • 8/3/2019 Hibernarte Note

    4/30

    Hibernate 3.0

    SessionFactory:- It is a factory class which is used by application developer to create session.A partfrom this it can also be used to manage second level cache.

    Session:-This is a main interface throw which application eveloper interact. This interface providesmethod for persistence object, creating transaction and query objects for each user a different session isprovided.

    Transaction:-This interface is used by application developer to transact execution query.

    Query: - This interface is used by he application developer to execute HQL query. HQL is objectversions of sql used by hibernate.

    A simple select program of Hibernate :-

    1- Create hibernate.hbm.xml file

    org.hibernate.dialect.Oracle9Dialectjdbc:oracle:thin:@localhost:1521:xesystemsystemoracle.jdbc.driver.OracleDriver

    2- Create Emp.java class:- Show in a Message Box using Validation Summary

    package r4r;

    publicclass Emp {

    intid;

    String name,job;

    intsalary;

    public String getName() {

    returnname;

    }

    publicvoid setName(String name) {

    this.name = name;

    }

    publicint getId() {

    returnid;

    }

    4

  • 8/3/2019 Hibernarte Note

    5/30

    Hibernate 3.0

    publicvoid setId(int id) {

    this.id = id;

    }

    public String getJob() {

    returnjob;

    }

    publicvoid setJob(String job) {

    this.job = job;

    }

    publicint getSalary() {

    returnsalary;

    }

    publicvoid setSalary(int salary) {

    this.salary = salary;

    }

    }

    Show in a Message Box using Validation Summary

    3- Create Emp.hbm.xml file:-

    4- Create Session provider class

    // SessionProvider.java

    package r4r;

    import org.hibernate.Session;import org.hibernate.SessionFactory;

    import org.hibernate.cfg.Configuration;

    public class SessionProvider {static SessionFactory factory;static

    5

  • 8/3/2019 Hibernarte Note

    6/30

    Hibernate 3.0

    {

    Configuration cfg=new Configuration().configure();factory=cfg.buildSessionFactory();

    }public static Session getSession(){return factory.openSession();}

    }

    5- Create a main class

    // SelectTest.java

    package r4r;

    importjava.util.Scanner;

    import org.hibernate.Session;import org.hibernate.Transaction;

    public class SelectTest {

    public static void main(String rr[]){Session session=SessionProvider.getSession();Transaction t=session.beginTransaction();// List list=new List;Scannerin=new Scanner(System.in);System.out.println("enter id:-");int id=in.nextInt();Emp e=(Emp)session.load(Emp.class,id);System.out.println("followin records are fetched:-");System.out.println(e.getId()+"\t"+e.getName()+"\t"+e.getJob()+"\t"+e.getSalary());t.commit();session.close();

    }}

    Some Important Methods Of Hibernate:-

    save():-

    method of Session interface is used to persist object.

    public void save (Object o);

    delete():-

    is used to remove a persistent object.

    public void delete(Object o);

    refresh():-

    is used to Synchronized the state of a persistaent logc to the database.

    public void refresh(Object o);

    beginTransaction:-

    is used to start a transaction.

    public Transaction begintransaction();

    6

  • 8/3/2019 Hibernarte Note

    7/30

    Hibernate 3.0

    createQuery:-

    is used to obtain query object.Query object is used to run sql query.

    public query createquery();

    etc

    ID Generator:-

    Id generator is used to auto generate id of objects. Different database support different types of generator. Mostcommonly used generator that is supported by oracle is:

    1-increment

    2-sequential

    1. increment:- Increment generator uses highest value of primary key increases to generator id value.

    Example:- Consider previous example of Student, in which id generator is used as:

    2-Sequence Generator:- sequence generator uses the sequence define in the database for generating id.

    Example:- Consider Emp example

    oursequence

    Hibernate Mapping: - There are two types of mapping:

    1-Is -A Mapping

    7

  • 8/3/2019 Hibernarte Note

    8/30

    Hibernate 3.0

    2-Has-A Mapping

    1. Is-A Mapping:- Is a relation between persistent object can be implemented in the following three ways-1- Table per class Hierarchy2- Table per subclass3- Table per class

    1- Table Per Class Hierarchy:- In this approach objects of all the classes of a family are mapped to a singletable in a database. This table contain field to represent combined data member of all the classes of the familyplus an additional fields is used to describe record of the table ,that is, to identified which record of table representobject of which class of the family

    Advantages of This Approach:- Major advantages of this approach is performance. Because hibernate need tomanage to all the classes to the family.

    Disadvantages of This Approach:-

    1-Table is not normalized

    2-Not Null constraint can not be applied non the field representing data member of subclass

    2-Table per Subclasses: -In this approach one table for each class of the family is created. Table for the parentclass contains field to represenent parent class data member and table for the subclasses contains fields torepresent their own data member. Primary key of parent table is used for hierarchy in table for subclasses.

    Advantages-

    Tables are normalized

    Not null constraint can be applied

    Disadvantages:-

    performance is degraded because to insert and fetched subclasses object .Multiple queries or joins arerequired

    Tables are not fully normalized.

    3-Table Per Class:- In this approach one table for each class of the family is created. Each table contains fields torepresents declared as well as inherited data member of the class.

    Advantages:-

    Tables are fully normalized.

    Not null constraint cn be applied on all the table of fields.

    Better performance.

    Disadvantages:-

    Relation of object is losses in the table.

    This approach s not supported in the all ORM framework.

    Has-A- Mapping:- Has-A relation between object can be of following types:-

    1-One-to-One (Unidirectional and bidirectional)

    2-One-to-Many (Unidirectional and bidirectional)

    3-Many-to-Many (Unidirectional and bidirectional)

    8

  • 8/3/2019 Hibernarte Note

    9/30

    Hibernate 3.0

    1-One-to-One Mapping:-One to one mapping between object can be implement with the three ways- In case ofunidirectional:-

    1- Using primary key-foreign key relation

    2- Using same primary Key

    3-Using relation table

    Disadvantages:- This approach can only be used if relation between objects which be one to one .If in future oneto one is changed to one to many then this approach went to wrong.

    1- Using Primary Key-Foreign Key Relation:- Consider two classes first Address(owned object) and secondPerson(owner object) .In address there are three fields id, street and city. And in person table it contains id, name,address.

    Example:-

    //hibernate.cfg.xml

    org.hibernate.dialect.Oracle9Dialectjdbc:oracle:thin:@localhost:1521:xesystem

    systemoracle.jdbc.driver.OracleDriver

    //Address.java

    package r4r;

    public class Address {int id;String city,street;

    public Address() {

    }public Address(String city, String street) {super();this.city = city;this.street = street;}public int getId() {return id;}public void setId(int id) {this.id = id;}public String getCity() {return city;}public void setCity(String city) {this.city = city;}public String getStreet() {return street;

    9

  • 8/3/2019 Hibernarte Note

    10/30

    Hibernate 3.0

    }public void setStreet(String street) {this.street = street;}}

    //Person.java

    package r4r;

    public class Person {int id;String name;Address address;

    public Person() {super();}public Person(String name, Address address) {super();this.name = name;this.address = address;

    }public int getId() {return id;}public void setId(int id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}

    public Address getAddress() {return address;}public void setAddress(Address address) {this.address = address;}}//PkFk.hbm.xml

    10

  • 8/3/2019 Hibernarte Note

    11/30

    Hibernate 3.0

    //InsertTest.java

    package r4r;

    import org.hibernate.Session;import org.hibernate.SessionFactory;import org.hibernate.Transaction;

    import org.hibernate.cfg.Configuration;

    public class InsertTest {

    public static void main(String[] args) {

    try{Configuration cfg=new Configuration().configure();SessionFactory f=cfg.buildSessionFactory();Session session=f.openSession();Transaction t=session.beginTransaction();Address a=new Address("noida","u.p");Person p=new Person("name",a);session.save(a);

    session.save(p);t.commit();session.close();System.out.println("successfully inserted");}catch(Exception e){System.out.println("exception thrown");}

    }

    }

    2-Same Primary Key Mapping:- In this approach owner and owned shared same primary key value.

    Advantages:- It eliminate the need of foreign key.

    Disadvantages:-

    1- A special id is generator is required to used id of one object as id of another.

    2- If it converted into one-to-many then this approach will not be used.

    Example:-

    //SamePk.hbm.xml

    address

    11

  • 8/3/2019 Hibernarte Note

    12/30

    Hibernate 3.0

    3-Using Relation Table:- In this approach the relation table is used to manage the relation between obect.Primary key of both objects are used as foreign key in relation table .

    Advantages:- support one-to-many ,if any time one name has many address then it support it .

    Disadvantage:- Performance is degraded.

    Example:- In this approach three tables are used

    1- Table for Batch(id,name)

    2-Table for Trainer(id,name,fees)

    3-Table for Relation(batchid,trainerid)

    2-One-to-Many Mapping:-This type of association relates one entity object to many object of another entity.

    Example:- Relationship between a department and employee.Many employee can work in a single department.

    //hibernate.cfg.xml

    12

  • 8/3/2019 Hibernarte Note

    13/30

    Hibernate 3.0

    org.hibernate.dialect.Oracle9Dialectjdbc:oracle:thin:@localhost:1521:xesystemsystemoracle.jdbc.driver.OracleDriver

    // Batch.java

    package r4r;

    public class Batch {int id;String time,course,mode;Trainer trainer;public Batch() {super();}public Batch(String time, String course, String mode,Trainer t) {super();this.time = time;this.course = course;this.mode = mode;this.trainer=t;}public int getId() {return id;}public void setId(int id) {this.id = id;}public String getTime() {return time;}public void setTime(String time) {

    this.time = time;}public String getCourse() {return course;}public void setCourse(String course) {this.course = course;}public String getMode() {return mode;}public void setMode(String mode) {this.mode = mode;}public Trainer getTrainer() {return trainer;

    }public void setTrainer(Trainer trainer) {this.trainer = trainer;}

    }

    //Trainer.java

    package r4r;

    importjava.util.*;

    public class Trainer {int id;String name;

    Set batches;

    public Trainer() {super();

    13

  • 8/3/2019 Hibernarte Note

    14/30

  • 8/3/2019 Hibernarte Note

    15/30

    Hibernate 3.0

    So here is an many-to-many mapping

    Example Of Many To Many Mapping:-

    //hibernate.cfg.xml

    org.hibernate.dialect.Oracle9Dialectjdbc:oracle:thin:@localhost:1521:xesystemsystemoracle.jdbc.driver.OracleDriver

    //Emp.java

    package r4r;importjava.util.*;public class Emp {

    int id;String name,job;int salary;Set privilages;

    public Emp() {super();// TODO Auto-generated constructor stub

    }public Emp(String name, Stringjob, int salary, Set privilages) {super();this.name = name;this.job = job;this.salary = salary;this.privilages = privilages;}public int getId() {return id;}public void setId(int id) {this.id = id;}public String getName() {return name;

    }public void setName(String name) {this.name = name;}public String getJob() {

    15

  • 8/3/2019 Hibernarte Note

    16/30

  • 8/3/2019 Hibernarte Note

    17/30

    Hibernate 3.0

    //Selecttest.java

    package r4r;

    importjava.util.Iterator;importjava.util.Scanner;importjava.util.Set;

    import org.hibernate.Session;import org.hibernate.SessionFactory;import org.hibernate.cfg.Configuration;

    public class Selecttest {

    public static void main(String[] args) {

    Configuration cfg=new Configuration().configure();SessionFactory f=cfg.buildSessionFactory();Session session=f.openSession();Scannerin=new Scanner(System.in);System.out.println("enter empid");int empid=in.nextInt();Emp emp=(Emp) session.load(Emp.class,empid);System.out.println("employees details");System.out.println(emp.getName()+"\t"+emp.getJob()+"\t"+emp.getSalary());System.out.println("following privilages are enjoyed:");Set pr=emp.getPrivilages();Iterator itr=pr.iterator();while(itr.hasNext())

    {Privilage pre=itr.next();System.out.println(pre.getId()+"\t"+pre.getName()+"\t"+pre.getCost());

    }System.out.println("enter privilage id:");int privilageid=in.nextInt();Privilage privilages=(Privilage) session.load(Privilage.class,privilageid);System.out.println("following privilage detais:");System.out.println(privilages.getName()+"\t"+privilages.getCost());System.out.println("employee benifited are:-");Set emp11=privilages.getEmployees();System.out.println("following employees are benifited: ");

    Iterator eitr=emp11.iterator();

    while(eitr.hasNext()){

    Emp e=eitr.next();

    17

  • 8/3/2019 Hibernarte Note

    18/30

  • 8/3/2019 Hibernarte Note

    19/30

    Hibernate 3.0

    Syntax Of HQL Queries:-

    To fetch the all the object of a type:-

    from classname as Alias

    ex-

    1- To fetch all the emp object:-

    Query q=Session.createQuery("From Emp e")

    -2- To fetch only Those object to class which satisfy given condition

    from classname as Alias where condition

    ex- To fetch all those employee who earn more 75000/month

    from Emp e where e.salary>75000

    3-To fetch name of all manager

    select e.name from Emp e where e.job="manager"

    Note:-HQL queries supports named as well as positioned parametersFirst Approach:-(positioned parameter):-Query q=session.createQuery("select e.name from Emp e e.job=?");q.setString(1,job);

    // value of positioned parameter is set.

    Second Approach(Named parameter):-Query q=session.createQuery("from Emp e where e.salary>:salary");q.setInt("salary",s);

    Simple Program Of Select in HQL:-

    Step1- Create hibernate.cfg.xml

    org.hibernate.dialect.Oracle9Dialectjdbc:oracle:thin:@localhost:1521:xesystemsystemoracle.jdbc.driver.OracleDriver

    Step2- Create Persitent class

    //Emp.java

    19

  • 8/3/2019 Hibernarte Note

    20/30

    Hibernate 3.0

    package mypack;

    public class Emp {int id;String name,job;int salary;

    public Emp() {super();

    }public Emp(String name, Stringjob, int salary) {super();this.name = name;this.job = job;this.salary = salary;}public int getId() {return id;}public void setId(int id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}public String getJob() {returnjob;}public void setJob(Stringjob) {this.job = job;}public int getSalary() {return salary;}public void setSalary(int salary) {this.salary = salary;}

    }

    //Emp.hbm.xml?xml version='1.0' encoding='UTF-8'?>

    //PersistTest.java

    package mypack;importjava.util.*;

    import org.hibernate.Query;import org.hibernate.Session;

    public class PersistTest {

    @SuppressWarnings("unchecked")public static void main(String[] args) {

    Session session=SessionProvider.getSession();

    Query q=session.createQuery("from Emp e");List e=(List) q.list();

    20

  • 8/3/2019 Hibernarte Note

    21/30

    Hibernate 3.0

    Iterator itr=e.iterator();System.out.println("following data fetched");while(itr.hasNext()){Emp emp=itr.next();

    System.out.println(emp.getName()+"\t"+emp.getSalary());

    }session.close();

    }}

    Example of Select Program in HQL:-hibernate.cfg.xml

    org.hibernate.dialect.Oracle9Dialect

    jdbc:oracle:thin:@localhost:1521:xe system system oracle.jdbc.driver.OracleDriver

    Student.java

    package mypack;

    public class Student {int id;String name;

    String subject;

    public Student() {super();

    }public Student(String name, String subject) {

    super();this.name = name;this.subject = subject;

    }public int getId() {

    return id;}public void setId(int id) {

    this.id = id;

    }public String getName() {

    return name;}public void setName(String name) {

    this.name = name;}public String getSubject() {

    return subject;}public void setSubject(String subject) {

    this.subject = subject;}

    }

    21

  • 8/3/2019 Hibernarte Note

    22/30

    Hibernate 3.0

    //Insert Demopackage mypack;

    importjava.util.Iterator;importjava.util.List;

    import org.hibernate.Query;import org.hibernate.Session;import org.hibernate.SessionFactory;import org.hibernate.cfg.Configuration;

    public class InsertDemo {

    @SuppressWarnings("unchecked")public static void main(String[] args) {

    Configuration cfg=new Configuration().configure();SessionFactory f=cfg.buildSessionFactory();Session session=f.openSession();Query q=session.createQuery("from Student");List student=q.list();Iterator itr=student.iterator();while(itr.hasNext()){

    Student s=itr.next();System.out.println(s.getName());

    }

    session.close();}}

    Hibernate Caching:-caching is the facility of storing object temporally in the memory . The purpose of caching toimprove the performance by reducing database hits . If same object is required by different session or user then itmake sense to fetch them only one and to store them into the cache so that they can provide the cache each timethey are requested.

    Hibernate support caching at two levels:-

    1- First Level Caching

    2-Second Level Caching

    First Level Caching :-(Transactional scope caching):- First level caching is implicitly enable. It is implementedby session. Fist level caching is responsible for storing the object used by user.Object in this cache hastransactional scope, once the transaction is completed object of this cache are synchronize to the database andcache is discarded.

    Second Level Cache (Application Scope caching):- Second level cache is not enable by default. This cachehas a application scope, Object in this cache are shared by multiple users. This cache is managed bysessionFactory

    NOTE:-Hibernate does not provide implementation of Second level caching , it only provide specification howsecond level cache should be implemented. Third party implementation of second level cache are available:

    22

  • 8/3/2019 Hibernarte Note

    23/30

    Hibernate 3.0

    1- EHCACHE ( Easy hibernate Caching)

    2-OSCACHE (Open source caching)

    Specification Of second Level Cache:- Hibernate Specification says that cache provider must defined block inmemory for storing object. I these storing block objects are stored in it. Each block must have name and musthave some additional properties.

    Second level cache is divided into two parts:-

    1- Object cache

    2-Query Cache

    1-Object Cache: - In object ache, object along with there relation is stored in Simplified Form.

    2-Query Cache: - In query cache, Queries are stored along with the ID of fetched object. For the implementationof query cache two reasons are created in memory

    1- In first reason query along with the value of parameter to store as key and id of returned object are stored asvalue.

    2- In second region time stamp of query execution is stored. The Purpose of this region is to identified whetherresult of query is valid or not.

    Program Of EHCache:-

    Example: This example shows the implementation of EHCache

    hibernate.cfg.xml:-

    system jdbc:oracle:thin:@localhost:1521:xe org.hibernate.dialect.Oracle9Dialect oracle oracle.jdbc.driver.OracleDriver net.sf.ehcache.hibernate.EhCacheProvider true

    truetrue

    m-to-m.hbm.xml:-

    23

  • 8/3/2019 Hibernarte Note

    24/30

    Hibernate 3.0

    keygenerator

    ehcache.xml:-

    keygenerator

    Emp.java:-

    package r4r;importjava.util.*;public class Emp {

    int id;String name,job;int salary;Set priviliges;

    24

  • 8/3/2019 Hibernarte Note

    25/30

  • 8/3/2019 Hibernarte Note

    26/30

  • 8/3/2019 Hibernarte Note

    27/30

    Hibernate 3.0

    {System.out.println(e);

    }}

    }

    Working With Collection In Hibernate:-Collection is widely used in hibernate .

    Example:-- hibernate.cfg.xml

    org.hibernate.dialect.Oracle9Dialect jdbc:oracle:thin:@localhost:1521:xe system

    system oracle.jdbc.driver.OracleDriver

    package r4r;

    importjava.util.List;

    public class Persons {

    int id;String name;List song;

    public Persons() {super();// TODO Auto-generated constructor stub

    }

    public Persons(String name, List song) {super();this.name = name;this.song = song;

    }

    27

  • 8/3/2019 Hibernarte Note

    28/30

    Hibernate 3.0

    public int getId() {return id;

    }public void setId(int id) {

    this.id = id;}public String getName() {

    return name;}public void setName(String name) {

    this.name = name;}public List getSong() {

    return song;}public void setSong(List song) {

    this.song = song;}}

    package r4r;

    public class Songs {

    int id;String info;

    public Songs() {super();

    }public Songs(String info) {

    super();this.info = info;

    }public int getId() {

    return id;}public void setId(int id) {

    this.id = id;}

    public String getInfo() {return info;

    }public void setInfo(String info) {

    this.info = info;}

    }

    package r4r;

    importjava.util.ArrayList;

    import org.hibernate.Session;import org.hibernate.SessionFactory;import org.hibernate.Transaction;

    import org.hibernate.cfg.Configuration;

    public class InsertTest {

    public static void main(String[] args) {

    try{Configuration cfg=new Configuration().configure();SessionFactory f=cfg.buildSessionFactory();Session session=f.openSession();ArrayList list=new ArrayList();list.add(new Songs("mast mast laila"));list.add(new Songs("dhink ckika"));Persons p=new Persons("sushant",list);

    Transaction t=session.beginTransaction();session.save(p);t.commit();

    session.close();

    28

  • 8/3/2019 Hibernarte Note

    29/30

    Hibernate 3.0

    System.out.println("successfully inserted");}catch(Exception e){

    System.out.println(e);}

    }}

    29

  • 8/3/2019 Hibernarte Note

    30/30

    Hibernate 3.0