Search in sources :

Example 61 with StatementParameters

use of com.ctrip.platform.dal.dao.StatementParameters in project dal by ctripcorp.

the class DalQueryDaoTest method testQueryForObjectAllShardsWithClass.

@Test
public void testQueryForObjectAllShardsWithClass() {
    try {
        DalHints hints = new DalHints();
        StatementParameters parameters = new StatementParameters();
        parameters.set(1, 1);
        Integer result = dao.queryForObject(sqlObject, parameters, hints.inAllShards(), Integer.class);
        assertEquals(1, result.intValue());
    } catch (Exception e) {
        e.printStackTrace();
        fail();
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) DalHints(com.ctrip.platform.dal.dao.DalHints) StatementParameters(com.ctrip.platform.dal.dao.StatementParameters) SQLException(java.sql.SQLException) Test(org.junit.Test)

Example 62 with StatementParameters

use of com.ctrip.platform.dal.dao.StatementParameters in project dal by ctripcorp.

the class DalQueryDaoTest method testQueryFirstAllShardsWithClass.

@Test
public void testQueryFirstAllShardsWithClass() {
    try {
        DalHints hints = new DalHints();
        StatementParameters parameters = new StatementParameters();
        parameters.set(1, 1);
        Integer result = dao.queryFirst(sqlFirst, parameters, hints.inAllShards(), Integer.class);
        assertEquals(1, result.intValue());
    } catch (Exception e) {
        fail();
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) DalHints(com.ctrip.platform.dal.dao.DalHints) StatementParameters(com.ctrip.platform.dal.dao.StatementParameters) SQLException(java.sql.SQLException) Test(org.junit.Test)

Example 63 with StatementParameters

use of com.ctrip.platform.dal.dao.StatementParameters in project dal by ctripcorp.

the class DalQueryDaoTest method queryFirstInAllShardPartial.

private ClientTestModel queryFirstInAllShardPartial(DalHints hints) throws SQLException {
    StatementParameters parameters = new StatementParameters();
    parameters.set(1, 1);
    return dao.queryFirst(sqlFirst, parameters, hints.inAllShards().partialQuery("quantity", "address"), new DalDefaultJpaMapper<>(ClientTestModel.class));
}
Also used : StatementParameters(com.ctrip.platform.dal.dao.StatementParameters)

Example 64 with StatementParameters

use of com.ctrip.platform.dal.dao.StatementParameters in project dal by ctripcorp.

the class DalQueryDaoTest method testQueryFirstAllShardsNullable.

@Test
public void testQueryFirstAllShardsNullable() {
    try {
        DalHints hints = new DalHints();
        StatementParameters parameters = new StatementParameters();
        ClientTestModel result = dao.queryFirstNullable(sqlNoResult, parameters(), hints.inAllShards(), new ClientTestDalRowMapper());
        assertNull(result);
    } catch (Exception e) {
        e.printStackTrace();
        fail();
    }
}
Also used : DalHints(com.ctrip.platform.dal.dao.DalHints) StatementParameters(com.ctrip.platform.dal.dao.StatementParameters) SQLException(java.sql.SQLException) Test(org.junit.Test)

Example 65 with StatementParameters

use of com.ctrip.platform.dal.dao.StatementParameters in project dal by ctripcorp.

the class DalQueryDaoTest method testQueryForObjectAllShardsWithClassAsync.

@Test
public void testQueryForObjectAllShardsWithClassAsync() {
    try {
        DalHints hints = new DalHints();
        StatementParameters parameters = new StatementParameters();
        parameters.set(1, 1);
        Integer result = dao.queryForObject(sqlObject, parameters, hints.inAllShards().asyncExecution(), Integer.class);
        assertNull(result);
        Future<Integer> fr = (Future<Integer>) hints.getAsyncResult();
        result = fr.get();
        assertEquals(1, result.intValue());
    } catch (Exception e) {
        e.printStackTrace();
        fail();
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) DalHints(com.ctrip.platform.dal.dao.DalHints) StatementParameters(com.ctrip.platform.dal.dao.StatementParameters) Future(java.util.concurrent.Future) SQLException(java.sql.SQLException) Test(org.junit.Test)

Aggregations

StatementParameters (com.ctrip.platform.dal.dao.StatementParameters)360 DalHints (com.ctrip.platform.dal.dao.DalHints)317 Test (org.junit.Test)209 SQLException (java.sql.SQLException)102 ArrayList (java.util.ArrayList)51 FreeSelectSqlBuilder (com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder)40 ClientTestModel (test.com.ctrip.platform.dal.dao.unitbase.ClientTestModel)40 List (java.util.List)29 FreeUpdateSqlBuilder (com.ctrip.platform.dal.dao.sqlbuilder.FreeUpdateSqlBuilder)20 DalQueryDao (com.ctrip.platform.dal.dao.DalQueryDao)19 DalTableDao (com.ctrip.platform.dal.dao.DalTableDao)17 After (org.junit.After)17 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)15 DalDefaultJpaParser (com.ctrip.platform.dal.dao.helper.DalDefaultJpaParser)14 ResultSet (java.sql.ResultSet)10 DalClient (com.ctrip.platform.dal.dao.DalClient)9 AfterClass (org.junit.AfterClass)9 BeforeClass (org.junit.BeforeClass)9 AbstractFreeSqlBuilder (com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder)8 Map (java.util.Map)8