Search in sources :

Example 26 with QueryRunner

use of com.haulmont.bali.db.QueryRunner in project cuba by cuba-platform.

the class DbUpdaterEngine method markScript.

protected void markScript(String name, boolean init) {
    log.trace("Marking script as executed: {}", name);
    QueryRunner runner = new QueryRunner(getDataSource());
    try {
        runner.update("insert into SYS_DB_CHANGELOG (SCRIPT_NAME, IS_INIT) values (?, ?)", new Object[] { name, init ? 1 : 0 });
    } catch (SQLException e) {
        throw new RuntimeException(ERROR + "Error updating SYS_DB_CHANGELOG", e);
    }
}
Also used : QueryRunner(com.haulmont.bali.db.QueryRunner)

Example 27 with QueryRunner

use of com.haulmont.bali.db.QueryRunner in project cuba by cuba-platform.

the class IdentityTest method setUp.

@Before
public void setUp() throws Exception {
    QueryRunner runner = new QueryRunner(cont.persistence().getDataSource());
    runner.update("delete from TEST_IDENTITY");
    metadata = cont.metadata();
    persistence = cont.persistence();
}
Also used : QueryRunner(com.haulmont.bali.db.QueryRunner) Before(org.junit.Before)

Example 28 with QueryRunner

use of com.haulmont.bali.db.QueryRunner in project cuba by cuba-platform.

the class IdentityUuidTest method setUp.

@Before
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();
}
Also used : QueryRunner(com.haulmont.bali.db.QueryRunner) Before(org.junit.Before)

Example 29 with QueryRunner

use of com.haulmont.bali.db.QueryRunner in project cuba by cuba-platform.

the class EntityLogTest method cleanup.

private void cleanup() throws SQLException {
    QueryRunner runner = new QueryRunner(cont.persistence().getDataSource());
    runner.update("delete from SEC_LOGGED_ATTR");
    runner.update("delete from SEC_LOGGED_ENTITY");
}
Also used : QueryRunner(com.haulmont.bali.db.QueryRunner)

Example 30 with QueryRunner

use of com.haulmont.bali.db.QueryRunner in project cuba by cuba-platform.

the class DataManagerDistinctResultsTest method tearDown.

@After
public void tearDown() throws Exception {
    Transaction tx = cont.persistence().createTransaction();
    try {
        QueryRunner runner = new QueryRunner(cont.persistence().getDataSource());
        try {
            String sql = "delete from SEC_USER_ROLE where ROLE_ID = '" + role1Id.toString() + "'";
            runner.update(sql);
            sql = "delete from SEC_USER_ROLE where ROLE_ID = '" + role2Id.toString() + "'";
            runner.update(sql);
            sql = "delete from SEC_ROLE where ID = '" + role1Id.toString() + "'";
            runner.update(sql);
            sql = "delete from SEC_ROLE where ID = '" + role2Id.toString() + "'";
            runner.update(sql);
            sql = "delete from SEC_USER where GROUP_ID = '" + groupId.toString() + "'";
            runner.update(sql);
            sql = "delete from SEC_GROUP where ID = '" + groupId.toString() + "'";
            runner.update(sql);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        tx.commit();
    } finally {
        tx.end();
    }
}
Also used : SQLException(java.sql.SQLException) QueryRunner(com.haulmont.bali.db.QueryRunner) After(org.junit.After)

Aggregations

QueryRunner (com.haulmont.bali.db.QueryRunner)38 SQLException (java.sql.SQLException)14 Before (org.junit.Before)10 DbTypeConverter (com.haulmont.cuba.core.sys.persistence.DbTypeConverter)6 User (com.haulmont.cuba.security.entity.User)4 EntityManager (com.haulmont.cuba.core.EntityManager)3 Transaction (com.haulmont.cuba.core.Transaction)3 After (org.junit.After)3 MetaClass (com.haulmont.chile.core.model.MetaClass)2 Entity (com.haulmont.cuba.core.entity.Entity)2 UserSession (com.haulmont.cuba.security.global.UserSession)2 IOException (java.io.IOException)2 ResultSet (java.sql.ResultSet)2 ArrayHandler (com.haulmont.bali.db.ArrayHandler)1 ResultSetHandler (com.haulmont.bali.db.ResultSetHandler)1 EntitySnapshot (com.haulmont.cuba.core.entity.EntitySnapshot)1 Server (com.haulmont.cuba.core.entity.Server)1 View (com.haulmont.cuba.core.global.View)1 EntityListenerManager (com.haulmont.cuba.core.sys.listener.EntityListenerManager)1 Group (com.haulmont.cuba.security.entity.Group)1