Search in sources :

Example 6 with JdbcException

use of org.seasar.doma.jdbc.JdbcException 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 7 with JdbcException

use of org.seasar.doma.jdbc.JdbcException 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)

Example 8 with JdbcException

use of org.seasar.doma.jdbc.JdbcException 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 9 with JdbcException

use of org.seasar.doma.jdbc.JdbcException 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 10 with JdbcException

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

the class AutoBatchUpdateTest method testNoId.

@Test
public void testNoId(Config config) throws Exception {
    NoIdDao dao = new NoIdDaoImpl(config);
    NoId entity = new NoId();
    entity.setValue1(1);
    entity.setValue2(2);
    NoId entity2 = new NoId();
    entity2.setValue1(1);
    entity2.setValue2(2);
    try {
        dao.update(Arrays.asList(entity, entity2));
        fail();
    } catch (JdbcException expected) {
        assertEquals(Message.DOMA2022, expected.getMessageResource());
    }
}
Also used : NoIdDao(org.seasar.doma.it.dao.NoIdDao) NoId(org.seasar.doma.it.entity.NoId) NoIdDaoImpl(org.seasar.doma.it.dao.NoIdDaoImpl) JdbcException(org.seasar.doma.jdbc.JdbcException) Test(org.junit.jupiter.api.Test)

Aggregations

JdbcException (org.seasar.doma.jdbc.JdbcException)69 Test (org.junit.jupiter.api.Test)35 SqlNode (org.seasar.doma.jdbc.SqlNode)18 SQLException (java.sql.SQLException)15 BigDecimal (java.math.BigDecimal)9 Value (org.seasar.doma.internal.expr.Value)9 ExpressionEvaluator (org.seasar.doma.internal.expr.ExpressionEvaluator)8 SqlLocation (org.seasar.doma.internal.jdbc.sql.node.SqlLocation)7 SelectOptions (org.seasar.doma.jdbc.SelectOptions)7 SqlParser (org.seasar.doma.internal.jdbc.sql.SqlParser)6 Connection (java.sql.Connection)5 MockConfig (org.seasar.doma.internal.jdbc.mock.MockConfig)5 PreparedStatement (java.sql.PreparedStatement)4 Savepoint (java.sql.Savepoint)4 ArrayList (java.util.ArrayList)4 LinkedHashMap (java.util.LinkedHashMap)4 DomaNullPointerException (org.seasar.doma.DomaNullPointerException)4 MockConnection (org.seasar.doma.internal.jdbc.mock.MockConnection)4 MockDataSource (org.seasar.doma.internal.jdbc.mock.MockDataSource)4 IfBlockNode (org.seasar.doma.internal.jdbc.sql.node.IfBlockNode)4