0 Replies Latest reply on Mar 15, 2007 11:37 PM by quang huynh

    can not save persistent object into database, pls help

    quang huynh Newbie

      hi,

      I am new to hibernate. I am trying to save a data object into oracle database but it is silent after executing. No record inserted into database. I catched the error but no error message thrown also.

      Retrieve data from database is ok. Below is my code for inserting:

      Session session = factory.openSession();
      Transaction tx=null;
      try{
      tx = session.beginTransaction();

      Player p = new Player();
      p.setPlayerid(3);
      p.setPosition("defender");
      p.setName("Mark");
      p.setSalary(600);
      session.saveOrUpdate(p);

      tx.commit();
      }catch(HibernateException e){
      System.out.println("insert error:"+e.getMessage());
      tx.rollback();
      }
      session.close();

      Any help will be appreciated.

      Regards,