[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - can not save persistent object into database, pls help

hquang do-not-reply at jboss.com
Thu Mar 15 23:37:04 EDT 2007


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,

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4028658#4028658

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4028658



More information about the jboss-user mailing list