Browse Source

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

dependabot/maven/junit-junit-4.13.1
Travis Burtrum 3 years ago
parent
commit
c143004fc2
  1. 8
      common/src/main/java/com/moparisthebest/jdbc/util/ResultSetUtil.java
  2. 41
      jdbcmapper/src/main/java/com/moparisthebest/jdbc/codegen/JdbcMapperProcessor.java
  3. 3
      jdbcmapper/src/main/java/com/moparisthebest/jdbc/codegen/SimpleSQLChecker.java
  4. 1
      jdbcmapper/src/main/java/com/moparisthebest/jdbc/codegen/SpecialVariableElement.java
  5. 5
      jdbcmapper/src/test/java/com/moparisthebest/jdbc/codegen/ParamPatternTest.java
  6. 9
      test/src/main/java/com/moparisthebest/jdbc/codegen/PersonDAO.java
  7. 9
      test/src/main/java/com/moparisthebest/jdbc/codegen/PrestoPersonDAO.java
  8. 43
      test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOAnyBean.java
  9. 43
      test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOBean.java
  10. 43
      test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOBindBean.java
  11. 43
      test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOOracleBean.java
  12. 43
      test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOUnNestBean.java
  13. 43
      test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/PersonDAOAnyBean.java
  14. 43
      test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/PersonDAOBean.java
  15. 43
      test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/PersonDAOBindBean.java
  16. 43
      test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/PersonDAOOracleBean.java
  17. 43
      test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/PersonDAOUnNestBean.java

8
common/src/main/java/com/moparisthebest/jdbc/util/ResultSetUtil.java

@ -15,6 +15,14 @@ public class ResultSetUtil { @@ -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);

41
jdbcmapper/src/main/java/com/moparisthebest/jdbc/codegen/JdbcMapperProcessor.java

@ -39,7 +39,7 @@ import static com.moparisthebest.jdbc.codegen.SpecialVariableElement.SpecialType @@ -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 { @@ -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 { @@ -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);

3
jdbcmapper/src/main/java/com/moparisthebest/jdbc/codegen/SimpleSQLChecker.java

@ -3,6 +3,7 @@ package com.moparisthebest.jdbc.codegen; @@ -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 { @@ -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;
}

1
jdbcmapper/src/main/java/com/moparisthebest/jdbc/codegen/SpecialVariableElement.java

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

5
jdbcmapper/src/test/java/com/moparisthebest/jdbc/codegen/ParamPatternTest.java

@ -21,6 +21,7 @@ public class ParamPatternTest { @@ -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 { @@ -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) {

9
test/src/main/java/com/moparisthebest/jdbc/codegen/PersonDAO.java

@ -49,6 +49,15 @@ public interface PersonDAO extends JdbcMapper { @@ -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;

9
test/src/main/java/com/moparisthebest/jdbc/codegen/PrestoPersonDAO.java

@ -49,6 +49,15 @@ public interface PrestoPersonDAO extends PersonDAO { @@ -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;

43
test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOAnyBean.java

@ -170,6 +170,49 @@ public class PersonDAOAnyBean implements PersonDAO { @@ -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;

43
test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOBean.java

@ -170,6 +170,49 @@ public class PersonDAOBean implements PersonDAO { @@ -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;

43
test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOBindBean.java

@ -170,6 +170,49 @@ public class PersonDAOBindBean implements PersonDAO { @@ -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;

43
test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOOracleBean.java

@ -170,6 +170,49 @@ public class PersonDAOOracleBean implements PersonDAO { @@ -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;

43
test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOUnNestBean.java

@ -170,6 +170,49 @@ public class PersonDAOUnNestBean implements PersonDAO { @@ -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;

43
test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/PersonDAOAnyBean.java

@ -170,6 +170,49 @@ public class PersonDAOAnyBean implements PersonDAO { @@ -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;

43
test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/PersonDAOBean.java

@ -170,6 +170,49 @@ public class PersonDAOBean implements PersonDAO { @@ -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;

43
test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/PersonDAOBindBean.java

@ -170,6 +170,49 @@ public class PersonDAOBindBean implements PersonDAO { @@ -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;

43
test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/PersonDAOOracleBean.java

@ -170,6 +170,49 @@ public class PersonDAOOracleBean implements PersonDAO { @@ -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;

43
test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/PersonDAOUnNestBean.java

@ -170,6 +170,49 @@ public class PersonDAOUnNestBean implements PersonDAO { @@ -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;

Loading…
Cancel
Save