Stateless Session

What is the use case of StatelessSession in hibernate?
I looked at the documentation, and I believe that that only use case for it is if you want to retreive lots of data from the database and do some processing with that, and you don’t want to store them in the 1st level cache.

I can’t find inserts and update useful with StatelessSession, because even though the data won’t be stored in the 1st level cache, but won’t be able to use JDBC batching because data would be inserted into the DB immediately when we call session.insert(employee).

Is my understanding correct?

Due to cascading multiple entities can end up in the temporary action queue and I am pretty sure batching will still apply.

In general, a stateless session will consume less memory because Hibernate can avoid creating certain data structures, so yes, it’s mostly useful when processing big amounts of data. I guess though, that it is just as good as regularly calling session.clear() to clear the first level cache.