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 { @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())); } }