use of com.haulmont.bali.db.QueryRunner in project cuba by cuba-platform.
the class TestAfterCompleteTxListener method testRollback.
private void testRollback(boolean committed, Collection<Entity> detachedEntities) {
assertFalse(committed);
User user = null;
for (Entity entity : detachedEntities) {
if (entity instanceof User && ((User) entity).getLogin().startsWith("TxLstnrTst-1-"))
user = (User) entity;
}
if (user != null) {
assertEquals("updated by testRollback", user.getName());
try {
QueryRunner runner = new QueryRunner(persistence.getDataSource());
runner.update("update SEC_USER set NAME = 'updated by TestAfterCompleteTxListener' where ID = ?", user.getId().toString());
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
}
use of com.haulmont.bali.db.QueryRunner in project cuba by cuba-platform.
the class TestEntityChangedEventListener method isCommitted.
private boolean isCommitted(Id<Order, UUID> entityId) {
ExecutorService executor = Executors.newSingleThreadExecutor();
Future<Boolean> future = executor.submit(() -> {
QueryRunner runner = new QueryRunner(persistence.getDataSource());
try {
Object[] row = runner.query("select id from SALES1_ORDER where id = ?", entityId.getValue().toString(), new ArrayHandler());
return row != null;
} catch (SQLException e) {
throw new RuntimeException(e);
}
});
try {
return future.get(200L, TimeUnit.MILLISECONDS);
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
} catch (TimeoutException e) {
return false;
}
}
use of com.haulmont.bali.db.QueryRunner in project cuba by cuba-platform.
the class TestContainer method deleteRecord.
public void deleteRecord(String table, String primaryKeyCol, Object... ids) {
for (Object id : ids) {
String sql = "delete from " + table + " where " + primaryKeyCol + " = '" + id.toString() + "'";
QueryRunner runner = new QueryRunner(persistence().getDataSource());
try {
runner.update(sql);
} catch (SQLException e) {
throw new RuntimeException(String.format("Unable to delete record %s from %s", id.toString(), table), e);
}
}
}
use of com.haulmont.bali.db.QueryRunner in project cuba by cuba-platform.
the class IdentityUuidTest method setUp.
@BeforeEach
public void setUp() throws Exception {
QueryRunner runner = new QueryRunner(cont.persistence().getDataSource());
runner.update("delete from TEST_IDENTITY_UUID");
metadata = cont.metadata();
persistence = cont.persistence();
}
use of com.haulmont.bali.db.QueryRunner in project cuba by cuba-platform.
the class IdentityTest method setUp.
@BeforeEach
public void setUp() throws Exception {
QueryRunner runner = new QueryRunner(cont.persistence().getDataSource());
runner.update("delete from TEST_IDENTITY");
metadata = cont.metadata();
persistence = cont.persistence();
}
Aggregations