Currently setting fetchSize hint for Statement requires custom implementation using SQLDetailedListener. As Statement.setFetchSize(int) is part of standard JDBC API, it would make sense to implement this in core API.
I suggest that we support setting the following Statement properties on configuration and query level:
@ssaarela @Shredder121 @johnktims What do you think about the enum style, it would pollute the SQLQuery namespace less than Bean setters.
I think that should scale well.
Then we can give an enum constant a default value as field.
On the other hand setters would be more intuitive than enum style - distinct methods work well with auto-complete whereas finding that kind of enum setters would require googling/documentation.
I would leave defaults as unset, null or empty Optional, for all of these. At least fetchSize might slow down other queries and there are other ways of defining timeouts. Instead of setting maxRows, most developers would/should use SQL based limit, etc. If, however, someone wants to use Querydsl for setting these at global level, then using a listener is not that hard.
Enum vs setters:
How about a StatementOptions immutable object. Default is created with default constructor, builder might be overkill. That way code can apply the same combination of options easily to many statements.
And I agree with ssaarela that defaults should be null or empty Optional. There are no values for the any of the settings that are good for all jdbc drivers.
An immutable StatementOptions class sounds good, it provides typesafety and adds only a single method in the query signature.