Results 1 to 2 of 2
  1. #1
    ananddevaraj is offline Member
    Join Date
    Jun 2010
    Location
    Coimbatore
    Posts
    5
    Rep Power
    0

    Default Hibernate update function

    Can anyone help me regarding how to use the hibernate update function ?

  2. #2
    Prajin's Avatar
    Prajin is offline Senior Member
    Join Date
    Jun 2010
    Location
    Ktm, Nepal
    Posts
    120
    Rep Power
    0

    Default

    Here is the example: -
    -->
    Java Code:
    import java.util.Date;
    
    import org.hibernate.Session;
    import org.hibernate.SessionFactory;
    import org.hibernate.Transaction;
    import org.hibernate.cfg.Configuration;
    
    public class UpdateExample {
      /**
       * 
       */
      public static void main(String[] args) {
        // TODO Auto-generated method stub
        Session sess = null;
        try
     {
          SessionFactory fact = new Configuration()
    .configure().buildSessionFactory();
          sess = fact.openSession();
          Transaction tr = sess.beginTransaction();
          Insurance ins = (Insurance)sess.get
    (Insurance.class, new Long(1));
          ins.setInsuranceName("Prajin");
          ins.setInvestementAmount(2000);
          ins.setInvestementDate(new Date());
          sess.update(ins);
          tr.commit();
          sess.close();
          System.out.println("Update successfully!");
        }
        catch(Exception e){
          System.out.println(e.getMessage());
        }
      }
    }
    I hope this work
    Last edited by Prajin; 07-15-2010 at 11:56 AM. Reason: Forgot to use coe tag

Similar Threads

  1. Replies: 3
    Last Post: 12-04-2009, 03:08 PM
  2. How to update my jdk???
    By low224 in forum New To Java
    Replies: 4
    Last Post: 01-04-2009, 04:51 PM
  3. Auto Update Function
    By abiieez in forum New To Java
    Replies: 4
    Last Post: 04-16-2008, 04:17 PM
  4. Using sql:update tag
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-13-2008, 11:49 PM
  5. Replies: 2
    Last Post: 06-30-2007, 03:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •