From 3a51d6ee56a8337980de71d525bcd64596a94fbb Mon Sep 17 00:00:00 2001 From: moparisthebest Date: Fri, 18 Oct 2019 19:36:03 -0400 Subject: [PATCH] Fix breakage when encountering TYPE_USE annotations --- .../codegen/CompileTimeResultSetMapper.java | 4 +- .../jdbc/codegen/JdbcMapperProcessor.java | 60 +++++++++++++++---- .../jdbc/codegen/JdbcMapperProcessorTest.java | 23 +++++++ .../jdbc/TypeUseAnnotation.java | 16 +++++ .../jdbc/codegen/PersonDAO.java | 3 + .../jdbc/codegen/PrestoPersonDAO.java | 3 + .../jdbc/dto/TypeUsePerson.java | 51 ++++++++++++++++ .../jdbc/codegen/PersonDAOAnyBean.java | 24 ++++++++ .../jdbc/codegen/PersonDAOBean.java | 24 ++++++++ .../jdbc/codegen/PersonDAOBindBean.java | 24 ++++++++ .../jdbc/codegen/PersonDAOOracleBean.java | 24 ++++++++ .../jdbc/codegen/PersonDAOUnNestBean.java | 24 ++++++++ .../jdbc/codegen/PersonDAOAnyBean.java | 24 ++++++++ .../jdbc/codegen/PersonDAOBean.java | 24 ++++++++ .../jdbc/codegen/PersonDAOBindBean.java | 24 ++++++++ .../jdbc/codegen/PersonDAOOracleBean.java | 24 ++++++++ .../jdbc/codegen/PersonDAOUnNestBean.java | 24 ++++++++ 17 files changed, 385 insertions(+), 15 deletions(-) create mode 100644 jdbcmapper/src/test/java/com/moparisthebest/jdbc/codegen/JdbcMapperProcessorTest.java create mode 100644 test/src/main/java/com/moparisthebest/jdbc/TypeUseAnnotation.java create mode 100644 test/src/main/java/com/moparisthebest/jdbc/dto/TypeUsePerson.java diff --git a/jdbcmapper/src/main/java/com/moparisthebest/jdbc/codegen/CompileTimeResultSetMapper.java b/jdbcmapper/src/main/java/com/moparisthebest/jdbc/codegen/CompileTimeResultSetMapper.java index 7e8e6ea..0b1bf85 100644 --- a/jdbcmapper/src/main/java/com/moparisthebest/jdbc/codegen/CompileTimeResultSetMapper.java +++ b/jdbcmapper/src/main/java/com/moparisthebest/jdbc/codegen/CompileTimeResultSetMapper.java @@ -26,7 +26,7 @@ import java.util.stream.Stream; //IFJAVA8_END import static com.moparisthebest.jdbc.codegen.JdbcMapperProcessor.java8; -import static com.moparisthebest.jdbc.codegen.JdbcMapperProcessor.typeMirrorStringNoGenerics; +import static com.moparisthebest.jdbc.codegen.JdbcMapperProcessor.baseTypeMirrorString; import static com.moparisthebest.jdbc.codegen.JdbcMapperProcessor.typeMirrorToClass; /** @@ -75,7 +75,7 @@ public class CompileTimeResultSetMapper { // ignore? } } - return typeMirrorStringNoGenerics(returnType); + return baseTypeMirrorString(returnType.toString()); } /** diff --git a/jdbcmapper/src/main/java/com/moparisthebest/jdbc/codegen/JdbcMapperProcessor.java b/jdbcmapper/src/main/java/com/moparisthebest/jdbc/codegen/JdbcMapperProcessor.java index 06c76b9..a4b4c37 100644 --- a/jdbcmapper/src/main/java/com/moparisthebest/jdbc/codegen/JdbcMapperProcessor.java +++ b/jdbcmapper/src/main/java/com/moparisthebest/jdbc/codegen/JdbcMapperProcessor.java @@ -14,6 +14,7 @@ import javax.lang.model.util.Types; import javax.tools.Diagnostic; import java.io.*; import java.lang.annotation.Annotation; +import java.lang.reflect.InvocationTargetException; import java.sql.Blob; import java.sql.Clob; import java.sql.Connection; @@ -1162,20 +1163,53 @@ public class JdbcMapperProcessor extends AbstractProcessor { default: return Class.forName("[L" + arrayComponentType.toString() + ";"); } - case DECLARED: - if (!((DeclaredType) tm).getTypeArguments().isEmpty()) { - return Class.forName(typeMirrorStringNoGenerics(tm)); - } - // fallthrough otherwise... - default: - return Class.forName(tm.toString()); - } - } + case DECLARED: + final DeclaredType dt = (DeclaredType) tm; + if (!dt.getTypeArguments().isEmpty() + //IFJAVA8_START + || !dt.getAnnotationMirrors().isEmpty() + //IFJAVA8_END + ) { + //messager.printMessage(Diagnostic.Kind.MANDATORY_WARNING, "dt.toString(): " + dt.toString() + " dt.getClass(): " + dt.getClass(), types.asElement(dt)); + //return dt.getClass().getDeclaredMethod("unannotatedType").invoke(dt).toString(); // this is java 8 only + //return dt.getClass().getDeclaredMethod("getEnclosingType").invoke(dt); // modules prevent this 9+ - public static String typeMirrorStringNoGenerics(final TypeMirror tm) { - final String classWithGenerics = tm.toString(); - return classWithGenerics.substring(0, classWithGenerics.indexOf('<')); - } + return Class.forName(baseTypeMirrorString(tm.toString())); + } + // fallthrough otherwise... + default: + return Class.forName(tm.toString()); + } + } + + /** + * This is a terrible hack because I don't think a proper solution exists, the TypeUseAnnotation.java in the test module + * tests this functionality by being similar to real-world NotNull: + *

+ * https://github.com/eclipse-ee4j/beanvalidation-api/blob/master/src/main/java/javax/validation/constraints/NotNull.java + *

+ * The problem is they added TYPE_USE to the list of targets in this commit: + *

+ * https://github.com/eclipse-ee4j/beanvalidation-api/commit/87ea7911ffc8578807ab78886e9483e87bcc7acd#diff-8aebda554210427d515ad1c7b1274d60 + *

+ * Which was well-known as a bad thing to do that cannot be handled all the way back in 2013 before Java 8 was even released: + *

+ * https://mail.openjdk.java.net/pipermail/type-annotations-spec-comments/2013-October/000049.html + *

+ * In practice, a type that used to be `java.lang.String` now reads as `(@javax.validation.constraints.NotNull :: java.lang.String)` + * with absolutely no documented way I can find to get the original type back out, the below way seems to work with + * the openjdk compilers 8-15 which was latest at the time of this writing, but I will continue to investigate a better + * way to do it. + * + * @param tm a DeclaredType that is an AnnotatedType underneath + * @return the DeclaredType as a String without generics or type annotations + */ + public static String baseTypeMirrorString(final String rawTypeString) { + return baseTypeBegin.matcher(baseTypeEnd.matcher(rawTypeString).replaceAll("")).replaceAll(""); + } + + private static final Pattern baseTypeEnd = Pattern.compile("(<.*|[)])$"); + private static final Pattern baseTypeBegin = Pattern.compile("^.*\\s"); public ExecutableElement getCloseMethod(final TypeElement genClass) { ExecutableElement ret = null; diff --git a/jdbcmapper/src/test/java/com/moparisthebest/jdbc/codegen/JdbcMapperProcessorTest.java b/jdbcmapper/src/test/java/com/moparisthebest/jdbc/codegen/JdbcMapperProcessorTest.java new file mode 100644 index 0000000..470c1c7 --- /dev/null +++ b/jdbcmapper/src/test/java/com/moparisthebest/jdbc/codegen/JdbcMapperProcessorTest.java @@ -0,0 +1,23 @@ +package com.moparisthebest.jdbc.codegen; + +import org.junit.Test; + +import static com.moparisthebest.jdbc.codegen.JdbcMapperProcessor.baseTypeMirrorString; +import static org.junit.Assert.*; + +public class JdbcMapperProcessorTest { + + @Test + public void baseTypeMirrorStringTest() { + // generics + assertEquals("java.util.List", baseTypeMirrorString("java.util.List>")); + assertEquals("java.util.Map", baseTypeMirrorString("java.util.Map")); + assertEquals("java.util.Map", baseTypeMirrorString("java.util.Map>")); + // how java 8 formats TYPE_USE annotations + assertEquals("java.lang.String", baseTypeMirrorString("(@com.moparisthebest.jdbc.TypeUseAnnotation :: java.lang.String)")); + assertEquals("java.util.Date", baseTypeMirrorString("(@com.moparisthebest.jdbc.TypeUseAnnotation :: java.util.Date)")); + // how java 13 formats TYPE_USE annotations + assertEquals("java.lang.String", baseTypeMirrorString("@com.moparisthebest.jdbc.TypeUseAnnotation java.lang.String")); + assertEquals("java.util.Date", baseTypeMirrorString("@com.moparisthebest.jdbc.TypeUseAnnotation java.util.Date")); + } +} \ No newline at end of file diff --git a/test/src/main/java/com/moparisthebest/jdbc/TypeUseAnnotation.java b/test/src/main/java/com/moparisthebest/jdbc/TypeUseAnnotation.java new file mode 100644 index 0000000..3aca779 --- /dev/null +++ b/test/src/main/java/com/moparisthebest/jdbc/TypeUseAnnotation.java @@ -0,0 +1,16 @@ +package com.moparisthebest.jdbc; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import static java.lang.annotation.ElementType.*; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +@Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER + //IFJAVA8_START + , TYPE_USE + //IFJAVA8_END +}) +@Retention(RUNTIME) +public @interface TypeUseAnnotation { +} diff --git a/test/src/main/java/com/moparisthebest/jdbc/codegen/PersonDAO.java b/test/src/main/java/com/moparisthebest/jdbc/codegen/PersonDAO.java index df51949..143cbc7 100644 --- a/test/src/main/java/com/moparisthebest/jdbc/codegen/PersonDAO.java +++ b/test/src/main/java/com/moparisthebest/jdbc/codegen/PersonDAO.java @@ -84,6 +84,9 @@ public interface PersonDAO extends JdbcMapper { @JdbcMapper.SQL("SELECT first_name, last_name, birth_date FROM person WHERE person_no = {personNo}") FieldPerson getPerson(long personNo, Calendar cal) throws SQLException; + + @JdbcMapper.SQL("SELECT person_no, first_name, last_name, birth_date FROM person WHERE person_no = {personNo}") + TypeUsePerson getTypeUsePerson(long personNo, Calendar cal) throws SQLException; @JdbcMapper.SQL("SELECT first_name, last_name FROM person WHERE last_name = {lastName}") List getPeople(String lastName) throws SQLException; diff --git a/test/src/main/java/com/moparisthebest/jdbc/codegen/PrestoPersonDAO.java b/test/src/main/java/com/moparisthebest/jdbc/codegen/PrestoPersonDAO.java index 41fd05e..16a7545 100644 --- a/test/src/main/java/com/moparisthebest/jdbc/codegen/PrestoPersonDAO.java +++ b/test/src/main/java/com/moparisthebest/jdbc/codegen/PrestoPersonDAO.java @@ -84,6 +84,9 @@ public interface PrestoPersonDAO extends PersonDAO { @JdbcMapper.SQL("SELECT first_name, last_name, birth_date FROM person WHERE person_no = {personNo}") FieldPerson getPerson(long personNo, Calendar cal) throws SQLException; + + @JdbcMapper.SQL("SELECT person_no, first_name, last_name, birth_date FROM person WHERE person_no = {personNo}") + TypeUsePerson getTypeUsePerson(long personNo, Calendar cal) throws SQLException; @JdbcMapper.SQL("SELECT first_name, last_name FROM person WHERE last_name = {lastName}") List getPeople(String lastName) throws SQLException; diff --git a/test/src/main/java/com/moparisthebest/jdbc/dto/TypeUsePerson.java b/test/src/main/java/com/moparisthebest/jdbc/dto/TypeUsePerson.java new file mode 100644 index 0000000..07bf67d --- /dev/null +++ b/test/src/main/java/com/moparisthebest/jdbc/dto/TypeUsePerson.java @@ -0,0 +1,51 @@ +package com.moparisthebest.jdbc.dto; + +import com.moparisthebest.jdbc.TypeUseAnnotation; + +import java.util.Date; + +public class TypeUsePerson implements Person { + + public long personNo; + + @TypeUseAnnotation + public Date birthDate; + @TypeUseAnnotation + public String firstName, lastName; + + public long getPersonNo() { + return personNo; + } + + public Date getBirthDate() { + return birthDate; + } + + public String getFirstName() { + return firstName; + } + + public String getLastName() { + return lastName; + } + + @Override + public boolean equals(final Object o) { + return PersonEqualsHashCode.equals(this, o); + } + + @Override + public int hashCode() { + return PersonEqualsHashCode.hashCode(this); + } + + @Override + public String toString() { + return this.getClass().getSimpleName()+"{" + + "personNo=" + personNo + + ", birthDate=" + birthDate + + ", firstName='" + firstName + '\'' + + ", lastName='" + lastName + '\'' + + '}'; + } +} diff --git a/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOAnyBean.java b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOAnyBean.java index 64b81f1..6ab0d5b 100644 --- a/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOAnyBean.java +++ b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOAnyBean.java @@ -396,6 +396,30 @@ com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.mopari } } + @Override + public com.moparisthebest.jdbc.dto.TypeUsePerson getTypeUsePerson(final long personNo, final java.util.Calendar cal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no, first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.TypeUsePerson ret = new com.moparisthebest.jdbc.dto.TypeUsePerson(); +ret.personNo = rs.getLong(1); +ret.firstName = rs.getString(2); +ret.lastName = rs.getString(3); +ret.birthDate = com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4, cal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + @Override public java.util.List getPeople(final java.lang.String lastName) throws java.sql.SQLException { PreparedStatement ps = null; diff --git a/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOBean.java b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOBean.java index 2602e2d..f5e1381 100644 --- a/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOBean.java +++ b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOBean.java @@ -396,6 +396,30 @@ com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.mopari } } + @Override + public com.moparisthebest.jdbc.dto.TypeUsePerson getTypeUsePerson(final long personNo, final java.util.Calendar cal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no, first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.TypeUsePerson ret = new com.moparisthebest.jdbc.dto.TypeUsePerson(); +ret.personNo = rs.getLong(1); +ret.firstName = rs.getString(2); +ret.lastName = rs.getString(3); +ret.birthDate = com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4, cal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + @Override public java.util.List getPeople(final java.lang.String lastName) throws java.sql.SQLException { PreparedStatement ps = null; diff --git a/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOBindBean.java b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOBindBean.java index d9b9436..c311a22 100644 --- a/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOBindBean.java +++ b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOBindBean.java @@ -396,6 +396,30 @@ com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.mopari } } + @Override + public com.moparisthebest.jdbc.dto.TypeUsePerson getTypeUsePerson(final long personNo, final java.util.Calendar cal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no, first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.TypeUsePerson ret = new com.moparisthebest.jdbc.dto.TypeUsePerson(); +ret.personNo = rs.getLong(1); +ret.firstName = rs.getString(2); +ret.lastName = rs.getString(3); +ret.birthDate = com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4, cal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + @Override public java.util.List getPeople(final java.lang.String lastName) throws java.sql.SQLException { PreparedStatement ps = null; diff --git a/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOOracleBean.java b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOOracleBean.java index 53e8a2b..5e69021 100644 --- a/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOOracleBean.java +++ b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOOracleBean.java @@ -396,6 +396,30 @@ com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.mopari } } + @Override + public com.moparisthebest.jdbc.dto.TypeUsePerson getTypeUsePerson(final long personNo, final java.util.Calendar cal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no, first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.TypeUsePerson ret = new com.moparisthebest.jdbc.dto.TypeUsePerson(); +ret.personNo = rs.getLong(1); +ret.firstName = rs.getString(2); +ret.lastName = rs.getString(3); +ret.birthDate = com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4, cal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + @Override public java.util.List getPeople(final java.lang.String lastName) throws java.sql.SQLException { PreparedStatement ps = null; diff --git a/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOUnNestBean.java b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOUnNestBean.java index 5171205..0bd7350 100644 --- a/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOUnNestBean.java +++ b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOUnNestBean.java @@ -396,6 +396,30 @@ com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.mopari } } + @Override + public com.moparisthebest.jdbc.dto.TypeUsePerson getTypeUsePerson(final long personNo, final java.util.Calendar cal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no, first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.TypeUsePerson ret = new com.moparisthebest.jdbc.dto.TypeUsePerson(); +ret.personNo = rs.getLong(1); +ret.firstName = rs.getString(2); +ret.lastName = rs.getString(3); +ret.birthDate = com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4, cal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + @Override public java.util.List getPeople(final java.lang.String lastName) throws java.sql.SQLException { PreparedStatement ps = null; diff --git a/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/PersonDAOAnyBean.java b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/PersonDAOAnyBean.java index 5bfb1fa..720adb3 100644 --- a/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/PersonDAOAnyBean.java +++ b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/PersonDAOAnyBean.java @@ -396,6 +396,30 @@ com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.mopari } } + @Override + public com.moparisthebest.jdbc.dto.TypeUsePerson getTypeUsePerson(final long personNo, final java.util.Calendar cal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no, first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.TypeUsePerson ret = new com.moparisthebest.jdbc.dto.TypeUsePerson(); +ret.personNo = rs.getLong(1); +ret.firstName = rs.getString(2); +ret.lastName = rs.getString(3); +ret.birthDate = com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4, cal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + @Override public java.util.List getPeople(final java.lang.String lastName) throws java.sql.SQLException { PreparedStatement ps = null; diff --git a/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/PersonDAOBean.java b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/PersonDAOBean.java index 0b2b2b5..570926b 100644 --- a/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/PersonDAOBean.java +++ b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/PersonDAOBean.java @@ -396,6 +396,30 @@ com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.mopari } } + @Override + public com.moparisthebest.jdbc.dto.TypeUsePerson getTypeUsePerson(final long personNo, final java.util.Calendar cal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no, first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.TypeUsePerson ret = new com.moparisthebest.jdbc.dto.TypeUsePerson(); +ret.personNo = rs.getLong(1); +ret.firstName = rs.getString(2); +ret.lastName = rs.getString(3); +ret.birthDate = com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4, cal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + @Override public java.util.List getPeople(final java.lang.String lastName) throws java.sql.SQLException { PreparedStatement ps = null; diff --git a/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/PersonDAOBindBean.java b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/PersonDAOBindBean.java index da2d99a..7cb99ea 100644 --- a/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/PersonDAOBindBean.java +++ b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/PersonDAOBindBean.java @@ -396,6 +396,30 @@ com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.mopari } } + @Override + public com.moparisthebest.jdbc.dto.TypeUsePerson getTypeUsePerson(final long personNo, final java.util.Calendar cal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no, first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.TypeUsePerson ret = new com.moparisthebest.jdbc.dto.TypeUsePerson(); +ret.personNo = rs.getLong(1); +ret.firstName = rs.getString(2); +ret.lastName = rs.getString(3); +ret.birthDate = com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4, cal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + @Override public java.util.List getPeople(final java.lang.String lastName) throws java.sql.SQLException { PreparedStatement ps = null; diff --git a/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/PersonDAOOracleBean.java b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/PersonDAOOracleBean.java index 90072cd..b563e40 100644 --- a/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/PersonDAOOracleBean.java +++ b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/PersonDAOOracleBean.java @@ -396,6 +396,30 @@ com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.mopari } } + @Override + public com.moparisthebest.jdbc.dto.TypeUsePerson getTypeUsePerson(final long personNo, final java.util.Calendar cal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no, first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.TypeUsePerson ret = new com.moparisthebest.jdbc.dto.TypeUsePerson(); +ret.personNo = rs.getLong(1); +ret.firstName = rs.getString(2); +ret.lastName = rs.getString(3); +ret.birthDate = com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4, cal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + @Override public java.util.List getPeople(final java.lang.String lastName) throws java.sql.SQLException { PreparedStatement ps = null; diff --git a/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/PersonDAOUnNestBean.java b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/PersonDAOUnNestBean.java index 3149846..5cfae41 100644 --- a/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/PersonDAOUnNestBean.java +++ b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/PersonDAOUnNestBean.java @@ -396,6 +396,30 @@ com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.mopari } } + @Override + public com.moparisthebest.jdbc.dto.TypeUsePerson getTypeUsePerson(final long personNo, final java.util.Calendar cal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no, first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.TypeUsePerson ret = new com.moparisthebest.jdbc.dto.TypeUsePerson(); +ret.personNo = rs.getLong(1); +ret.firstName = rs.getString(2); +ret.lastName = rs.getString(3); +ret.birthDate = com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4, cal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + @Override public java.util.List getPeople(final java.lang.String lastName) throws java.sql.SQLException { PreparedStatement ps = null;