概述
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<!-- mybatis 配置中心 -->
<configuration>
<typeAliases>
<typeAlias type="cn.linkea.common.lang.Money" alias="money" />
<typeAlias
type="com.uytong.thirdbus.entity.enmus.NetMobilePayOrderStatesEnum"
alias="NetMObileOrderStates" />
<typeHandlers>
<typeHandler
handler="com.uytong.thirdbus.repository.typehandler.NetMobileOrderStatesEnumHandler"
javaType="NetMObileOrderStates" />
</typeHandlers>
</configuration>
package com.uytong.thirdbus.repository.typehandler;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.TypeHandler;
import com.uytong.thirdbus.entity.enmus.NetMobilePayOrderStatesEnum;
public class NetMobileOrderStatesEnumHandler implements
TypeHandler<NetMobilePayOrderStatesEnum> {
@Override
public void setParameter(PreparedStatement ps, int i,
NetMobilePayOrderStatesEnum parameter, JdbcType jdbcType)
throws SQLException {
ps.setString(i, parameter.getValue());
}
@Override
public NetMobilePayOrderStatesEnum getResult(ResultSet rs, String columnName)
throws SQLException {
String status = rs.getString(columnName);
return NetMobilePayOrderStatesEnum.getByValue(status);
}
@Override
public NetMobilePayOrderStatesEnum getResult(CallableStatement cs,
int columnIndex) throws SQLException {
String status = cs.getString(columnIndex);
return NetMobilePayOrderStatesEnum.getByValue(status);
}
}
最后
以上就是精明蜜粉为你收集整理的mybatis mapper.xml 中查询出的status 赋值给枚举类型要装换的全部内容,希望文章能够帮你解决mybatis mapper.xml 中查询出的status 赋值给枚举类型要装换所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复