I followed this tutorial mykong in order to use hibernate with mysql.
My problem is that when I launch the program I am getting this exception org.hibernate.TransactionException: Transaction not successfully started".
So I tried to use session.persist(Object) and session.flush() instead of session.save(Object) and session.getTransaction().commit(). Now I am not getting any exception but the object is not saved in the database. logs show the request
Hibernate: insert into stock (STOCK_CODE, STOCK_NAME) values (?, ?)
Could someone help me with this ?
session = HibernateUtil.getSessionFactory().openSession();
Stock stock = new Stock();
stock.setStockCode("4715");
stock.setStockName("GENM");
session.persist(stock);
session.flush();
session.getTransaction().commit();
session.close();