Search in sources :

Example 1 with SelectOptions

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

the class PageablesTest method testToSelectOptions.

@Test
public void testToSelectOptions() throws Exception {
    SelectOptions options = Pageables.toSelectOptions(pageRequest(0, 10));
    assertThat(SelectOptionsAccessor.getOffset(options), is(0L));
    assertThat(SelectOptionsAccessor.getLimit(options), is(10L));
}
Also used : SelectOptions(org.seasar.doma.jdbc.SelectOptions) Test(org.junit.Test)

Example 2 with SelectOptions

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

the class PageablesTest method testToSelectOptions2.

@Test
public void testToSelectOptions2() throws Exception {
    SelectOptions options = Pageables.toSelectOptions(pageRequest(2, 10));
    assertThat(SelectOptionsAccessor.getOffset(options), is(20L));
    assertThat(SelectOptionsAccessor.getLimit(options), is(10L));
}
Also used : SelectOptions(org.seasar.doma.jdbc.SelectOptions) Test(org.junit.Test)

Example 3 with SelectOptions

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

the class StandardDialectTest method testTransformSelectSqlNode_forUpdate_alias.

@Test
public void testTransformSelectSqlNode_forUpdate_alias() {
    StandardDialect dialect = new StandardDialectStab();
    SqlParser parser = new SqlParser("select * from emp order by emp.id");
    SqlNode sqlNode = parser.parse();
    SelectOptions options = SelectOptions.get().forUpdate("emp");
    try {
        dialect.transformSelectSqlNode(sqlNode, options);
        fail();
    } catch (JdbcException ex) {
        System.out.println(ex.getMessage());
        assertEquals("DOMA2024", 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 4 with SelectOptions

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

the class StandardDialectTest method testTransformSelectSqlNode_forUpdateNowait_alias.

@Test
public void testTransformSelectSqlNode_forUpdateNowait_alias() {
    StandardDialect dialect = new StandardDialectStab();
    SqlParser parser = new SqlParser("select * from emp order by emp.id");
    SqlNode sqlNode = parser.parse();
    SelectOptions options = SelectOptions.get().forUpdateNowait("emp");
    try {
        dialect.transformSelectSqlNode(sqlNode, options);
        fail();
    } catch (JdbcException ex) {
        System.out.println(ex.getMessage());
        assertEquals("DOMA2082", 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 5 with SelectOptions

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

the class StandardDialectTest method testTransformSelectSqlNode_forUpdate.

@Test
public void testTransformSelectSqlNode_forUpdate() {
    StandardDialect dialect = new StandardDialect();
    SqlParser parser = new SqlParser("select * from emp order by emp.id");
    SqlNode sqlNode = parser.parse();
    SelectOptions options = SelectOptions.get().forUpdate();
    try {
        dialect.transformSelectSqlNode(sqlNode, options);
        fail();
    } catch (JdbcException ex) {
        System.out.println(ex.getMessage());
        assertEquals("DOMA2023", 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)

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