Search in sources :

Example 11 with QueryRunner

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

the class AfterCompleteTransactionListenerTest method tearDown.

@After
public void tearDown() throws Exception {
    QueryRunner runner = new QueryRunner(persistence.getDataSource());
    runner.update("delete from SEC_USER where LOGIN_LC like 'txlstnrtst-%'");
}
Also used : QueryRunner(com.haulmont.bali.db.QueryRunner) After(org.junit.After)

Example 12 with QueryRunner

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

the class BeforeCommitTransactionListenerTest method tearDown.

@After
public void tearDown() throws Exception {
    QueryRunner runner = new QueryRunner(persistence.getDataSource());
    runner.update("delete from SEC_USER where LOGIN_LC like 'txlstnrtst-%'");
}
Also used : QueryRunner(com.haulmont.bali.db.QueryRunner) After(org.junit.After)

Example 13 with QueryRunner

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

the class TestAfterCompleteTxListener method testCommit.

private void testCommit(boolean committed, Collection<Entity> detachedEntities) {
    assertTrue(committed);
    User user = null;
    for (Entity entity : detachedEntities) {
        assertTrue(PersistenceHelper.isDetached(entity));
        if (entity instanceof User && ((User) entity).getLogin().startsWith("TxLstnrTst-1-"))
            user = (User) entity;
    }
    if (user != null) {
        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);
        }
    }
}
Also used : Entity(com.haulmont.cuba.core.entity.Entity) User(com.haulmont.cuba.security.entity.User) SQLException(java.sql.SQLException) QueryRunner(com.haulmont.bali.db.QueryRunner)

Example 14 with QueryRunner

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

the class PersistenceHelperTest method tearDown.

@After
public void tearDown() throws Exception {
    QueryRunner runner = new QueryRunner(cont.persistence().getDataSource());
    runner.update("delete from SYS_SERVER");
}
Also used : QueryRunner(com.haulmont.bali.db.QueryRunner)

Example 15 with QueryRunner

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

the class PersistenceTest method setUp.

@Before
public void setUp() throws Exception {
    QueryRunner runner = new QueryRunner(cont.persistence().getDataSource());
    runner.update("delete from SYS_SERVER");
    Transaction tx = cont.persistence().createTransaction();
    try {
        EntityManager em = cont.persistence().getEntityManager();
        User user = new User();
        userId = user.getId();
        user.setName("testUser");
        user.setLogin("testLogin");
        user.setGroup(em.find(Group.class, UUID.fromString("0fa2b1a5-1d68-4d69-9fbd-dff348347f93")));
        em.persist(user);
        tx.commit();
    } finally {
        tx.end();
    }
}
Also used : Group(com.haulmont.cuba.security.entity.Group) User(com.haulmont.cuba.security.entity.User) QueryRunner(com.haulmont.bali.db.QueryRunner) Before(org.junit.Before)

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