Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2022 the original author or authors.
* Copyright 2004-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,13 +20,13 @@
*/
public abstract class BaseTypeHandler implements TypeHandler {

@Override
public boolean equals(Object object, String string) {
if (object == null || string == null) {
return object == string;
} else {
Object castedObject = valueOf(string);
return object.equals(castedObject);
}
Object castedObject = valueOf(string);
return object.equals(castedObject);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,39 @@
*/
public class BigDecimalTypeHandler extends BaseTypeHandler implements TypeHandler {

@Override
public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) throws SQLException {
ps.setBigDecimal(i, ((BigDecimal) parameter));
ps.setBigDecimal(i, (BigDecimal) parameter);
}

@Override
public Object getResult(ResultSet rs, String columnName) throws SQLException {
Object bigdec = rs.getBigDecimal(columnName);
if (rs.wasNull()) {
return null;
} else {
return bigdec;
}
return bigdec;
}

@Override
public Object getResult(ResultSet rs, int columnIndex) throws SQLException {
Object bigdec = rs.getBigDecimal(columnIndex);
if (rs.wasNull()) {
return null;
} else {
return bigdec;
}
return bigdec;
}

@Override
public Object getResult(CallableStatement cs, int columnIndex) throws SQLException {
Object bigdec = cs.getBigDecimal(columnIndex);
if (cs.wasNull()) {
return null;
} else {
return bigdec;
}
return bigdec;
}

@Override
public Object valueOf(String s) {
return java.math.BigDecimal.valueOf(Long.parseLong(s));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2022 the original author or authors.
* Copyright 2004-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -29,6 +29,7 @@
*/
public class BlobTypeHandlerCallback implements TypeHandlerCallback {

@Override
public Object getResult(ResultGetter getter) throws SQLException {
Blob blob = getter.getBlob();
byte[] returnValue;
Expand All @@ -40,16 +41,18 @@ public Object getResult(ResultGetter getter) throws SQLException {
return returnValue;
}

@Override
public void setParameter(ParameterSetter setter, Object parameter) throws SQLException {
if (null != parameter) {
byte[] bytes = (byte[]) parameter;
ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
setter.setBinaryStream(bis, (int) (bytes.length));
setter.setBinaryStream(bis, bytes.length);
} else {
setter.setNull(Types.BLOB);
}
}

@Override
public Object valueOf(String s) {
return s;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2022 the original author or authors.
* Copyright 2004-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -25,37 +25,39 @@
*/
public class BooleanTypeHandler extends BaseTypeHandler implements TypeHandler {

@Override
public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) throws SQLException {
ps.setBoolean(i, ((Boolean) parameter).booleanValue());
}

@Override
public Object getResult(ResultSet rs, String columnName) throws SQLException {
boolean b = rs.getBoolean(columnName);
if (rs.wasNull()) {
return null;
} else {
return Boolean.valueOf(b);
}
return Boolean.valueOf(b);
}

@Override
public Object getResult(ResultSet rs, int columnIndex) throws SQLException {
boolean b = rs.getBoolean(columnIndex);
if (rs.wasNull()) {
return null;
} else {
return Boolean.valueOf(b);
}
return Boolean.valueOf(b);
}

@Override
public Object getResult(CallableStatement cs, int columnIndex) throws SQLException {
boolean b = cs.getBoolean(columnIndex);
if (cs.wasNull()) {
return null;
} else {
return Boolean.valueOf(b);
}
return Boolean.valueOf(b);
}

@Override
public Object valueOf(String s) {
return Boolean.valueOf(s);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2022 the original author or authors.
* Copyright 2004-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -25,37 +25,39 @@
*/
public class ByteArrayTypeHandler extends BaseTypeHandler implements TypeHandler {

@Override
public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) throws SQLException {
ps.setBytes(i, (byte[]) parameter);
}

@Override
public Object getResult(ResultSet rs, String columnName) throws SQLException {
Object bytes = rs.getBytes(columnName);
if (rs.wasNull()) {
return null;
} else {
return bytes;
}
return bytes;
}

@Override
public Object getResult(ResultSet rs, int columnIndex) throws SQLException {
Object bytes = rs.getBytes(columnIndex);
if (rs.wasNull()) {
return null;
} else {
return bytes;
}
return bytes;
}

@Override
public Object getResult(CallableStatement cs, int columnIndex) throws SQLException {
Object bytes = cs.getBytes(columnIndex);
if (cs.wasNull()) {
return null;
} else {
return bytes;
}
return bytes;
}

@Override
public Object valueOf(String s) {
return s.getBytes();
}
Expand Down
16 changes: 9 additions & 7 deletions src/main/java/com/ibatis/sqlmap/engine/type/ByteTypeHandler.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2022 the original author or authors.
* Copyright 2004-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -25,37 +25,39 @@
*/
public class ByteTypeHandler extends BaseTypeHandler implements TypeHandler {

@Override
public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) throws SQLException {
ps.setByte(i, ((Byte) parameter).byteValue());
}

@Override
public Object getResult(ResultSet rs, String columnName) throws SQLException {
byte b = rs.getByte(columnName);
if (rs.wasNull()) {
return null;
} else {
return Byte.valueOf(b);
}
return Byte.valueOf(b);
}

@Override
public Object getResult(ResultSet rs, int columnIndex) throws SQLException {
byte b = rs.getByte(columnIndex);
if (rs.wasNull()) {
return null;
} else {
return Byte.valueOf(b);
}
return Byte.valueOf(b);
}

@Override
public Object getResult(CallableStatement cs, int columnIndex) throws SQLException {
byte b = cs.getByte(columnIndex);
if (cs.wasNull()) {
return null;
} else {
return Byte.valueOf(b);
}
return Byte.valueOf(b);
}

@Override
public Object valueOf(String s) {
return Byte.valueOf(s);
}
Expand Down
Loading
Loading