<commit_before>package org.apache.ibatis.type;

import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class EnumTypeHandler<E extends Enum<E>> extends BaseTypeHandler<E> {

  private Class<E> type;

  public EnumTypeHandler(Class<E> type) {
    this.type = type;
  }

  public void setNonNullParameter(PreparedStatement ps, int i, E parameter, JdbcType jdbcType) throws SQLException {
    if (jdbcType == null) {
        ps.setString(i, parameter.toString());
    } else {
        ps.setObject(i, parameter.toString(), jdbcType.TYPE_CODE);
    }
  }

  public E getNullableResult(ResultSet rs, String columnName) throws SQLException {
    String s = rs.getString(columnName);
    return s == null ? null : Enum.valueOf(type, s);
  }
<commit_msg>Fix for http://code.google.com/p/mybatis/issues/detail?id=424  - EnumTypeHandler should use Enum.name() rather than Enum.toString()<commit_after>package org.apache.ibatis.type;

import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class EnumTypeHandler<E extends Enum<E>> extends BaseTypeHandler<E> {

  private Class<E> type;

  public EnumTypeHandler(Class<E> type) {
    this.type = type;
  }

  public void setNonNullParameter(PreparedStatement ps, int i, E parameter, JdbcType jdbcType) throws SQLException {
    if (jdbcType == null) {
        ps.setString(i, parameter.name());
    } else {
        ps.setObject(i, parameter.name(), jdbcType.TYPE_CODE);
    }
  }

  public E getNullableResult(ResultSet rs, String columnName) throws SQLException {
    String s = rs.getString(columnName);
    return s == null ? null : Enum.valueOf(type, s);
  }

{'fraction_non_alphanumeric': 0.11237230419977298, 'fraction_numerical': 0.00170261066969353, 'mean_word_length': 4.170087976539589, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1369106', 'n_tokens_mistral': 554, 'n_tokens_neox': 545, 'n_words': 135}