I've been told that I don't need to use transactions...that session.save and session.flush are enough. But clearly it's not working.I'm really new in this hibernate world so I don't know how to use transaction. How would that code be? Thank you very much.

Exception in thread "main" org.hibernate.HibernateException: No CurrentSessionContext configured! at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:572) at acessoBanco.Leitor.main(Leitor.java:50)

But if i change it to Session session = factory.openSession(); instead of Session session = factory.GetCurrentSession(); it works.

I also tried to call two methods in main, one opening a session and the other getting it but I got the same error.What does it mean? Is there another thing I have to do before using GetCurrentSession?