Hi, I'm not sure if this is the correct place to be posting these discrepancies, but hopefully someone who can fix them will notice and get around to updating the tutorial.
URL:
http://www.hibernate.org/hib_docs/v3/re ... orial.html
the EventManager class described in the tutorial makes a call to session.getTransaction() where no such method exists.
It looks like getTransaction has been replaced by returning a transaction from session.beginTransaction() making the correct code:
Code:
private void createAndStoreEvent(final String title, final Date theDate) {
final Session session = HibernateUtil.getSessionFactory().getCurrentSession();
final Transaction transaction = session.beginTransaction();
final Event theEvent = new Event();
theEvent.setTitle(title);
theEvent.setDate(theDate);
session.save(theEvent);
transaction.commit();
}
That allows the code to compile, however I am having trouble at runtime when hibernate goes to save the Event instance, and I'm fairly certain it's because I'm missing a piece of configuration in hibernate.cfg.xml
The stack trace is as follows:
Code:
Exception in thread "main" org.hibernate.HibernateException: No TransactionManagerLookup specified
at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:503)
at events.EventManager.createAndStoreEvent(EventManager.java:26)
at events.EventManager.main(EventManager.java:18)
The only slight variation I'm taking from the tutorial is in using MySQL instead of HS, however I'm convinced that's not the issue as there's no problem initialising Hibernate (which involves establishing the connection and running the CREATE statements).
I'll probably find the Transaction configuration by myself, I thought I'd post the issues here somewhere so they could be fixed to make things easier for the next people to use the tutorial.