Search in sources :

Example 6 with SelectOptions

use of org.seasar.doma.jdbc.SelectOptions in project doma by domaframework.

the class StandardDialectTest method testTransformSelectSqlNode_forUpdateWait.

@Test
public void testTransformSelectSqlNode_forUpdateWait() {
    StandardDialect dialect = new StandardDialect();
    SqlParser parser = new SqlParser("select * from emp order by emp.id");
    SqlNode sqlNode = parser.parse();
    SelectOptions options = SelectOptions.get().forUpdateWait(1);
    try {
        dialect.transformSelectSqlNode(sqlNode, options);
        fail();
    } catch (JdbcException ex) {
        System.out.println(ex.getMessage());
        assertEquals("DOMA2079", ex.getMessageResource().getCode());
    }
}
Also used : SelectOptions(org.seasar.doma.jdbc.SelectOptions) SqlParser(org.seasar.doma.internal.jdbc.sql.SqlParser) JdbcException(org.seasar.doma.jdbc.JdbcException) SqlNode(org.seasar.doma.jdbc.SqlNode) Test(org.junit.jupiter.api.Test)

Example 7 with SelectOptions

use of org.seasar.doma.jdbc.SelectOptions in project doma by domaframework.

the class StandardDialectTest method testTransformSelectSqlNode_forUpdateNowait.

@Test
public void testTransformSelectSqlNode_forUpdateNowait() {
    StandardDialect dialect = new StandardDialect();
    SqlParser parser = new SqlParser("select * from emp order by emp.id");
    SqlNode sqlNode = parser.parse();
    SelectOptions options = SelectOptions.get().forUpdateNowait();
    try {
        dialect.transformSelectSqlNode(sqlNode, options);
        fail();
    } catch (JdbcException ex) {
        System.out.println(ex.getMessage());
        assertEquals("DOMA2080", ex.getMessageResource().getCode());
    }
}
Also used : SelectOptions(org.seasar.doma.jdbc.SelectOptions) SqlParser(org.seasar.doma.internal.jdbc.sql.SqlParser) JdbcException(org.seasar.doma.jdbc.JdbcException) SqlNode(org.seasar.doma.jdbc.SqlNode) Test(org.junit.jupiter.api.Test)

Example 8 with SelectOptions

use of org.seasar.doma.jdbc.SelectOptions in project doma by domaframework.

the class SqlFileSelectCountTest method test.

@Test
public void test(Config config) throws Exception {
    EmployeeDao dao = new EmployeeDaoImpl(config);
    SelectOptions options = SelectOptions.get().count();
    List<Employee> employees = dao.selectAll(options);
    assertEquals(14, employees.size());
    assertEquals(14, options.getCount());
}
Also used : EmployeeDao(org.seasar.doma.it.dao.EmployeeDao) Employee(org.seasar.doma.it.entity.Employee) SelectOptions(org.seasar.doma.jdbc.SelectOptions) EmployeeDaoImpl(org.seasar.doma.it.dao.EmployeeDaoImpl) Test(org.junit.jupiter.api.Test)

Example 9 with SelectOptions

use of org.seasar.doma.jdbc.SelectOptions in project doma by domaframework.

the class SqlFileSelectCountTest method testCountUnspecified.

@Test
public void testCountUnspecified(Config config) throws Exception {
    EmployeeDao dao = new EmployeeDaoImpl(config);
    SelectOptions options = SelectOptions.get();
    List<Employee> employees = dao.selectAll(options);
    assertEquals(14, employees.size());
    assertEquals(-1, options.getCount());
}
Also used : EmployeeDao(org.seasar.doma.it.dao.EmployeeDao) Employee(org.seasar.doma.it.entity.Employee) SelectOptions(org.seasar.doma.jdbc.SelectOptions) EmployeeDaoImpl(org.seasar.doma.it.dao.EmployeeDaoImpl) Test(org.junit.jupiter.api.Test)

Example 10 with SelectOptions

use of org.seasar.doma.jdbc.SelectOptions in project stackoverflow-qa by yukihane.

the class SelectTest method testCount.

public void testCount() throws Exception {
    LocalTransaction tx = AppConfig.getLocalTransaction();
    try {
        tx.begin();
        SelectOptions options = SelectOptions.get().offset(5).limit(3).count();
        List<Employee> list = dao.selectAll(options);
        assertEquals(3, list.size());
        assertEquals(14, options.getCount());
        tx.commit();
    } finally {
        tx.rollback();
    }
}
Also used : Employee(tutorial.entity.Employee) LocalTransaction(org.seasar.doma.jdbc.tx.LocalTransaction) SelectOptions(org.seasar.doma.jdbc.SelectOptions)

Aggregations

SelectOptions (org.seasar.doma.jdbc.SelectOptions)15 Test (org.junit.jupiter.api.Test)10 SqlParser (org.seasar.doma.internal.jdbc.sql.SqlParser)6 JdbcException (org.seasar.doma.jdbc.JdbcException)6 SqlNode (org.seasar.doma.jdbc.SqlNode)6 EmployeeDao (org.seasar.doma.it.dao.EmployeeDao)4 EmployeeDaoImpl (org.seasar.doma.it.dao.EmployeeDaoImpl)4 Employee (org.seasar.doma.it.entity.Employee)4 Test (org.junit.Test)3 LocalTransaction (org.seasar.doma.jdbc.tx.LocalTransaction)2 Employee (tutorial.entity.Employee)2