I need to fetch from the database a large amount of data and make a stream from it. But ScrollableResult from Hibernate and Cursor from MyBatis bounded to a session that is not thread-safe and must be closed. How to do such things right?
Source.unfoldResource should be your friend for such tasks, see docs: Source.unfoldResource • Akka Documentation
Many thanks! This is exactly what I need.