Search in sources :

Example 36 with DalException

use of com.ctrip.platform.dal.exceptions.DalException in project dal by ctripcorp.

the class DalSingleResultExtractor method extract.

@Override
public T extract(ResultSet rs) throws SQLException {
    T result = null;
    checkHints(rs);
    if (rs.next()) {
        result = mapper.map(rs, 0);
        if (rs.next() && requireSingle)
            throw new DalException(ErrorCode.AssertSingle);
    }
    return result;
}
Also used : DalException(com.ctrip.platform.dal.exceptions.DalException)

Example 37 with DalException

use of com.ctrip.platform.dal.exceptions.DalException in project dal by ctripcorp.

the class BatchUpdateTask method createTaskContext.

@Override
public BulkTaskContext<T> createTaskContext(DalHints hints, List<Map<String, ?>> daoPojos, List<T> rawPojos) throws DalException {
    BulkTaskContext<T> taskContext = new BulkTaskContext<T>(rawPojos);
    Map<String, Boolean> pojoFieldStatus = taskContext.isUpdatableEntity() ? filterUpdatableEntity(hints, rawPojos) : filterNullColumns(hints, daoPojos);
    if (pojoFieldStatus.size() == 0)
        throw new DalException(ErrorCode.ValidateFieldCount);
    taskContext.setPojoFieldStatus(pojoFieldStatus);
    if (taskContext instanceof DalContextConfigure)
        taskContext.setShardingCategory(shardingCategory);
    return taskContext;
}
Also used : DalException(com.ctrip.platform.dal.exceptions.DalException)

Aggregations

DalException (com.ctrip.platform.dal.exceptions.DalException)37 ArrayList (java.util.ArrayList)8 SQLException (java.sql.SQLException)5 Test (org.junit.Test)5 DalHints (com.ctrip.platform.dal.dao.DalHints)4 SelectSqlBuilder (com.ctrip.platform.dal.dao.sqlbuilder.SelectSqlBuilder)4 UpdatableEntity (com.ctrip.platform.dal.dao.UpdatableEntity)3 DalTableDao (com.ctrip.platform.dal.dao.DalTableDao)2 StatementParameters (com.ctrip.platform.dal.dao.StatementParameters)2 LogContext (com.ctrip.platform.dal.dao.client.LogContext)2 DatabaseSet (com.ctrip.platform.dal.dao.configure.DatabaseSet)2 DalShardingStrategy (com.ctrip.platform.dal.dao.strategy.DalShardingStrategy)2 Field (java.lang.reflect.Field)2 Connection (java.sql.Connection)2 Map (java.util.Map)2 PooledConnection (org.apache.tomcat.jdbc.pool.PooledConnection)2 DatabaseCategory (com.ctrip.platform.dal.common.enums.DatabaseCategory)1 DalContextClient (com.ctrip.platform.dal.dao.DalContextClient)1 StatementParameter (com.ctrip.platform.dal.dao.StatementParameter)1 Type (com.ctrip.platform.dal.dao.annotation.Type)1