fengxiang
2018-01-25 56e81073389ebb511562ddf85e1b22a8db0585a9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package com.moral.mapper.type;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
 
import com.moral.common.json.BooleanValueFilter;
import com.moral.entity.alarm.AlarmConfigValue;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.MappedTypes;
 
import com.alibaba.fastjson.JSON;
 
/**
 * @author fengxiang
 * @Time:2017年11月29日 上午9:38:51
 * @version 1.0
 */
@MappedJdbcTypes({JdbcType.OTHER})
@MappedTypes({AlarmConfigValue.class})
public class AlarmConfigValueHandle extends BaseTypeHandler<AlarmConfigValue> {
    @Override
    public AlarmConfigValue getNullableResult(ResultSet resultSet, String s) throws SQLException {
        return JSON.parseObject(resultSet.getString(s),AlarmConfigValue.class);
    }
 
    @Override
    public AlarmConfigValue getNullableResult(ResultSet resultSet, int i) throws SQLException {
        return JSON.parseObject(resultSet.getString(i),AlarmConfigValue.class);
    }
 
    @Override
    public AlarmConfigValue getNullableResult(CallableStatement cStatement, int i) throws SQLException {
        return JSON.parseObject(cStatement.getString(i),AlarmConfigValue.class);
    }
 
    @Override
    public void setNonNullParameter(PreparedStatement preparedStatement, int i, AlarmConfigValue alarmConfigValue, JdbcType jdbcType)
            throws SQLException {
        preparedStatement.setString(i,JSON.toJSONString(alarmConfigValue,new BooleanValueFilter()));
    }
 
}