Search in sources :

Example 1 with TwoLayerExceptionDalCommand

use of com.ctrip.platform.dal.dao.client.DalCommand.nesting.normal.TwoLayerExceptionDalCommand in project dal by ctripcorp.

the class DalCommandTest method testFourLayerExceptionTransaction.

// Four layer transaction throws exception
@Test
public void testFourLayerExceptionTransaction() throws Exception {
    DalClient client = DalClientFactory.getClient(dbName);
    try {
        client.execute(new TwoLayerExceptionDalCommand(), new DalHints());
        Assert.fail();
    } catch (Throwable e) {
        System.out.println(e.getMessage());
        Assert.assertTrue(e instanceof BatchUpdateException);
        Assert.assertTrue(e.getMessage().equals("Data truncation: Data too long for column 'Name' at row 1"));
        Assert.assertTrue(isCurrentTransactionNull());
    }
}
Also used : DalClient(com.ctrip.platform.dal.dao.DalClient) DalHints(com.ctrip.platform.dal.dao.DalHints) TwoLayerExceptionDalCommand(com.ctrip.platform.dal.dao.client.DalCommand.nesting.normal.TwoLayerExceptionDalCommand) BatchUpdateException(java.sql.BatchUpdateException) Test(org.junit.Test)

Aggregations

DalClient (com.ctrip.platform.dal.dao.DalClient)1 DalHints (com.ctrip.platform.dal.dao.DalHints)1 TwoLayerExceptionDalCommand (com.ctrip.platform.dal.dao.client.DalCommand.nesting.normal.TwoLayerExceptionDalCommand)1 BatchUpdateException (java.sql.BatchUpdateException)1 Test (org.junit.Test)1