There is no built-in type handler for AtomicLong
, so you may need to write one.
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedTypes;
@MappedTypes(AtomicLong.class)
public class AtomicLongTypeHandler
extends BaseTypeHandler<AtomicLong>{
@Override
public void setNonNullParameter(PreparedStatement ps, int i,
AtomicLong parameter, JdbcType jdbcType)
throws SQLException {
ps.setLong(i, parameter.get());
}
@Override
public AtomicLong getNullableResult(ResultSet rs,
String columnName) throws SQLException {
return new AtomicLong(rs.getLong(columnName));
}
@Override
public AtomicLong getNullableResult(ResultSet rs,
int columnIndex) throws SQLException {
return new AtomicLong(rs.getLong(columnIndex));
}
@Override
public AtomicLong getNullableResult(CallableStatement cs,
int columnIndex) throws SQLException {
return new AtomicLong(cs.getLong(columnIndex));
}
}
You can register the type handler globally in the config. e.g.
<typeHandlers>
<typeHandler handler="pkg.AtomicLongTypeHandler" />
</typeHandlers>
The result map should work as-is.