Implement {str:booleanParamName} for JdbcMapper to set booleans as Strings for crippled databases like Oracle

This commit is contained in:
Travis Burtrum 2020-06-17 01:36:10 -04:00
parent 4f5800a269
commit c143004fc2
17 changed files with 495 additions and 11 deletions

View File

@ -15,6 +15,14 @@ public class ResultSetUtil {
// the UpdateableDTO.YES/NO constants are for legacy reasons and should be considered deprecated
public static final String TRUE = System.getProperty("ResultSetUtil.TRUE", System.getProperty("UpdateableDTO.YES", "Y"));
public static final String FALSE = System.getProperty("ResultSetUtil.FALSE", System.getProperty("UpdateableDTO.NO", "N"));
public static String booleanToString(boolean bool){
return bool ? TRUE : FALSE;
}
public static String booleanToString(Boolean bool){
return bool == null ? null : booleanToString(bool.booleanValue());
}
public static Integer getObjectInt(final ResultSet rs, final int index) throws SQLException {
final int ret = rs.getInt(index);

View File

@ -39,7 +39,7 @@ import static com.moparisthebest.jdbc.codegen.SpecialVariableElement.SpecialType
@SupportedOptions({"jdbcMapper.databaseType", "jdbcMapper.arrayNumberTypeName", "jdbcMapper.arrayStringTypeName", "jdbcMapper.allowedMaxRowParamNames", "jdbcMapper.sqlCheckerClass"})
public class JdbcMapperProcessor extends AbstractProcessor {
public static final Pattern paramPattern = Pattern.compile("\\{(([^\\s]+)\\s+(([Nn][Oo][Tt]\\s+)?[Ii][Nn]\\s+))?([BbCcSs][LlQq][OoLl][Bb]?\\s*:\\s*([^:}]+\\s*:\\s*)?)?([^}]+)\\}");
public static final Pattern paramPattern = Pattern.compile("\\{(([^\\s]+)\\s+(([Nn][Oo][Tt]\\s+)?[Ii][Nn]\\s+))?([BbCcSs][LlQqTt][OoLlRr][Bb]?\\s*:\\s*([^:}]+\\s*:\\s*)?)?([^}]+)\\}");
public static final SourceVersion RELEASE_8;
public static boolean java8;
@ -423,23 +423,32 @@ public class JdbcMapperProcessor extends AbstractProcessor {
bindParams.add(sve);
sqlParam = true;
sqlIterableParam |= sve.iterable || sve.bindable;
} else if(upperClobBlobSql.startsWith("CLOB") || upperClobBlobSql.startsWith("BLOB")) {
} else if(upperClobBlobSql.startsWith("CLOB") || upperClobBlobSql.startsWith("BLOB") || upperClobBlobSql.startsWith("STR")) {
bindParamMatcher.appendReplacement(sb, "?");
final boolean clobNotBlob = 'C' == upperClobBlobSql.charAt(0);
if (clobNotBlob) {
if (blobCharset != null)
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "blob character set not valid with clob", bindParam);
bindParams.add(new SpecialVariableElement(bindParam, SpecialVariableElement.SpecialType.CLOB));
} else {
bindParams.add(new SpecialVariableElement(bindParam, SpecialVariableElement.SpecialType.BLOB, blobCharset));
switch (upperClobBlobSql.charAt(0)) {
case 'B':
bindParams.add(new SpecialVariableElement(bindParam, SpecialVariableElement.SpecialType.BLOB, blobCharset));
break;
case 'C':
if (blobCharset != null)
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "blob character set not valid with clob", bindParam);
bindParams.add(new SpecialVariableElement(bindParam, SpecialVariableElement.SpecialType.CLOB));
break;
case 'S':
if (blobCharset != null)
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "blob character set not valid with str", bindParam);
if(upperClobBlobSql.startsWith("STRB")) // side-effect of regex matching...
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "special variable type can only be clob/blob/str/sql, not " + clobBlobSql, bindParam);
bindParams.add(new SpecialVariableElement(bindParam, SpecialVariableElement.SpecialType.STR_BOOLEAN));
break;
}
} else {
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "special variable type can only be clob/blob/sql, not " + clobBlobSql, bindParam);
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "special variable type can only be clob/blob/str/sql, not " + clobBlobSql, bindParam);
}
}
} else {
if(clobBlobSql != null)
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "cannot combine in/not in and clob/blob/sql", bindParam);
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "cannot combine in/not in and clob/blob/str/sql", bindParam);
SpecialVariableElement inListBindParam = inListBindParams.get(paramName);
if(inListBindParam == null) {
inListBindParam = new SpecialVariableElement(bindParam,
@ -1018,6 +1027,16 @@ public class JdbcMapperProcessor extends AbstractProcessor {
}
break;
}
case STR_BOOLEAN: {
if (types.isAssignable(o, booleanType) || o.getKind() == TypeKind.BOOLEAN) {
method = "String";
variableName = "com.moparisthebest.jdbc.util.ResultSetUtil.booleanToString(" + variableName + ")";
} else {
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "JdbcMapper {str:paramName} only valid for boolean, Boolean", specialParam.delegate);
return;
}
break;
}
case SQL: {
if(specialParam.iterable || specialParam.bindable) {
w.append("psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, ").append(specialParam.name);

View File

@ -3,6 +3,7 @@ package com.moparisthebest.jdbc.codegen;
import com.moparisthebest.jdbc.ArrayInList;
import com.moparisthebest.jdbc.QueryMapper;
import com.moparisthebest.jdbc.util.Bindable;
import com.moparisthebest.jdbc.util.ResultSetUtil;
import javax.annotation.processing.Messager;
import javax.annotation.processing.ProcessingEnvironment;
@ -135,6 +136,8 @@ public class SimpleSQLChecker implements SQLChecker {
return new ByteArrayInputStream(new byte[1]);
case CLOB:
return new StringReader(defaultString);
case STR_BOOLEAN:
return ResultSetUtil.TRUE;
case SQL:
return Bindable.empty;
}

View File

@ -17,6 +17,7 @@ class SpecialVariableElement implements VariableElement {
CLOB,
BLOB,
SQL,
STR_BOOLEAN,
}
final VariableElement delegate;

View File

@ -21,6 +21,7 @@ public class ParamPatternTest {
testMatch("{last_name IN lastNames}", s("last_name IN ", "last_name", "IN ", null, null, null, "lastNames"));
testMatch("{last_name not in lastNames}", s("last_name not in ", "last_name", "not in ", "not ", null, null, "lastNames"));
testMatch("{clob:comment}", s(null, null, null, null, "clob:", null, "comment"));
testMatch("{clob : comment}", s(null, null, null, null, "clob : ", null, "comment"));
testMatch("{clob: comment}", s(null, null, null, null, "clob: ", null, "comment"));
testMatch("{blob: comment}", s(null, null, null, null, "blob: ", null, "comment"));
testMatch("{Blob: comment}", s(null, null, null, null, "Blob: ", null, "comment"));
@ -38,6 +39,10 @@ public class ParamPatternTest {
testMatch("{Sql : sqlStatement}", s(null, null, null, null, "Sql : ", null, "sqlStatement"));
testMatch("{sql:person:sqlStatement}", s(null, null, null, null, "sql:person:", "person:", "sqlStatement"));
testMatch("{sql:JOIN person ON p.person_no = b.person_no:sqlStatement}", s(null, null, null, null, "sql:JOIN person ON p.person_no = b.person_no:", "JOIN person ON p.person_no = b.person_no:", "sqlStatement"));
testMatch("{str:comment}", s(null, null, null, null, "str:", null, "comment"));
testMatch("{str: comment}", s(null, null, null, null, "str: ", null, "comment"));
testMatch("{str : comment}", s(null, null, null, null, "str : ", null, "comment"));
}
private static void testMatch(final String sql, final Collection<String[]> expected) {

View File

@ -49,6 +49,15 @@ public interface PersonDAO extends JdbcMapper {
@JdbcMapper.SQL("UPDATE person SET first_name = {blob:firstName} WHERE person_no = {personNo}")
void setFirstNameBlob(String firstName, long personNo) throws SQLException;
@JdbcMapper.SQL("UPDATE person SET first_name = {blob:utf-16:firstName} WHERE person_no = {personNo}")
void setFirstNameBlobUtf16(String firstName, long personNo) throws SQLException;
@JdbcMapper.SQL("UPDATE person SET first_name = {clob:firstName} WHERE person_no = {personNo}")
void setFirstNameClob(String firstName, long personNo) throws SQLException;
@JdbcMapper.SQL("UPDATE person SET first_name = {str:firstName} WHERE person_no = {personNo}")
void setFirstNameStringBoolean(boolean firstName, long personNo) throws SQLException;
@JdbcMapper.SQL("SELECT person_no FROM person WHERE last_name = {lastName}")
long getPersonNo(String lastName) throws SQLException;

View File

@ -49,6 +49,15 @@ public interface PrestoPersonDAO extends PersonDAO {
@JdbcMapper.SQL("UPDATE person SET first_name = {blob:firstName} WHERE person_no = {personNo}")
void setFirstNameBlob(String firstName, long personNo) throws SQLException;
@JdbcMapper.SQL("UPDATE person SET first_name = {blob:utf-16:firstName} WHERE person_no = {personNo}")
void setFirstNameBlobUtf16(String firstName, long personNo) throws SQLException;
@JdbcMapper.SQL("UPDATE person SET first_name = {clob:firstName} WHERE person_no = {personNo}")
void setFirstNameClob(String firstName, long personNo) throws SQLException;
@JdbcMapper.SQL("UPDATE person SET first_name = {str:firstName} WHERE person_no = {personNo}")
void setFirstNameStringBoolean(boolean firstName, long personNo) throws SQLException;
@JdbcMapper.SQL("SELECT person_no FROM person WHERE last_name = {lastName}")
long getPersonNo(String lastName) throws SQLException;

View File

@ -170,6 +170,49 @@ public class PersonDAOAnyBean implements PersonDAO {
}
}
@Override
public void setFirstNameBlobUtf16(final java.lang.String firstName, final long personNo) throws java.sql.SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE person_no = ?");
try {
ps.setBlob(1, firstName == null ? null : new java.io.ByteArrayInputStream(firstName.getBytes("utf-16")));
} catch (java.io.UnsupportedEncodingException e) {
throw new SQLException("String to Blob UnsupportedEncodingException", e);
}
ps.setObject(2, personNo);
ps.executeUpdate();
} finally {
tryClose(ps);
}
}
@Override
public void setFirstNameClob(final java.lang.String firstName, final long personNo) throws java.sql.SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE person_no = ?");
ps.setClob(1, firstName == null ? null : new java.io.StringReader(firstName));
ps.setObject(2, personNo);
ps.executeUpdate();
} finally {
tryClose(ps);
}
}
@Override
public void setFirstNameStringBoolean(final boolean firstName, final long personNo) throws java.sql.SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE person_no = ?");
ps.setString(1, com.moparisthebest.jdbc.util.ResultSetUtil.booleanToString(firstName));
ps.setObject(2, personNo);
ps.executeUpdate();
} finally {
tryClose(ps);
}
}
@Override
public long getPersonNo(final java.lang.String lastName) throws java.sql.SQLException {
PreparedStatement ps = null;

View File

@ -170,6 +170,49 @@ public class PersonDAOBean implements PersonDAO {
}
}
@Override
public void setFirstNameBlobUtf16(final java.lang.String firstName, final long personNo) throws java.sql.SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE person_no = ?");
try {
ps.setBlob(1, firstName == null ? null : new java.io.ByteArrayInputStream(firstName.getBytes("utf-16")));
} catch (java.io.UnsupportedEncodingException e) {
throw new SQLException("String to Blob UnsupportedEncodingException", e);
}
ps.setObject(2, personNo);
ps.executeUpdate();
} finally {
tryClose(ps);
}
}
@Override
public void setFirstNameClob(final java.lang.String firstName, final long personNo) throws java.sql.SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE person_no = ?");
ps.setClob(1, firstName == null ? null : new java.io.StringReader(firstName));
ps.setObject(2, personNo);
ps.executeUpdate();
} finally {
tryClose(ps);
}
}
@Override
public void setFirstNameStringBoolean(final boolean firstName, final long personNo) throws java.sql.SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE person_no = ?");
ps.setString(1, com.moparisthebest.jdbc.util.ResultSetUtil.booleanToString(firstName));
ps.setObject(2, personNo);
ps.executeUpdate();
} finally {
tryClose(ps);
}
}
@Override
public long getPersonNo(final java.lang.String lastName) throws java.sql.SQLException {
PreparedStatement ps = null;

View File

@ -170,6 +170,49 @@ public class PersonDAOBindBean implements PersonDAO {
}
}
@Override
public void setFirstNameBlobUtf16(final java.lang.String firstName, final long personNo) throws java.sql.SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE person_no = ?");
try {
ps.setBlob(1, firstName == null ? null : new java.io.ByteArrayInputStream(firstName.getBytes("utf-16")));
} catch (java.io.UnsupportedEncodingException e) {
throw new SQLException("String to Blob UnsupportedEncodingException", e);
}
ps.setObject(2, personNo);
ps.executeUpdate();
} finally {
tryClose(ps);
}
}
@Override
public void setFirstNameClob(final java.lang.String firstName, final long personNo) throws java.sql.SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE person_no = ?");
ps.setClob(1, firstName == null ? null : new java.io.StringReader(firstName));
ps.setObject(2, personNo);
ps.executeUpdate();
} finally {
tryClose(ps);
}
}
@Override
public void setFirstNameStringBoolean(final boolean firstName, final long personNo) throws java.sql.SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE person_no = ?");
ps.setString(1, com.moparisthebest.jdbc.util.ResultSetUtil.booleanToString(firstName));
ps.setObject(2, personNo);
ps.executeUpdate();
} finally {
tryClose(ps);
}
}
@Override
public long getPersonNo(final java.lang.String lastName) throws java.sql.SQLException {
PreparedStatement ps = null;

View File

@ -170,6 +170,49 @@ public class PersonDAOOracleBean implements PersonDAO {
}
}
@Override
public void setFirstNameBlobUtf16(final java.lang.String firstName, final long personNo) throws java.sql.SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE person_no = ?");
try {
ps.setBlob(1, firstName == null ? null : new java.io.ByteArrayInputStream(firstName.getBytes("utf-16")));
} catch (java.io.UnsupportedEncodingException e) {
throw new SQLException("String to Blob UnsupportedEncodingException", e);
}
ps.setObject(2, personNo);
ps.executeUpdate();
} finally {
tryClose(ps);
}
}
@Override
public void setFirstNameClob(final java.lang.String firstName, final long personNo) throws java.sql.SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE person_no = ?");
ps.setClob(1, firstName == null ? null : new java.io.StringReader(firstName));
ps.setObject(2, personNo);
ps.executeUpdate();
} finally {
tryClose(ps);
}
}
@Override
public void setFirstNameStringBoolean(final boolean firstName, final long personNo) throws java.sql.SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE person_no = ?");
ps.setString(1, com.moparisthebest.jdbc.util.ResultSetUtil.booleanToString(firstName));
ps.setObject(2, personNo);
ps.executeUpdate();
} finally {
tryClose(ps);
}
}
@Override
public long getPersonNo(final java.lang.String lastName) throws java.sql.SQLException {
PreparedStatement ps = null;

View File

@ -170,6 +170,49 @@ public class PersonDAOUnNestBean implements PersonDAO {
}
}
@Override
public void setFirstNameBlobUtf16(final java.lang.String firstName, final long personNo) throws java.sql.SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE person_no = ?");
try {
ps.setBlob(1, firstName == null ? null : new java.io.ByteArrayInputStream(firstName.getBytes("utf-16")));
} catch (java.io.UnsupportedEncodingException e) {
throw new SQLException("String to Blob UnsupportedEncodingException", e);
}
ps.setObject(2, personNo);
ps.executeUpdate();
} finally {
tryClose(ps);
}
}
@Override
public void setFirstNameClob(final java.lang.String firstName, final long personNo) throws java.sql.SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE person_no = ?");
ps.setClob(1, firstName == null ? null : new java.io.StringReader(firstName));
ps.setObject(2, personNo);
ps.executeUpdate();
} finally {
tryClose(ps);
}
}
@Override
public void setFirstNameStringBoolean(final boolean firstName, final long personNo) throws java.sql.SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE person_no = ?");
ps.setString(1, com.moparisthebest.jdbc.util.ResultSetUtil.booleanToString(firstName));
ps.setObject(2, personNo);
ps.executeUpdate();
} finally {
tryClose(ps);
}
}
@Override
public long getPersonNo(final java.lang.String lastName) throws java.sql.SQLException {
PreparedStatement ps = null;

View File

@ -170,6 +170,49 @@ public class PersonDAOAnyBean implements PersonDAO {
}
}
@Override
public void setFirstNameBlobUtf16(final java.lang.String firstName, final long personNo) throws java.sql.SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE person_no = ?");
try {
ps.setBlob(1, firstName == null ? null : new java.io.ByteArrayInputStream(firstName.getBytes("utf-16")));
} catch (java.io.UnsupportedEncodingException e) {
throw new SQLException("String to Blob UnsupportedEncodingException", e);
}
ps.setObject(2, personNo);
ps.executeUpdate();
} finally {
tryClose(ps);
}
}
@Override
public void setFirstNameClob(final java.lang.String firstName, final long personNo) throws java.sql.SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE person_no = ?");
ps.setClob(1, firstName == null ? null : new java.io.StringReader(firstName));
ps.setObject(2, personNo);
ps.executeUpdate();
} finally {
tryClose(ps);
}
}
@Override
public void setFirstNameStringBoolean(final boolean firstName, final long personNo) throws java.sql.SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE person_no = ?");
ps.setString(1, com.moparisthebest.jdbc.util.ResultSetUtil.booleanToString(firstName));
ps.setObject(2, personNo);
ps.executeUpdate();
} finally {
tryClose(ps);
}
}
@Override
public long getPersonNo(final java.lang.String lastName) throws java.sql.SQLException {
PreparedStatement ps = null;

View File

@ -170,6 +170,49 @@ public class PersonDAOBean implements PersonDAO {
}
}
@Override
public void setFirstNameBlobUtf16(final java.lang.String firstName, final long personNo) throws java.sql.SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE person_no = ?");
try {
ps.setBlob(1, firstName == null ? null : new java.io.ByteArrayInputStream(firstName.getBytes("utf-16")));
} catch (java.io.UnsupportedEncodingException e) {
throw new SQLException("String to Blob UnsupportedEncodingException", e);
}
ps.setObject(2, personNo);
ps.executeUpdate();
} finally {
tryClose(ps);
}
}
@Override
public void setFirstNameClob(final java.lang.String firstName, final long personNo) throws java.sql.SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE person_no = ?");
ps.setClob(1, firstName == null ? null : new java.io.StringReader(firstName));
ps.setObject(2, personNo);
ps.executeUpdate();
} finally {
tryClose(ps);
}
}
@Override
public void setFirstNameStringBoolean(final boolean firstName, final long personNo) throws java.sql.SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE person_no = ?");
ps.setString(1, com.moparisthebest.jdbc.util.ResultSetUtil.booleanToString(firstName));
ps.setObject(2, personNo);
ps.executeUpdate();
} finally {
tryClose(ps);
}
}
@Override
public long getPersonNo(final java.lang.String lastName) throws java.sql.SQLException {
PreparedStatement ps = null;

View File

@ -170,6 +170,49 @@ public class PersonDAOBindBean implements PersonDAO {
}
}
@Override
public void setFirstNameBlobUtf16(final java.lang.String firstName, final long personNo) throws java.sql.SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE person_no = ?");
try {
ps.setBlob(1, firstName == null ? null : new java.io.ByteArrayInputStream(firstName.getBytes("utf-16")));
} catch (java.io.UnsupportedEncodingException e) {
throw new SQLException("String to Blob UnsupportedEncodingException", e);
}
ps.setObject(2, personNo);
ps.executeUpdate();
} finally {
tryClose(ps);
}
}
@Override
public void setFirstNameClob(final java.lang.String firstName, final long personNo) throws java.sql.SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE person_no = ?");
ps.setClob(1, firstName == null ? null : new java.io.StringReader(firstName));
ps.setObject(2, personNo);
ps.executeUpdate();
} finally {
tryClose(ps);
}
}
@Override
public void setFirstNameStringBoolean(final boolean firstName, final long personNo) throws java.sql.SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE person_no = ?");
ps.setString(1, com.moparisthebest.jdbc.util.ResultSetUtil.booleanToString(firstName));
ps.setObject(2, personNo);
ps.executeUpdate();
} finally {
tryClose(ps);
}
}
@Override
public long getPersonNo(final java.lang.String lastName) throws java.sql.SQLException {
PreparedStatement ps = null;

View File

@ -170,6 +170,49 @@ public class PersonDAOOracleBean implements PersonDAO {
}
}
@Override
public void setFirstNameBlobUtf16(final java.lang.String firstName, final long personNo) throws java.sql.SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE person_no = ?");
try {
ps.setBlob(1, firstName == null ? null : new java.io.ByteArrayInputStream(firstName.getBytes("utf-16")));
} catch (java.io.UnsupportedEncodingException e) {
throw new SQLException("String to Blob UnsupportedEncodingException", e);
}
ps.setObject(2, personNo);
ps.executeUpdate();
} finally {
tryClose(ps);
}
}
@Override
public void setFirstNameClob(final java.lang.String firstName, final long personNo) throws java.sql.SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE person_no = ?");
ps.setClob(1, firstName == null ? null : new java.io.StringReader(firstName));
ps.setObject(2, personNo);
ps.executeUpdate();
} finally {
tryClose(ps);
}
}
@Override
public void setFirstNameStringBoolean(final boolean firstName, final long personNo) throws java.sql.SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE person_no = ?");
ps.setString(1, com.moparisthebest.jdbc.util.ResultSetUtil.booleanToString(firstName));
ps.setObject(2, personNo);
ps.executeUpdate();
} finally {
tryClose(ps);
}
}
@Override
public long getPersonNo(final java.lang.String lastName) throws java.sql.SQLException {
PreparedStatement ps = null;

View File

@ -170,6 +170,49 @@ public class PersonDAOUnNestBean implements PersonDAO {
}
}
@Override
public void setFirstNameBlobUtf16(final java.lang.String firstName, final long personNo) throws java.sql.SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE person_no = ?");
try {
ps.setBlob(1, firstName == null ? null : new java.io.ByteArrayInputStream(firstName.getBytes("utf-16")));
} catch (java.io.UnsupportedEncodingException e) {
throw new SQLException("String to Blob UnsupportedEncodingException", e);
}
ps.setObject(2, personNo);
ps.executeUpdate();
} finally {
tryClose(ps);
}
}
@Override
public void setFirstNameClob(final java.lang.String firstName, final long personNo) throws java.sql.SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE person_no = ?");
ps.setClob(1, firstName == null ? null : new java.io.StringReader(firstName));
ps.setObject(2, personNo);
ps.executeUpdate();
} finally {
tryClose(ps);
}
}
@Override
public void setFirstNameStringBoolean(final boolean firstName, final long personNo) throws java.sql.SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE person_no = ?");
ps.setString(1, com.moparisthebest.jdbc.util.ResultSetUtil.booleanToString(firstName));
ps.setObject(2, personNo);
ps.executeUpdate();
} finally {
tryClose(ps);
}
}
@Override
public long getPersonNo(final java.lang.String lastName) throws java.sql.SQLException {
PreparedStatement ps = null;