I have a concern using StatelessSession
and ScrollableResults
in spring application with hibernate.
I have a number of DAOs mostly using common session object autowired in them, but for one purpose I need to cycle through a whole table.
I found out that for this it is efficient to use ScrollableResults
to iterate objects and StatelessSession
not to store any results attached in memory.
However, I need to do this iteration outside the DAO, because the info from the DB is used to access foreign API. So I've crated methods to create and close StatelessSession
from outside DAO.
I wonder, how in this case should I manage transactions? It seems like no transactional operations are needed at all (data is only readed), but on code review I've been told that transaction can be created automatically and never closed by Spring Hibernate Transaction Manager. So should it be overrider manually or would it be a useless precaution?
Asked
Active
Viewed 544 times
3

Viktor Lopatin
- 31
- 2