Search in sources :

Example 26 with Handle

use of org.jdbi.v3.core.Handle in project jdbi by jdbi.

the class TestModifiers method setUp.

@Before
public void setUp() throws Exception {
    handle = dbRule.getSharedHandle();
    handle.registerRowMapper(new SomethingMapper());
}
Also used : SomethingMapper(org.jdbi.v3.core.mapper.SomethingMapper) Before(org.junit.Before)

Example 27 with Handle

use of org.jdbi.v3.core.Handle in project jdbi by jdbi.

the class TestReadOnly method testReadOnlyInner.

@Test
public void testReadOnlyInner() {
    try (Handle h = db.openHandle()) {
        RODao dao = h.attach(RODao.class);
        dao.writeTxn(() -> dao.readTxn(() -> {
        }));
    }
}
Also used : Handle(org.jdbi.v3.core.Handle) Test(org.junit.Test)

Example 28 with Handle

use of org.jdbi.v3.core.Handle in project jdbi by jdbi.

the class TestReadOnly method testReadOnlyOuter.

@Test(expected = TransactionException.class)
public void testReadOnlyOuter() {
    try (Handle h = db.openHandle()) {
        RODao dao = h.attach(RODao.class);
        dao.readTxn(() -> dao.writeTxn(() -> {
        }));
    }
}
Also used : Handle(org.jdbi.v3.core.Handle) Test(org.junit.Test)

Example 29 with Handle

use of org.jdbi.v3.core.Handle in project jdbi by jdbi.

the class TestReadOnly method testHandleReadOnly.

@Test
public void testHandleReadOnly() throws Exception {
    try (Handle h = db.openHandle()) {
        assertThat(h.isReadOnly()).isFalse();
        assertThat(h.getConnection().isReadOnly()).isFalse();
        h.setReadOnly(true);
        assertThat(h.isReadOnly()).isTrue();
        assertThat(h.getConnection().isReadOnly()).isTrue();
    }
}
Also used : Handle(org.jdbi.v3.core.Handle) Test(org.junit.Test)

Example 30 with Handle

use of org.jdbi.v3.core.Handle in project jdbi by jdbi.

the class TestReentrancy method testGetHandleProvidesSeperateHandle.

@Test(expected = UnableToCreateStatementException.class)
public void testGetHandleProvidesSeperateHandle() throws Exception {
    final TheBasics dao = db.onDemand(TheBasics.class);
    Handle h = dao.getHandle();
    h.execute("insert into something (id, name) values (1, 'Stephen')");
}
Also used : Handle(org.jdbi.v3.core.Handle) Test(org.junit.Test)

Aggregations

Handle (org.jdbi.v3.core.Handle)134 Test (org.junit.Test)124 Jdbi (org.jdbi.v3.core.Jdbi)36 Something (org.jdbi.v3.core.Something)29 Before (org.junit.Before)21 SomethingMapper (org.jdbi.v3.core.mapper.SomethingMapper)17 Namespace (net.sourceforge.argparse4j.inf.Namespace)11 Test (org.junit.jupiter.api.Test)11 SQLException (java.sql.SQLException)10 Query (org.jdbi.v3.core.statement.Query)8 Map (java.util.Map)7 Update (org.jdbi.v3.core.statement.Update)7 GenericType (org.jdbi.v3.core.generic.GenericType)6 Rule (org.junit.Rule)5 List (java.util.List)4 BrokenDao (org.jdbi.v3.sqlobject.subpackage.BrokenDao)4 SomethingDao (org.jdbi.v3.sqlobject.subpackage.SomethingDao)4 ArrayList (java.util.ArrayList)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3 JdbiPlugin (org.jdbi.v3.core.spi.JdbiPlugin)3