为什么在Hibernate中进行只读操作时需要事务?
以下事务是否会在数据库中放置锁定?
从数据库获取的示例代码:
Transaction tx = HibernateUtil.getCurrentSession().beginTransaction(); // why begin transaction?
//readonly operation here
tx.commit() // why tx.commit? I don't want to write anything
我可以使用session.close()替代tx.commit()吗?