But if you don't have anything to commit/rollback, why even have a transaction. The 4 methods in Transaction are commit(), rollback(), wasCommitted() and wasRolledBack(). If you don't need to do any of these, why create a transaction. If you call transaction.commit() for a SELECT statement, don't you end up opening yourself up to the possibility of updating data by some fluke chance. While the example in the javadocs for Session talks of using transaction, it seems to pertain more to modification of persistent objects, not retrieval of data.
|