//Create new instance of Contact and set values in it by reading them from form object System.out.println(" Inserting Book object into database.."); Book book = new Book(); book.setStrBookName("Hibernate Tutorial"); session.save(book); System.out.println("Book object persisted to the database."); tx.commit(); session.flush(); session.close(); }catch(Exception e){ System.out.println(e.getMessage()); }finally{ }
} }
Please compare your code with this...There you are missing "Transaction " after session instance is created and tx.commit() is missing...I think...Try and let me know......
View All Comments
| View Tutorial