When I create a query in squeryl, it returns a Query [T] object. The query has not been executed yet and will be when I iterate over the Query object (Query [T] extends Iterable [T]).
At the time the request is executed, there must be a transaction {} or an inTransaction block {}.
I'm just talking about SELECT queries, and transactions are not needed, but the squeryl framework needs them.
I would like to create a query in the model of my application and pass it directly to the view, where the view assistant in the template iterates over it and presents the data. This is possible only when the transaction block {} is placed in the controller (the controller includes a template call, so the template that iterates is also inside). It is not possible to put the transaction block {} in the model because the model does not really execute the request.
But in my understanding, a transaction has nothing to do with a controller. This is a solution to the model for which the database is used, how to use it, and where to use transactions. Therefore, I want the transaction block {} to be in the model.
I know that I can - instead of returning an instance of Query [T] - call Iterable [T] .toList on this Query [T] object, and then return the created list. Then the entire query is executed in the model, and everything is in order. But I do not like this approach, because all the data requested from the database must be cached in this list. I would prefer that this data be directly passed to the view. I like the MySql function for streaming the result set when it's big.
- ? , - Query [T].executeNow(), , , MySQL ( ) , ? , .