mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Merge branch 'FOCONIS-bug/transactional-affects-query-cache'
This commit is contained in:
@@ -396,7 +396,7 @@ final class CQueryBuilder {
|
||||
sql = nativeQueryPaging(query, sql);
|
||||
}
|
||||
query.setGeneratedSql(sql);
|
||||
Connection connection = request.transaction().connection();
|
||||
Connection connection = request.transaction().getInternalConnection();
|
||||
BeanDescriptor<?> desc = request.descriptor();
|
||||
try {
|
||||
// For SqlServer we need either "selectMethod=cursor" in the connection string or fetch explicitly a cursorable
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ abstract class TransactionFactory {
|
||||
*/
|
||||
final SpiTransaction setIsolationLevel(SpiTransaction t, boolean explicit, int isolationLevel) {
|
||||
if (isolationLevel > -1) {
|
||||
Connection connection = t.connection();
|
||||
Connection connection = t.getInternalConnection();
|
||||
try {
|
||||
connection.setTransactionIsolation(isolationLevel);
|
||||
} catch (SQLException e) {
|
||||
|
||||
@@ -3,6 +3,8 @@ package org.tests.cache;
|
||||
import io.ebean.CacheMode;
|
||||
import io.ebean.DB;
|
||||
import io.ebean.ExpressionList;
|
||||
import io.ebean.annotation.Transactional;
|
||||
import io.ebean.annotation.TxIsolation;
|
||||
import io.ebean.bean.BeanCollection;
|
||||
import io.ebean.cache.ServerCache;
|
||||
import io.ebean.test.LoggedSql;
|
||||
@@ -159,6 +161,30 @@ public class TestQueryCache extends BaseTestCase {
|
||||
assertThat(count2).isEqualTo(count1);
|
||||
sql = LoggedSql.stop();
|
||||
assertThat(sql).hasSize(1);
|
||||
|
||||
|
||||
LoggedSql.start();
|
||||
findCountNoTxn();
|
||||
sql = LoggedSql.stop();
|
||||
assertThat(sql).hasSize(0);
|
||||
|
||||
LoggedSql.start();
|
||||
findCountTxn();
|
||||
sql = LoggedSql.stop();
|
||||
assertThat(sql).hasSize(0);
|
||||
}
|
||||
|
||||
private void findCountNoTxn() {
|
||||
DB.find(EColAB.class)
|
||||
.setUseQueryCache(CacheMode.ON)
|
||||
.where()
|
||||
.eq("columnB", "count")
|
||||
.findCount();
|
||||
}
|
||||
|
||||
@Transactional(isolation = TxIsolation.READ_UNCOMMITTED)
|
||||
private void findCountTxn() {
|
||||
findCountNoTxn();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user