Hibernate version: 3.1
If I want to just read from a database, so something like this:
Code:
Session session = HibernateUtil.currentSession();
Transaction tx = null;
tx = session.beginTransaction();
org.hibernate.Query query = session.createQuery("from Document");
query.list(); // just symbolically
tx.commit();
Is there a need for commiting this transaction? If i just read and don't change anything then do i need to commit? If I should, what would happen if I don't use the commit?
Is there any need for a transaction at all? I tried this:
Code:
Session session = HibernateUtil.currentSession();
org.hibernate.Query query = session.createQuery("from Document");
query.list(); // just symbolically
But sometimes I got an error saying "Couldn't obtain connection" (although sometimes it was ok).
Thanks for advice.