mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1933 - ENH: Add DtoQuery.usingTransaction(Transaction) ... dto query with supplied transaction
This commit is contained in:
@@ -14,6 +14,7 @@ import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class TestQueryUsingConnection extends BaseTestCase {
|
||||
|
||||
@@ -51,6 +52,15 @@ public class TestQueryUsingConnection extends BaseTestCase {
|
||||
|
||||
DB.getDefault().insert(x, transaction);
|
||||
|
||||
final CountryDto dto = DB.findDto(CountryDto.class, "select code, name from o_country where code=?")
|
||||
.usingTransaction(transaction)
|
||||
.setParameter(1, "xx")
|
||||
.findOne();
|
||||
|
||||
assertThat(dto).isNotNull();
|
||||
assertEquals("xx", dto.code);
|
||||
assertEquals("WillRollThisBack", dto.name);
|
||||
|
||||
final int count = DB.find(Country.class)
|
||||
.usingTransaction(transaction)
|
||||
.findCount();
|
||||
@@ -63,4 +73,14 @@ public class TestQueryUsingConnection extends BaseTestCase {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class CountryDto {
|
||||
final String code;
|
||||
final String name;
|
||||
|
||||
public CountryDto(String code, String name) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user