Search in sources :

Example 46 with RowMapper

use of org.springframework.jdbc.core.RowMapper in project topcom-cloud by 545314690.

the class RowMappers method kvPairHatRowMapper.

public static RowMapper<KVPair> kvPairHatRowMapper() {
    return new RowMapper<KVPair>() {

        @Override
        public KVPair mapRow(ResultSet resultSet, int i) throws SQLException {
            KVPair kvPair = new KVPair();
            kvPair.setName(resultSet.getString("keyName"));
            kvPair.setValue(resultSet.getString("value"));
            return kvPair;
        }
    };
}
Also used : ResultSet(java.sql.ResultSet) KVPair(com.topcom.tjs.vo.KVPair) RowMapper(org.springframework.jdbc.core.RowMapper)

Example 47 with RowMapper

use of org.springframework.jdbc.core.RowMapper in project topcom-cloud by 545314690.

the class RowMappers method tjsSpecialCompanyRowMapper.

/**
 * 企业RowMapper
 * @return
 */
public static RowMapper<TjsSpecialCompany> tjsSpecialCompanyRowMapper() {
    return new RowMapper<TjsSpecialCompany>() {

        @Override
        public TjsSpecialCompany mapRow(ResultSet resultSet, int i) throws SQLException {
            TjsSpecialCompany company = new TjsSpecialCompany();
            company.setId(resultSet.getLong("id"));
            company.setCompanyName(resultSet.getString("companyName"));
            company.setLng(resultSet.getDouble("lng"));
            company.setLat(resultSet.getDouble("lat"));
            company.setAddress(resultSet.getString("address"));
            company.setSCC(resultSet.getString("SCC"));
            company.setProvince(resultSet.getString("province"));
            company.setCity(resultSet.getString("city"));
            company.setSpecial(resultSet.getBoolean("special"));
            company.setScale(resultSet.getBoolean("scale"));
            company.setProductType(resultSet.getString("productType"));
            company.setIndustryNumber(resultSet.getInt("industryNumber"));
            company.setIndustryType(resultSet.getString("industryType"));
            company.setCompanyAttribute(resultSet.getString("companyAttribute"));
            company.setLogoType(resultSet.getString("logoType"));
            company.setPersonNumber(resultSet.getInt("personNumber"));
            company.setCompanyType(resultSet.getString("companyType"));
            company.setLicence(resultSet.getString("licence"));
            company.setNumber(resultSet.getLong("number"));
            company.setOrganName(resultSet.getString("organName"));
            company.setLicenceStartDate(resultSet.getDate("licenceStartDate"));
            company.setLicenceEndDate(resultSet.getDate("licenceEndDate"));
            company.setGLFL(resultSet.getString("GLFL"));
            company.setHazardousChemicals(resultSet.getBoolean("hazardousChemicals"));
            company.setLawPlan(resultSet.getBoolean("lawPlan"));
            company.setCancellation(resultSet.getBoolean("cancellation"));
            return company;
        }
    };
}
Also used : TjsSpecialCompany(com.topcom.tjs.domain.TjsSpecialCompany) ResultSet(java.sql.ResultSet) RowMapper(org.springframework.jdbc.core.RowMapper)

Example 48 with RowMapper

use of org.springframework.jdbc.core.RowMapper in project topcom-cloud by 545314690.

the class RowMappers method tjsZfyhByTime.

public static RowMapper<JSONObject> tjsZfyhByTime() {
    return new RowMapper<JSONObject>() {

        @Override
        public JSONObject mapRow(ResultSet resultSet, int i) throws SQLException {
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("年", resultSet.getInt("年"));
            jsonObject.put("月", resultSet.getInt("月"));
            jsonObject.put("一般隐患", resultSet.getInt("一般隐患"));
            jsonObject.put("重大隐患", resultSet.getInt("重大隐患"));
            jsonObject.put("违法行为", resultSet.getInt("违法行为"));
            jsonObject.put("执法次数", resultSet.getInt("执法次数"));
            return jsonObject;
        }
    };
}
Also used : JSONObject(net.sf.json.JSONObject) ResultSet(java.sql.ResultSet) RowMapper(org.springframework.jdbc.core.RowMapper)

Example 49 with RowMapper

use of org.springframework.jdbc.core.RowMapper in project topcom-cloud by 545314690.

the class RowMappers method tjsAccidentDeathnumberByTime.

public static RowMapper<JSONObject> tjsAccidentDeathnumberByTime() {
    return new RowMapper<JSONObject>() {

        @Override
        public JSONObject mapRow(ResultSet resultSet, int i) throws SQLException {
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("年", resultSet.getInt("年"));
            jsonObject.put("月", resultSet.getInt("月"));
            jsonObject.put("死亡人数", resultSet.getInt("死亡人数"));
            jsonObject.put("事故起数", resultSet.getInt("事故起数"));
            return jsonObject;
        }
    };
}
Also used : JSONObject(net.sf.json.JSONObject) ResultSet(java.sql.ResultSet) RowMapper(org.springframework.jdbc.core.RowMapper)

Example 50 with RowMapper

use of org.springframework.jdbc.core.RowMapper in project ma-core-public by infiniteautomation.

the class AbstractBasicDao method customizedQuery.

protected void customizedQuery(SelectJoinStep<Record> select, Condition condition, List<SortField<Object>> sort, Integer limit, Integer offset, MappedRowCallback<T> callback) {
    SelectConnectByStep<Record> afterWhere = condition == null ? select : select.where(condition);
    SelectLimitStep<Record> afterSort = sort == null ? afterWhere : afterWhere.orderBy(sort);
    Select<Record> offsetStep = afterSort;
    if (limit != null) {
        if (offset != null) {
            offsetStep = afterSort.limit(offset, limit);
        } else {
            offsetStep = afterSort.limit(limit);
        }
    }
    String sql = offsetStep.getSQL();
    List<Object> arguments = offsetStep.getBindValues();
    Object[] argumentsArray = arguments.toArray(new Object[arguments.size()]);
    LogStopWatch stopWatch = null;
    if (useMetrics) {
        stopWatch = new LogStopWatch();
    }
    // this.query(sql, argumentsArray, this.getRowMapper(), callback );
    this.query(sql, argumentsArray, new ResultSetExtractor<Void>() {

        @Override
        public Void extractData(ResultSet rs) throws SQLException, DataAccessException {
            RowMapper<T> rowMapper = getRowMapper();
            int rowNum = 0;
            while (rs.next()) {
                try {
                    callback.row(rowMapper.mapRow(rs, rowNum), rowNum);
                } catch (Exception e) {
                    if (e.getCause() instanceof ModuleNotLoadedException)
                        LOG.error(e.getCause().getMessage(), e.getCause());
                    else
                        LOG.error(e.getMessage(), e);
                } finally {
                    rowNum++;
                }
            }
            return null;
        }
    });
    if (stopWatch != null) {
        stopWatch.stop("customizedQuery(): " + this.create.renderInlined(offsetStep), metricsThreshold);
    }
}
Also used : SQLException(java.sql.SQLException) DataAccessException(org.springframework.dao.DataAccessException) ModuleNotLoadedException(com.serotonin.ModuleNotLoadedException) SQLException(java.sql.SQLException) ShouldNeverHappenException(com.serotonin.ShouldNeverHappenException) ModuleNotLoadedException(com.serotonin.ModuleNotLoadedException) ResultSet(java.sql.ResultSet) Record(org.jooq.Record) LogStopWatch(com.serotonin.log.LogStopWatch) DataAccessException(org.springframework.dao.DataAccessException) RowMapper(org.springframework.jdbc.core.RowMapper)

Aggregations

RowMapper (org.springframework.jdbc.core.RowMapper)51 ResultSet (java.sql.ResultSet)27 SQLException (java.sql.SQLException)16 List (java.util.List)14 Named (javax.inject.Named)8 Singleton (javax.inject.Singleton)8 Test (org.junit.jupiter.api.Test)8 MapSqlParameterSource (org.springframework.jdbc.core.namedparam.MapSqlParameterSource)8 Guid (org.ovirt.engine.core.compat.Guid)7 QueryMappingConfiguration (org.springframework.data.jdbc.repository.QueryMappingConfiguration)7 HashMap (java.util.HashMap)5 Map (java.util.Map)5 Tags (org.ovirt.engine.core.common.businessentities.Tags)5 TagsTemplateMap (org.ovirt.engine.core.common.businessentities.TagsTemplateMap)5 TagsType (org.ovirt.engine.core.common.businessentities.TagsType)5 TagsUserGroupMap (org.ovirt.engine.core.common.businessentities.TagsUserGroupMap)5 TagsUserMap (org.ovirt.engine.core.common.businessentities.TagsUserMap)5 TagsVdsMap (org.ovirt.engine.core.common.businessentities.TagsVdsMap)5 TagsVmMap (org.ovirt.engine.core.common.businessentities.TagsVmMap)5 DataAccessException (org.springframework.dao.DataAccessException)5