hi all,
i'm studying chapter 3 of the book hibernate quickly.
at the same time, i'm trying everyting in a sample application.
now, i came at the point where i have everything set up correctly.
i have one class "Event", from which I try to put an instance in the database.
When I try this, it works fine and i see my created line in the database
Code:
Event e = new Event();
e.setId(3);
e.setName("Meeting C");
e.setDuration(2005);
Session session = factory.openSession();
Transaction tx = session.beginTransaction();
session.save(e);
tx.commit();
session.close();
But when I try this (with flush() instead of transaction commit()), i get no errors, but there's no row created in the database. Should i maybe indicate somewhere in a config file "not to use transactions and commit by default "?
Code:
Event e = new Event();
e.setId(3);
e.setName("Meeting C");
e.setDuration(2005);
Session session = factory.openSession();
session.save(e);
log.debug("6");
session.flush();
session.close();