Flushing a StatelessSession

In StatelessSessionImpl, the flush() method is empty. This seems logical given the contract that every method call is sent to the database immediately — in this case, a flush would be unnecessary.

However, a stateless session still does support JDBC batching, which means that the above contract isn’t really true. In fact, each method call immediately results in a SQL statement being generated (and logged!), but it is by no means guaranteed that the statement is sent to the database immediately.

In my opinion, a flush() method would make perfect sense in such cases. For example, I would like to be able to programmatically trigger the execution of pending statements — and thus any checks associated with them, such as constraint or @Version checks — before the transaction is committed.
What do you think?

Hey, I think you should join our chat platform and start a discussion there. I would have to dig a bit into the matter, but I think I saw someone suggesting a different API for handling batching on stateless session in the future instead.