use of com.haulmont.bali.db.QueryRunner in project cuba by cuba-platform.
the class ViewTest method getCurrentUpdateTs.
private long getCurrentUpdateTs() {
String sql = "select UPDATE_TS from SEC_USER where ID = '" + userId.toString() + "'";
QueryRunner runner = new QueryRunner(cont.persistence().getDataSource());
try {
return runner.query(sql, new ResultSetHandler<Long>() {
@Override
public Long handle(ResultSet rs) throws SQLException {
rs.next();
return rs.getTimestamp("UPDATE_TS").getTime();
}
});
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
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(e);
}
}
}
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);
}
}
}
Aggregations