Method creating SQLQuery using querydsl-sql :
protected final <T> T select(RelationalPathBase path, Function<SQLQuery, T> code) throws SQLException {
try (final Connection con = dataSource.getConnection()) {
return code.apply(new SQLQuery(con, SQLServer2008Templates.builder().printSchema().build()).from(getTable(path)));
}
}
Method using query:
public List<Tuple> selectDataForProcess() throws SQLException {
return select(map, sqlQuery -> sqlQuery
.limit(sendSelectBatch)
.where(map.selectedOn.isNull())
.list(map.all()));
}
How can i set timeout for query ?
From the comments, I believe datasource is spring managed. Either set the default timeout on the datasource level:
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
<!-- Sets default timeout to 5 seconds -->
<property name="defaultTimeout" value="5" />
</bean>
Or wrap an individual query in a transaction and set the timeout:
@Transactional(timeout=5)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With