From 46a37f657150c8be3bac982c3d5eb82c8b456867 Mon Sep 17 00:00:00 2001 From: moparisthebest Date: Sat, 9 Feb 2019 23:37:17 -0500 Subject: [PATCH] Implement snapshot tests for generated code --- .travis.yml | 6 +- test/runSnapshotTests.sh | 18 + .../jdbc/codegen/SnapshotTest.java | 97 + .../jdbc/codegen/AbstractDaoAnyBean.java | 79 + .../jdbc/codegen/AbstractDaoBean.java | 79 + .../jdbc/codegen/AbstractDaoBindBean.java | 79 + .../jdbc/codegen/AbstractDaoOracleBean.java | 79 + .../jdbc/codegen/AbstractDaoUnNestBean.java | 79 + .../codegen/CleaningPersonDaoAnyBean.java | 54 + .../jdbc/codegen/CleaningPersonDaoBean.java | 54 + .../codegen/CleaningPersonDaoBindBean.java | 54 + .../codegen/CleaningPersonDaoOracleBean.java | 54 + .../codegen/CleaningPersonDaoUnNestBean.java | 54 + .../jdbc/codegen/PersonDAOAnyBean.java | 2013 +++++++++++++++++ .../jdbc/codegen/PersonDAOBean.java | 2013 +++++++++++++++++ .../jdbc/codegen/PersonDAOBindBean.java | 2013 +++++++++++++++++ .../jdbc/codegen/PersonDAOOracleBean.java | 2013 +++++++++++++++++ .../jdbc/codegen/PersonDAOUnNestBean.java | 2013 +++++++++++++++++ .../jdbc/codegen/QmDaoAnyBean.java | 1604 +++++++++++++ .../jdbc/codegen/QmDaoBean.java | 1602 +++++++++++++ .../jdbc/codegen/QmDaoBindBean.java | 1602 +++++++++++++ .../jdbc/codegen/QmDaoOracleBean.java | 1604 +++++++++++++ .../jdbc/codegen/QmDaoUnNestBean.java | 1604 +++++++++++++ .../jdbc/codegen/AbstractDaoAnyBean.java | 74 + .../jdbc/codegen/AbstractDaoBean.java | 74 + .../jdbc/codegen/AbstractDaoBindBean.java | 74 + .../jdbc/codegen/AbstractDaoOracleBean.java | 74 + .../jdbc/codegen/AbstractDaoUnNestBean.java | 74 + .../codegen/CleaningPersonDaoAnyBean.java | 54 + .../jdbc/codegen/CleaningPersonDaoBean.java | 54 + .../codegen/CleaningPersonDaoBindBean.java | 54 + .../codegen/CleaningPersonDaoOracleBean.java | 54 + .../codegen/CleaningPersonDaoUnNestBean.java | 54 + .../jdbc/codegen/PersonDAOAnyBean.java | 1652 ++++++++++++++ .../jdbc/codegen/PersonDAOBean.java | 1652 ++++++++++++++ .../jdbc/codegen/PersonDAOBindBean.java | 1652 ++++++++++++++ .../jdbc/codegen/PersonDAOOracleBean.java | 1652 ++++++++++++++ .../jdbc/codegen/PersonDAOUnNestBean.java | 1652 ++++++++++++++ .../jdbc/codegen/QmDaoAnyBean.java | 1321 +++++++++++ .../jdbc/codegen/QmDaoBean.java | 1319 +++++++++++ .../jdbc/codegen/QmDaoBindBean.java | 1319 +++++++++++ .../jdbc/codegen/QmDaoOracleBean.java | 1321 +++++++++++ .../jdbc/codegen/QmDaoUnNestBean.java | 1321 +++++++++++ 43 files changed, 34365 insertions(+), 3 deletions(-) create mode 100755 test/runSnapshotTests.sh create mode 100644 test/src/test/java/com/moparisthebest/jdbc/codegen/SnapshotTest.java create mode 100644 test/src/test/snapshot/com/moparisthebest/jdbc/codegen/AbstractDaoAnyBean.java create mode 100644 test/src/test/snapshot/com/moparisthebest/jdbc/codegen/AbstractDaoBean.java create mode 100644 test/src/test/snapshot/com/moparisthebest/jdbc/codegen/AbstractDaoBindBean.java create mode 100644 test/src/test/snapshot/com/moparisthebest/jdbc/codegen/AbstractDaoOracleBean.java create mode 100644 test/src/test/snapshot/com/moparisthebest/jdbc/codegen/AbstractDaoUnNestBean.java create mode 100644 test/src/test/snapshot/com/moparisthebest/jdbc/codegen/CleaningPersonDaoAnyBean.java create mode 100644 test/src/test/snapshot/com/moparisthebest/jdbc/codegen/CleaningPersonDaoBean.java create mode 100644 test/src/test/snapshot/com/moparisthebest/jdbc/codegen/CleaningPersonDaoBindBean.java create mode 100644 test/src/test/snapshot/com/moparisthebest/jdbc/codegen/CleaningPersonDaoOracleBean.java create mode 100644 test/src/test/snapshot/com/moparisthebest/jdbc/codegen/CleaningPersonDaoUnNestBean.java create mode 100644 test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOAnyBean.java create mode 100644 test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOBean.java create mode 100644 test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOBindBean.java create mode 100644 test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOOracleBean.java create mode 100644 test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOUnNestBean.java create mode 100644 test/src/test/snapshot/com/moparisthebest/jdbc/codegen/QmDaoAnyBean.java create mode 100644 test/src/test/snapshot/com/moparisthebest/jdbc/codegen/QmDaoBean.java create mode 100644 test/src/test/snapshot/com/moparisthebest/jdbc/codegen/QmDaoBindBean.java create mode 100644 test/src/test/snapshot/com/moparisthebest/jdbc/codegen/QmDaoOracleBean.java create mode 100644 test/src/test/snapshot/com/moparisthebest/jdbc/codegen/QmDaoUnNestBean.java create mode 100644 test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/AbstractDaoAnyBean.java create mode 100644 test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/AbstractDaoBean.java create mode 100644 test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/AbstractDaoBindBean.java create mode 100644 test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/AbstractDaoOracleBean.java create mode 100644 test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/AbstractDaoUnNestBean.java create mode 100644 test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/CleaningPersonDaoAnyBean.java create mode 100644 test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/CleaningPersonDaoBean.java create mode 100644 test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/CleaningPersonDaoBindBean.java create mode 100644 test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/CleaningPersonDaoOracleBean.java create mode 100644 test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/CleaningPersonDaoUnNestBean.java create mode 100644 test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/PersonDAOAnyBean.java create mode 100644 test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/PersonDAOBean.java create mode 100644 test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/PersonDAOBindBean.java create mode 100644 test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/PersonDAOOracleBean.java create mode 100644 test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/PersonDAOUnNestBean.java create mode 100644 test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/QmDaoAnyBean.java create mode 100644 test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/QmDaoBean.java create mode 100644 test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/QmDaoBindBean.java create mode 100644 test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/QmDaoOracleBean.java create mode 100644 test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/QmDaoUnNestBean.java diff --git a/.travis.yml b/.travis.yml index 6e9905c..730eb21 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,7 +32,7 @@ before_script: script: - docker ps -a # java8+ supports everything - - mvn -B -pl '!test' clean install || travis_terminate 1; + - ./test/runSnapshotTests.sh || travis_terminate 1; # everything against BIND - mvn -B -pl test clean test -DjdbcMapper.databaseType=BIND --settings .travis-settings.xml -P oracle '-DjdbcUrl1=jdbc:postgresql:test_db' '-DjdbcUrl2=jdbc:mariadb://127.0.0.1:3306/test_db?user=root' '-DjdbcUrl3=jdbc:oracle:thin:travis_test/travis_test@127.0.0.1:1521/xe' '-DjdbcUrl4=jdbc:sqlserver://localhost:1433;databaseName=master;username=sa;password=;' || travis_terminate 1; # everything against BIND jdbcMapper, but OPTIMAL queryMapper @@ -55,7 +55,7 @@ matrix: script: # java6 doesn't support ms-sql at all, and doesn't support h2 with ANY - .travis/dl_java6_maven.sh - - mvn --offline -B -pl '!test' clean install || travis_terminate 1; + - ./test/runSnapshotTests.sh --offline || travis_terminate 1; - mvn --offline -B -pl test clean test -DjdbcMapper.databaseType=BIND --settings .travis-settings.xml -P oracle '-DjdbcUrl1=jdbc:postgresql:test_db' '-DjdbcUrl2=jdbc:mariadb://127.0.0.1:3306/test_db?user=root' '-DjdbcUrl3=jdbc:oracle:thin:travis_test/travis_test@127.0.0.1:1521/xe' || travis_terminate 1; - mvn --offline -B -pl test clean test -DjdbcMapper.databaseType=BIND -DqueryMapper.databaseType=OPTIMAL --settings .travis-settings.xml -P oracle '-DjdbcUrl1=jdbc:postgresql:test_db' '-DjdbcUrl2=jdbc:mariadb://127.0.0.1:3306/test_db?user=root' '-DjdbcUrl3=jdbc:oracle:thin:travis_test/travis_test@127.0.0.1:1521/xe' || travis_terminate 1; - mvn --offline -B -pl test clean test -DjdbcMapper.databaseType=ANY '-DjdbcUrl=jdbc:postgresql:test_db' || travis_terminate 1; @@ -65,7 +65,7 @@ matrix: jdk: openjdk7 script: # java7 doesn't support h2 with ANY - - mvn -B -pl '!test' clean install || travis_terminate 1; + - ./test/runSnapshotTests.sh || travis_terminate 1; - mvn -B -pl test clean test -DjdbcMapper.databaseType=BIND --settings .travis-settings.xml -P oracle '-DjdbcUrl1=jdbc:postgresql:test_db' '-DjdbcUrl2=jdbc:mariadb://127.0.0.1:3306/test_db?user=root' '-DjdbcUrl3=jdbc:oracle:thin:travis_test/travis_test@127.0.0.1:1521/xe' '-DjdbcUrl4=jdbc:sqlserver://localhost:1433;databaseName=master;username=sa;password=;' || travis_terminate 1; - mvn -B -pl test clean test -DjdbcMapper.databaseType=BIND -DqueryMapper.databaseType=OPTIMAL --settings .travis-settings.xml -P oracle '-DjdbcUrl1=jdbc:postgresql:test_db' '-DjdbcUrl2=jdbc:mariadb://127.0.0.1:3306/test_db?user=root' '-DjdbcUrl3=jdbc:oracle:thin:travis_test/travis_test@127.0.0.1:1521/xe' '-DjdbcUrl4=jdbc:sqlserver://localhost:1433;databaseName=master;username=sa;password=;' || travis_terminate 1; - mvn -B -pl test clean test -DjdbcMapper.databaseType=ANY '-DjdbcUrl=jdbc:postgresql:test_db' || travis_terminate 1; diff --git a/test/runSnapshotTests.sh b/test/runSnapshotTests.sh new file mode 100755 index 0000000..27ca08c --- /dev/null +++ b/test/runSnapshotTests.sh @@ -0,0 +1,18 @@ +#!/bin/sh +set -e + +updateSnapshots=false +if [ "$1" == "--update" ] +then + updateSnapshots=true + shift +fi + +mvn="mvn -B -pl test clean test -Dtest=SnapshotTest -DupdateSnapshots=$updateSnapshots" + +mvn "$@" -B -pl '!test' clean install +$mvn "$@" -DJdbcMapper.beanSuffix=Bean +$mvn "$@" -DjdbcMapper.databaseType=BIND -DJdbcMapper.beanSuffix=BindBean +$mvn "$@" -DjdbcMapper.databaseType=ANY -DJdbcMapper.beanSuffix=AnyBean +$mvn "$@" -DjdbcMapper.databaseType=UNNEST -DJdbcMapper.beanSuffix=UnNestBean +$mvn "$@" -DjdbcMapper.databaseType=ORACLE -P oracle -DJdbcMapper.beanSuffix=OracleBean diff --git a/test/src/test/java/com/moparisthebest/jdbc/codegen/SnapshotTest.java b/test/src/test/java/com/moparisthebest/jdbc/codegen/SnapshotTest.java new file mode 100644 index 0000000..8bb0b75 --- /dev/null +++ b/test/src/test/java/com/moparisthebest/jdbc/codegen/SnapshotTest.java @@ -0,0 +1,97 @@ +package com.moparisthebest.jdbc.codegen; + +import org.junit.Test; + +import java.io.File; +import java.io.IOException; +import java.io.RandomAccessFile; +import java.nio.charset.Charset; + +import static com.moparisthebest.jdbc.TryClose.tryClose; +import static org.junit.Assert.assertEquals; + +public class SnapshotTest { + + // we want to only run this when explicitly asked to by runSnapshotTests.sh, which carefully exercises all options + private final static boolean skipSnapshotTest = !"SnapshotTest".equals(System.getProperty("test")); + private final static boolean updateSnapshots = Boolean.parseBoolean(System.getProperty("updateSnapshots", "false")); + + //IFJAVA8_START + private static final String snapshotPrefix = "src/test/snapshot/"; + //IFJAVA8_END + + /*IFJAVA6_START + private static final String snapshotPrefix = "src/test/snapshot/jdk6/"; + IFJAVA6_END*/ + + @Test + public void testAbstractDao() throws IOException { + testFile(AbstractDao.class); + } + + @Test + public void testCleaningPersonDao() throws IOException { + testFile(CleaningPersonDao.class); + } + + @Test + public void testPersonDAO() throws IOException { + testFile(PersonDAO.class); + } + + @Test + public void testQmDao() throws IOException { + testFile(QmDao.class); + } + + static void testFile(final Class testClass) throws IOException { + testFile(testClass.getName()); + } + + static void testFile(final String className) throws IOException { + if(skipSnapshotTest) + return; // skip + final String javaName = className.replace('.', '/') + JdbcMapper.beanSuffix + ".java"; + final String snapshotName = snapshotPrefix + javaName; + final String generatedName = "target/generated-sources/annotations/" + javaName; + if (updateSnapshots) { + final byte[] generatedBytes = readAllBytes(generatedName); + writeFile(snapshotName, generatedBytes); + } else { + final String snapshotContents = readUtf8File(snapshotName); + final String generatedContents = readUtf8File(generatedName); + assertEquals(snapshotContents, generatedContents); + } + } + + static void writeFile(final String fileName, final byte[] bytes) throws IOException { + RandomAccessFile f = null; + try { + final File fileToWrite = new File(fileName); + fileToWrite.getParentFile().mkdirs(); + f = new RandomAccessFile(fileToWrite, "rw"); + f.write(bytes); + f.setLength(bytes.length); + } finally { + tryClose(f); + } + } + + static byte[] readAllBytes(final String fileName) throws IOException { + RandomAccessFile f = null; + try { + f = new RandomAccessFile(fileName, "r"); + final byte[] ret = new byte[(int) f.length()]; + f.readFully(ret); + return ret; + } finally { + tryClose(f); + } + } + + private static final Charset UTF_8 = Charset.forName("UTF-8"); + + static String readUtf8File(final String fileName) throws IOException { + return new String(readAllBytes(fileName), UTF_8); + } +} diff --git a/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/AbstractDaoAnyBean.java b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/AbstractDaoAnyBean.java new file mode 100644 index 0000000..5161593 --- /dev/null +++ b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/AbstractDaoAnyBean.java @@ -0,0 +1,79 @@ +package com.moparisthebest.jdbc.codegen; + +import com.moparisthebest.jdbc.Factory; + +import java.sql.*; + +import static com.moparisthebest.jdbc.util.ResultSetUtil.*; +import static com.moparisthebest.jdbc.TryClose.tryClose; + +public class AbstractDaoAnyBean extends AbstractDao { + + private final Connection conn; + private final boolean closeConn; + + + private AbstractDaoAnyBean(final Connection conn, final boolean closeConn) { + this.conn = conn; + this.closeConn = closeConn; + if (this.conn == null) + throw new NullPointerException("Connection needs to be non-null for JdbcMapper..."); + } + + public AbstractDaoAnyBean(Connection conn) { + this(conn, false); + } + + public Connection getConnection() { + return this.conn; + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPerson(final long personNo) 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public long getPersonNo(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + if(rs.next()) { +final long ret = rs.getLong(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.Person getPersonInTransaction(final java.lang.String lastName) throws java.sql.SQLException { + return com.moparisthebest.jdbc.QueryRunner.runConnectionInTransaction(this.conn, dao -> super.getPersonInTransaction(lastName)); + } +} diff --git a/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/AbstractDaoBean.java b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/AbstractDaoBean.java new file mode 100644 index 0000000..2b22b12 --- /dev/null +++ b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/AbstractDaoBean.java @@ -0,0 +1,79 @@ +package com.moparisthebest.jdbc.codegen; + +import com.moparisthebest.jdbc.Factory; + +import java.sql.*; + +import static com.moparisthebest.jdbc.util.ResultSetUtil.*; +import static com.moparisthebest.jdbc.TryClose.tryClose; + +public class AbstractDaoBean extends AbstractDao { + + private final Connection conn; + private final boolean closeConn; + + + private AbstractDaoBean(final Connection conn, final boolean closeConn) { + this.conn = conn; + this.closeConn = closeConn; + if (this.conn == null) + throw new NullPointerException("Connection needs to be non-null for JdbcMapper..."); + } + + public AbstractDaoBean(Connection conn) { + this(conn, false); + } + + public Connection getConnection() { + return this.conn; + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPerson(final long personNo) 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public long getPersonNo(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + if(rs.next()) { +final long ret = rs.getLong(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.Person getPersonInTransaction(final java.lang.String lastName) throws java.sql.SQLException { + return com.moparisthebest.jdbc.QueryRunner.runConnectionInTransaction(this.conn, dao -> super.getPersonInTransaction(lastName)); + } +} diff --git a/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/AbstractDaoBindBean.java b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/AbstractDaoBindBean.java new file mode 100644 index 0000000..49ad627 --- /dev/null +++ b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/AbstractDaoBindBean.java @@ -0,0 +1,79 @@ +package com.moparisthebest.jdbc.codegen; + +import com.moparisthebest.jdbc.Factory; + +import java.sql.*; + +import static com.moparisthebest.jdbc.util.ResultSetUtil.*; +import static com.moparisthebest.jdbc.TryClose.tryClose; + +public class AbstractDaoBindBean extends AbstractDao { + + private final Connection conn; + private final boolean closeConn; + + + private AbstractDaoBindBean(final Connection conn, final boolean closeConn) { + this.conn = conn; + this.closeConn = closeConn; + if (this.conn == null) + throw new NullPointerException("Connection needs to be non-null for JdbcMapper..."); + } + + public AbstractDaoBindBean(Connection conn) { + this(conn, false); + } + + public Connection getConnection() { + return this.conn; + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPerson(final long personNo) 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public long getPersonNo(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + if(rs.next()) { +final long ret = rs.getLong(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.Person getPersonInTransaction(final java.lang.String lastName) throws java.sql.SQLException { + return com.moparisthebest.jdbc.QueryRunner.runConnectionInTransaction(this.conn, dao -> super.getPersonInTransaction(lastName)); + } +} diff --git a/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/AbstractDaoOracleBean.java b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/AbstractDaoOracleBean.java new file mode 100644 index 0000000..60bb696 --- /dev/null +++ b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/AbstractDaoOracleBean.java @@ -0,0 +1,79 @@ +package com.moparisthebest.jdbc.codegen; + +import com.moparisthebest.jdbc.Factory; + +import java.sql.*; + +import static com.moparisthebest.jdbc.util.ResultSetUtil.*; +import static com.moparisthebest.jdbc.TryClose.tryClose; + +public class AbstractDaoOracleBean extends AbstractDao { + + private final Connection conn; + private final boolean closeConn; + + + private AbstractDaoOracleBean(final Connection conn, final boolean closeConn) { + this.conn = conn; + this.closeConn = closeConn; + if (this.conn == null) + throw new NullPointerException("Connection needs to be non-null for JdbcMapper..."); + } + + public AbstractDaoOracleBean(Connection conn) { + this(conn, false); + } + + public Connection getConnection() { + return this.conn; + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPerson(final long personNo) 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public long getPersonNo(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + if(rs.next()) { +final long ret = rs.getLong(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.Person getPersonInTransaction(final java.lang.String lastName) throws java.sql.SQLException { + return com.moparisthebest.jdbc.QueryRunner.runConnectionInTransaction(this.conn, dao -> super.getPersonInTransaction(lastName)); + } +} diff --git a/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/AbstractDaoUnNestBean.java b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/AbstractDaoUnNestBean.java new file mode 100644 index 0000000..8e50781 --- /dev/null +++ b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/AbstractDaoUnNestBean.java @@ -0,0 +1,79 @@ +package com.moparisthebest.jdbc.codegen; + +import com.moparisthebest.jdbc.Factory; + +import java.sql.*; + +import static com.moparisthebest.jdbc.util.ResultSetUtil.*; +import static com.moparisthebest.jdbc.TryClose.tryClose; + +public class AbstractDaoUnNestBean extends AbstractDao { + + private final Connection conn; + private final boolean closeConn; + + + private AbstractDaoUnNestBean(final Connection conn, final boolean closeConn) { + this.conn = conn; + this.closeConn = closeConn; + if (this.conn == null) + throw new NullPointerException("Connection needs to be non-null for JdbcMapper..."); + } + + public AbstractDaoUnNestBean(Connection conn) { + this(conn, false); + } + + public Connection getConnection() { + return this.conn; + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPerson(final long personNo) 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public long getPersonNo(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + if(rs.next()) { +final long ret = rs.getLong(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.Person getPersonInTransaction(final java.lang.String lastName) throws java.sql.SQLException { + return com.moparisthebest.jdbc.QueryRunner.runConnectionInTransaction(this.conn, dao -> super.getPersonInTransaction(lastName)); + } +} diff --git a/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/CleaningPersonDaoAnyBean.java b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/CleaningPersonDaoAnyBean.java new file mode 100644 index 0000000..9b77f2a --- /dev/null +++ b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/CleaningPersonDaoAnyBean.java @@ -0,0 +1,54 @@ +package com.moparisthebest.jdbc.codegen; + +import com.moparisthebest.jdbc.Factory; + +import java.sql.*; + +import static com.moparisthebest.jdbc.util.ResultSetUtil.*; +import static com.moparisthebest.jdbc.TryClose.tryClose; + +public class CleaningPersonDaoAnyBean implements CleaningPersonDao { + + private final Connection conn; + private final boolean closeConn; + + + private CleaningPersonDaoAnyBean(final Connection conn, final boolean closeConn) { + this.conn = conn; + this.closeConn = closeConn; + if (this.conn == null) + throw new NullPointerException("Connection needs to be non-null for JdbcMapper..."); + } + + public CleaningPersonDaoAnyBean(Connection conn) { + this(conn, false); + } + + public Connection getConnection() { + return this.conn; + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPerson(final long personNo, final com.moparisthebest.jdbc.Cleaner personCleaner) 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return personCleaner == null ? ret : personCleaner.clean(ret); + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } +} diff --git a/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/CleaningPersonDaoBean.java b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/CleaningPersonDaoBean.java new file mode 100644 index 0000000..951636c --- /dev/null +++ b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/CleaningPersonDaoBean.java @@ -0,0 +1,54 @@ +package com.moparisthebest.jdbc.codegen; + +import com.moparisthebest.jdbc.Factory; + +import java.sql.*; + +import static com.moparisthebest.jdbc.util.ResultSetUtil.*; +import static com.moparisthebest.jdbc.TryClose.tryClose; + +public class CleaningPersonDaoBean implements CleaningPersonDao { + + private final Connection conn; + private final boolean closeConn; + + + private CleaningPersonDaoBean(final Connection conn, final boolean closeConn) { + this.conn = conn; + this.closeConn = closeConn; + if (this.conn == null) + throw new NullPointerException("Connection needs to be non-null for JdbcMapper..."); + } + + public CleaningPersonDaoBean(Connection conn) { + this(conn, false); + } + + public Connection getConnection() { + return this.conn; + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPerson(final long personNo, final com.moparisthebest.jdbc.Cleaner personCleaner) 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return personCleaner == null ? ret : personCleaner.clean(ret); + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } +} diff --git a/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/CleaningPersonDaoBindBean.java b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/CleaningPersonDaoBindBean.java new file mode 100644 index 0000000..4f34f3e --- /dev/null +++ b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/CleaningPersonDaoBindBean.java @@ -0,0 +1,54 @@ +package com.moparisthebest.jdbc.codegen; + +import com.moparisthebest.jdbc.Factory; + +import java.sql.*; + +import static com.moparisthebest.jdbc.util.ResultSetUtil.*; +import static com.moparisthebest.jdbc.TryClose.tryClose; + +public class CleaningPersonDaoBindBean implements CleaningPersonDao { + + private final Connection conn; + private final boolean closeConn; + + + private CleaningPersonDaoBindBean(final Connection conn, final boolean closeConn) { + this.conn = conn; + this.closeConn = closeConn; + if (this.conn == null) + throw new NullPointerException("Connection needs to be non-null for JdbcMapper..."); + } + + public CleaningPersonDaoBindBean(Connection conn) { + this(conn, false); + } + + public Connection getConnection() { + return this.conn; + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPerson(final long personNo, final com.moparisthebest.jdbc.Cleaner personCleaner) 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return personCleaner == null ? ret : personCleaner.clean(ret); + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } +} diff --git a/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/CleaningPersonDaoOracleBean.java b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/CleaningPersonDaoOracleBean.java new file mode 100644 index 0000000..08bab04 --- /dev/null +++ b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/CleaningPersonDaoOracleBean.java @@ -0,0 +1,54 @@ +package com.moparisthebest.jdbc.codegen; + +import com.moparisthebest.jdbc.Factory; + +import java.sql.*; + +import static com.moparisthebest.jdbc.util.ResultSetUtil.*; +import static com.moparisthebest.jdbc.TryClose.tryClose; + +public class CleaningPersonDaoOracleBean implements CleaningPersonDao { + + private final Connection conn; + private final boolean closeConn; + + + private CleaningPersonDaoOracleBean(final Connection conn, final boolean closeConn) { + this.conn = conn; + this.closeConn = closeConn; + if (this.conn == null) + throw new NullPointerException("Connection needs to be non-null for JdbcMapper..."); + } + + public CleaningPersonDaoOracleBean(Connection conn) { + this(conn, false); + } + + public Connection getConnection() { + return this.conn; + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPerson(final long personNo, final com.moparisthebest.jdbc.Cleaner personCleaner) 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return personCleaner == null ? ret : personCleaner.clean(ret); + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } +} diff --git a/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/CleaningPersonDaoUnNestBean.java b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/CleaningPersonDaoUnNestBean.java new file mode 100644 index 0000000..497bb52 --- /dev/null +++ b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/CleaningPersonDaoUnNestBean.java @@ -0,0 +1,54 @@ +package com.moparisthebest.jdbc.codegen; + +import com.moparisthebest.jdbc.Factory; + +import java.sql.*; + +import static com.moparisthebest.jdbc.util.ResultSetUtil.*; +import static com.moparisthebest.jdbc.TryClose.tryClose; + +public class CleaningPersonDaoUnNestBean implements CleaningPersonDao { + + private final Connection conn; + private final boolean closeConn; + + + private CleaningPersonDaoUnNestBean(final Connection conn, final boolean closeConn) { + this.conn = conn; + this.closeConn = closeConn; + if (this.conn == null) + throw new NullPointerException("Connection needs to be non-null for JdbcMapper..."); + } + + public CleaningPersonDaoUnNestBean(Connection conn) { + this(conn, false); + } + + public Connection getConnection() { + return this.conn; + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPerson(final long personNo, final com.moparisthebest.jdbc.Cleaner personCleaner) 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return personCleaner == null ? ret : personCleaner.clean(ret); + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } +} diff --git a/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOAnyBean.java b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOAnyBean.java new file mode 100644 index 0000000..45f7a57 --- /dev/null +++ b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOAnyBean.java @@ -0,0 +1,2013 @@ +package com.moparisthebest.jdbc.codegen; + +import com.moparisthebest.jdbc.util.SqlBuilder; +import com.moparisthebest.jdbc.Factory; + +import java.sql.*; + +import static com.moparisthebest.jdbc.util.ResultSetUtil.*; +import static com.moparisthebest.jdbc.TryClose.tryClose; + +public class PersonDAOAnyBean implements PersonDAO { + + private final Connection conn; + private final boolean closeConn; + + private static final Factory _conFactory = com.moparisthebest.jdbc.codegen.JdbcMapperFactory.connectionFactory("bob"); + + public PersonDAOAnyBean() throws SQLException { + this(_conFactory); + } + + private PersonDAOAnyBean(final Connection conn, final boolean closeConn) { + this.conn = conn; + this.closeConn = closeConn; + if (this.conn == null) + throw new NullPointerException("Connection needs to be non-null for JdbcMapper..."); + } + + public PersonDAOAnyBean(Connection conn) { + this(conn, false); + } + + public Connection getConnection() { + return this.conn; + } + + @Override + public void createTablePerson() { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("CREATE TABLE person (person_no NUMERIC, first_name VARCHAR(40), last_name VARCHAR(40), birth_date TIMESTAMP)"); + ps.executeUpdate(); + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public int insertPerson(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)"); + ps.setObject(1, personNo); + ps.setObject(2, birthDate == null ? null : new java.sql.Timestamp(birthDate.getTime())); + ps.setObject(3, firstName); + ps.setObject(4, lastName); + return ps.executeUpdate(); + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public long insertPersonGeneratedKey(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)", java.sql.Statement.RETURN_GENERATED_KEYS); + ps.setObject(1, personNo); + ps.setObject(2, birthDate == null ? null : new java.sql.Timestamp(birthDate.getTime())); + ps.setObject(3, firstName); + ps.setObject(4, lastName); + ps.executeUpdate(); + ResultSet rs = null; + try { + rs = ps.getGeneratedKeys(); + return rs.next() ? rs.getLong(1) : 0; + } finally { + tryClose(rs); + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public java.lang.Long insertPersonGeneratedKeyLong(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)", java.sql.Statement.RETURN_GENERATED_KEYS); + ps.setObject(1, personNo); + ps.setObject(2, birthDate == null ? null : new java.sql.Timestamp(birthDate.getTime())); + ps.setObject(3, firstName); + ps.setObject(4, lastName); + ps.executeUpdate(); + ResultSet rs = null; + try { + rs = ps.getGeneratedKeys(); + return rs.next() ? com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1) : null; + } finally { + tryClose(rs); + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public int setFirstName(final java.lang.String firstName, final java.lang.String lastName) { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE last_name = ?"); + ps.setObject(1, firstName); + ps.setObject(2, lastName); + return ps.executeUpdate(); + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public void setFirstName(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.setObject(1, firstName); + ps.setObject(2, personNo); + ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + @Override + public void setFirstNameBlob(final byte[] firstName, final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE person_no = ?"); + ps.setBlob(1, firstName == null ? null : new java.io.ByteArrayInputStream(firstName)); + ps.setObject(2, personNo); + ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + @Override + public void setFirstNameBlob(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-8"))); + } catch (java.io.UnsupportedEncodingException e) { + throw new SQLException("String to Blob UnsupportedEncodingException", e); + } + 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; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + if(rs.next()) { +final long ret = rs.getLong(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public long getPersonNoUnusedParam(final java.lang.String lastName, final java.lang.String _bla) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + if(rs.next()) { +final long ret = rs.getLong(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.ResultSet getPeopleResultSet(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + return new com.moparisthebest.jdbc.StatementClosingResultSet(rs, ps); + } catch(Throwable e) { + tryClose(rs); + tryClose(ps); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public java.sql.ResultSet getPeopleResultSetCached(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(0, "SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + return rs; + } catch(Throwable e) { + tryClose(rs); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public java.lang.String getFirstNameColumnNames(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.String ret = rs.getString(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.lang.String getFirstName(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.String ret = rs.getString(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public int getFirstNameUpdate(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + return ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPersonColumnNames(final long personNo) 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPerson(final long personNo) 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.BuilderPerson getBuilderPerson(final long personNo) 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.BuilderPerson ret = new com.moparisthebest.jdbc.dto.BuilderPerson(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPerson(final long personNo, final java.util.Calendar cal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3, 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; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeople(final java.lang.String[] lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("TEXT", lastName); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (NOT(last_name = ANY(?)))"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeople(final java.util.List lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("TEXT", lastName.toArray(new java.lang.String[lastName.size()])); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (last_name = ANY(?))"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson[] getPeopleArray(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret.toArray(new com.moparisthebest.jdbc.dto.FieldPerson[_colret.size()]); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Iterator getPeopleIterator(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret.iterator(); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.ListIterator getPeopleListIterator(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret.listIterator(); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonMap(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, rs.getLong(3)); + _colret.put(rs.getString(1), ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map> getPersonMapList(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.Map> _colret = new java.util.HashMap>(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, rs.getLong(3)); + final java.lang.String _colkey = rs.getString(1); + java.util.List _collist = _colret.get(_colkey); + if(_collist == null) { + _collist = new java.util.ArrayList(); + _colret.put(_colkey, _collist); + } + _collist.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.lang.String getFirstName(final long personNo, final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ? and last_name = ?"); + ps.setObject(1, personNo); + ps.setObject(2, lastName); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.String ret = rs.getString(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Calendar getBirthDateCalendar(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Calendar ret = com.moparisthebest.jdbc.util.ResultSetUtil.getCalendar(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Calendar getBirthDateCalendar(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Calendar ret = com.moparisthebest.jdbc.util.ResultSetUtil.getCalendar(rs, 1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Timestamp getBirthDateTimestamp(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Timestamp ret = rs.getTimestamp(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Timestamp getBirthDateTimestamp(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Timestamp ret = rs.getTimestamp(1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Time getBirthDateTime(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Time ret = rs.getTime(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Time getBirthDateTime(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Time ret = rs.getTime(1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Date getBirthDateSqlDate(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Date ret = rs.getDate(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Date getBirthDateSqlDate(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Date ret = rs.getDate(1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Date getBirthDateUtilDate(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Date ret = com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Date getBirthDateUtilDate(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Date ret = com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPersonCleanFieldPerson(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + return clean == null ? ret : clean.clean(ret); + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPersonCleanPerson(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + return clean == null ? ret : clean.clean(ret); + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPersonCleanObject(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + return clean == null ? ret : clean.clean(ret); + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPersonCleanPersonList(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.add(clean == null ? ret : clean.clean(ret)); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonCleanPersonMap(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.put(rs.getString(1), clean == null ? ret : clean.clean(ret)); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map> getPersonCleanPersonMapList(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + final java.util.Map> _colret = new java.util.HashMap>(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + final java.lang.String _colkey = rs.getString(1); + java.util.List _collist = _colret.get(_colkey); + if(_collist == null) { + _collist = new java.util.ArrayList(); + _colret.put(_colkey, _collist); + } + _collist.add(clean == null ? ret : clean.clean(ret)); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonDynamicLimit(final long personNo, final byte maxRows) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + byte _rowCount = 0; + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.put(rs.getString(1), ret); + if(maxRows > 0 && ++_rowCount == maxRows) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonDynamicLimit(final long personNo, final short arrayMaxLength) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + short _rowCount = 0; + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.put(rs.getString(1), ret); + if(arrayMaxLength > 0 && ++_rowCount == arrayMaxLength) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPersonDynamicLimit(final long personNo, final int maxRows) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + int _rowCount = 0; + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.add(ret); + if(maxRows > 0 && ++_rowCount == maxRows) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map> getPersonDynamicLimit(final long personNo, final long rowLimit) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + long _rowCount = 0; + final java.util.Map> _colret = new java.util.HashMap>(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + final java.lang.String _colkey = rs.getString(1); + java.util.List _collist = _colret.get(_colkey); + if(_collist == null) { + _collist = new java.util.ArrayList(); + _colret.put(_colkey, _collist); + } + _collist.add(ret); + if(rowLimit > 0 && ++_rowCount == rowLimit) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPersonStaticLimitListByte(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + byte _rowCount = 0; + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.add(ret); + if(++_rowCount == 127) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPersonStaticLimitList(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + short _rowCount = 0; + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.add(ret); + if(++_rowCount == 32767) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonStaticLimitMap(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + int _rowCount = 0; + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.put(rs.getString(1), ret); + if(++_rowCount == 2147483647) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map> getPersonStaticLimitMapList(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + long _rowCount = 0; + final java.util.Map> _colret = new java.util.HashMap>(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + final java.lang.String _colkey = rs.getString(1); + java.util.List _collist = _colret.get(_colkey); + if(_collist == null) { + _collist = new java.util.ArrayList(); + _colret.put(_colkey, _collist); + } + _collist.add(ret); + if(++_rowCount == 9223372036854775807L) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeopleList(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no, birth_date, last_name, first_name from person WHERE person_no IN (?,?,?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 2), +rs.getString(4), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.util.ResultSetIterable getPeopleResultSetIterable(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no, birth_date, last_name, first_name from person WHERE person_no IN (?,?,?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + return com.moparisthebest.jdbc.util.ResultSetIterable.getResultSetIterable(rs, + rs.next() ? (_rs, _cal) -> { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 2), +_rs.getString(4), +_rs.getString(3)); + return ret; + } + : null, null).setPreparedStatementToClose(ps); + } catch(Throwable e) { + tryClose(rs); + tryClose(ps); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public com.moparisthebest.jdbc.util.ResultSetIterable getPeopleResultSetIterableCachedPreparedStatement(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(1, "SELECT person_no, birth_date, last_name, first_name from person WHERE person_no IN (?,?,?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + return com.moparisthebest.jdbc.util.ResultSetIterable.getResultSetIterable(rs, + rs.next() ? (_rs, _cal) -> { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 2), +_rs.getString(4), +_rs.getString(3)); + return ret; + } + : null, null); + } catch(Throwable e) { + tryClose(rs); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public java.util.stream.Stream getPeopleStream(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no, birth_date, last_name, first_name from person WHERE person_no IN (?,?,?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + final PreparedStatement finalPs = ps; + return com.moparisthebest.jdbc.util.ResultSetIterable.getStream(rs, + rs.next() ? (_rs, _cal) -> { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 2), +_rs.getString(4), +_rs.getString(3)); + return ret; + } + : null, null).onClose(() -> tryClose(finalPs)); + } catch(Throwable e) { + tryClose(rs); + tryClose(ps); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public java.util.stream.Stream getPeopleStreamCachedPreparedStatement(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(2, "SELECT person_no, birth_date, last_name, first_name from person WHERE person_no IN (?,?,?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + return com.moparisthebest.jdbc.util.ResultSetIterable.getStream(rs, + rs.next() ? (_rs, _cal) -> { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 2), +_rs.getString(4), +_rs.getString(3)); + return ret; + } + : null, null); + } catch(Throwable e) { + tryClose(rs); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPersonConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson( +com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FirstName getFirstNameEnum(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPersonNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val as first_name, str_val as last_name FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FirstName getEnumNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.CaseSensitivePerson getCaseSensitivePerson(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name AS M_PERSON_FIRST_NAME FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.CaseSensitivePerson ret = new com.moparisthebest.jdbc.dto.CaseSensitivePerson(); +ret.setmPersonFirstName(rs.getString(1)); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson getSameClassPathEnumPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson ret = new com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson getSameClassPathEnumPersonConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson ret = new com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson( +com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName getSameClassPathFirstNameEnum(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson getSameClassPathEnumPersonNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val as first_name, str_val as last_name FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson ret = new com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName getSameClassPathEnumNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeopleInListArray(final java.lang.Long[] personNos) { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("NUMERIC", personNos); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (person_no = ANY(?))"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeopleInListCollection(final java.util.Collection personNos) { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("NUMERIC", personNos.toArray(new java.lang.Long[personNos.size()])); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (person_no = ANY(?))"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.stream.Stream getPeopleInListStream(final java.util.stream.Stream personNos, final java.util.stream.Stream names) { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[2]; + try { + _bindArrays[0] = conn.createArrayOf("NUMERIC", personNos.toArray(java.lang.Long[]::new)); + _bindArrays[1] = conn.createArrayOf("TEXT", names.toArray(java.lang.String[]::new)); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (person_no = ANY(?)) OR (first_name = ANY(?)) OR (last_name = ANY(?))"); + ps.setArray(1, _bindArrays[0]); + ps.setArray(2, _bindArrays[1]); + ps.setArray(3, _bindArrays[1]); + rs = ps.executeQuery(); + final PreparedStatement finalPs = ps; + return com.moparisthebest.jdbc.util.ResultSetIterable.getStream(rs, + rs.next() ? (_rs, _cal) -> { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, _rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, _rs.getString(2)); + return ret; + } + : null, null).onClose(() -> tryClose(finalPs)); + } catch(Throwable e) { + tryClose(rs); + tryClose(ps); + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + } + } + + @Override + public java.time.Instant getBirthDateInstant(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.Instant ret = com.moparisthebest.jdbc.util.ResultSetUtil.getInstant(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.LocalDateTime getBirthDateLocalDateTime(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.LocalDateTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getLocalDateTime(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.LocalDate getBirthDateLocalDate(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.LocalDate ret = com.moparisthebest.jdbc.util.ResultSetUtil.getLocalDate(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.LocalTime getBirthDateLocalTime(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.LocalTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getLocalTime(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.ZonedDateTime getBirthDateZonedDateTime(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.ZonedDateTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getZonedDateTime(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.OffsetDateTime getBirthDateOffsetDateTime(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.OffsetDateTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getOffsetDateTime(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.OffsetTime getBirthDateZonedOffsetTime(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.OffsetTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getOffsetTime(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.Year getYearInt(final long valNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT num_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.Year ret = com.moparisthebest.jdbc.util.ResultSetUtil.getYear(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.Year getYearString(final long valNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.Year ret = com.moparisthebest.jdbc.util.ResultSetUtil.getYear(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.ZoneId getZoneId(final long valNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.ZoneId ret = com.moparisthebest.jdbc.util.ResultSetUtil.getZoneId(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.ZoneOffset getZoneOffsetInt(final long valNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT num_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.ZoneOffset ret = com.moparisthebest.jdbc.util.ResultSetUtil.getZoneOffset(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.ZoneOffset getZoneOffsetStr(final long valNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.ZoneOffset ret = com.moparisthebest.jdbc.util.ResultSetUtil.getZoneOffset(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.Person getPersonInTransaction(final java.lang.String lastName) throws java.sql.SQLException { + return com.moparisthebest.jdbc.QueryRunner.runInTransaction(this, dao -> PersonDAO.super.getPersonInTransaction(lastName)); + } + + @Override + public byte[] getBlob(final long valNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT some_blob FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final byte[] ret = rs.getBytes(1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.lang.String[] getSinglePersonNameArray(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.String[] ret = new java.lang.String[2]; +ret[0] = rs.getString(1); +ret[1] = rs.getString(2); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getSinglePersonNameMap(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Map ret = new java.util.HashMap(); +ret.put("first_name", rs.getString(1)); +ret.put("last_name", rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + private static final java.lang.reflect.Field[] _fields = new java.lang.reflect.Field[] { + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "firstName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "lastName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "birthDate"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "personNo"), + }; + + private final PreparedStatement[] psCache = new PreparedStatement[3]; + + private PreparedStatement prepareStatement(final int index, final String sql) throws SQLException { + final PreparedStatement ps = psCache[index]; + return ps == null ? (psCache[index] = conn.prepareStatement(sql)) : ps; + } + + @Override + public void close() { + for(final PreparedStatement ps : psCache) + tryClose(ps); + if(closeConn) + tryClose(conn); + } + + public PersonDAOAnyBean(final Factory connectionFactory) throws SQLException { + this(connectionFactory.create(), true); + } + + public PersonDAOAnyBean(final String jndiName) throws SQLException { + this(com.moparisthebest.jdbc.codegen.JdbcMapperFactory.connectionFactory(jndiName)); + } + + @Override + public SqlBuilder sqlBuilder() { + return SqlBuilder.of(conn, com.moparisthebest.jdbc.ArrayInList.instance()); + } +} diff --git a/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOBean.java b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOBean.java new file mode 100644 index 0000000..c772ef7 --- /dev/null +++ b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOBean.java @@ -0,0 +1,2013 @@ +package com.moparisthebest.jdbc.codegen; + +import com.moparisthebest.jdbc.util.SqlBuilder; +import com.moparisthebest.jdbc.Factory; + +import java.sql.*; + +import static com.moparisthebest.jdbc.util.ResultSetUtil.*; +import static com.moparisthebest.jdbc.TryClose.tryClose; + +public class PersonDAOBean implements PersonDAO { + + private final Connection conn; + private final boolean closeConn; + + private static final Factory _conFactory = com.moparisthebest.jdbc.codegen.JdbcMapperFactory.connectionFactory("bob"); + + public PersonDAOBean() throws SQLException { + this(_conFactory); + } + + private PersonDAOBean(final Connection conn, final boolean closeConn) { + this.conn = conn; + this.closeConn = closeConn; + if (this.conn == null) + throw new NullPointerException("Connection needs to be non-null for JdbcMapper..."); + } + + public PersonDAOBean(Connection conn) { + this(conn, false); + } + + public Connection getConnection() { + return this.conn; + } + + @Override + public void createTablePerson() { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("CREATE TABLE person (person_no NUMERIC, first_name VARCHAR(40), last_name VARCHAR(40), birth_date TIMESTAMP)"); + ps.executeUpdate(); + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public int insertPerson(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)"); + ps.setObject(1, personNo); + ps.setObject(2, birthDate == null ? null : new java.sql.Timestamp(birthDate.getTime())); + ps.setObject(3, firstName); + ps.setObject(4, lastName); + return ps.executeUpdate(); + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public long insertPersonGeneratedKey(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)", java.sql.Statement.RETURN_GENERATED_KEYS); + ps.setObject(1, personNo); + ps.setObject(2, birthDate == null ? null : new java.sql.Timestamp(birthDate.getTime())); + ps.setObject(3, firstName); + ps.setObject(4, lastName); + ps.executeUpdate(); + ResultSet rs = null; + try { + rs = ps.getGeneratedKeys(); + return rs.next() ? rs.getLong(1) : 0; + } finally { + tryClose(rs); + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public java.lang.Long insertPersonGeneratedKeyLong(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)", java.sql.Statement.RETURN_GENERATED_KEYS); + ps.setObject(1, personNo); + ps.setObject(2, birthDate == null ? null : new java.sql.Timestamp(birthDate.getTime())); + ps.setObject(3, firstName); + ps.setObject(4, lastName); + ps.executeUpdate(); + ResultSet rs = null; + try { + rs = ps.getGeneratedKeys(); + return rs.next() ? com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1) : null; + } finally { + tryClose(rs); + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public int setFirstName(final java.lang.String firstName, final java.lang.String lastName) { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE last_name = ?"); + ps.setObject(1, firstName); + ps.setObject(2, lastName); + return ps.executeUpdate(); + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public void setFirstName(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.setObject(1, firstName); + ps.setObject(2, personNo); + ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + @Override + public void setFirstNameBlob(final byte[] firstName, final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE person_no = ?"); + ps.setBlob(1, firstName == null ? null : new java.io.ByteArrayInputStream(firstName)); + ps.setObject(2, personNo); + ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + @Override + public void setFirstNameBlob(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-8"))); + } catch (java.io.UnsupportedEncodingException e) { + throw new SQLException("String to Blob UnsupportedEncodingException", e); + } + 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; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + if(rs.next()) { +final long ret = rs.getLong(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public long getPersonNoUnusedParam(final java.lang.String lastName, final java.lang.String _bla) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + if(rs.next()) { +final long ret = rs.getLong(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.ResultSet getPeopleResultSet(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + return new com.moparisthebest.jdbc.StatementClosingResultSet(rs, ps); + } catch(Throwable e) { + tryClose(rs); + tryClose(ps); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public java.sql.ResultSet getPeopleResultSetCached(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(0, "SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + return rs; + } catch(Throwable e) { + tryClose(rs); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public java.lang.String getFirstNameColumnNames(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.String ret = rs.getString(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.lang.String getFirstName(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.String ret = rs.getString(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public int getFirstNameUpdate(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + return ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPersonColumnNames(final long personNo) 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPerson(final long personNo) 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.BuilderPerson getBuilderPerson(final long personNo) 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.BuilderPerson ret = new com.moparisthebest.jdbc.dto.BuilderPerson(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPerson(final long personNo, final java.util.Calendar cal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3, 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; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeople(final java.lang.String[] lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("TEXT", lastName); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (NOT(last_name = ANY(?)))"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeople(final java.util.List lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("TEXT", lastName.toArray(new java.lang.String[lastName.size()])); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (last_name = ANY(?))"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson[] getPeopleArray(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret.toArray(new com.moparisthebest.jdbc.dto.FieldPerson[_colret.size()]); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Iterator getPeopleIterator(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret.iterator(); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.ListIterator getPeopleListIterator(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret.listIterator(); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonMap(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, rs.getLong(3)); + _colret.put(rs.getString(1), ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map> getPersonMapList(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.Map> _colret = new java.util.HashMap>(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, rs.getLong(3)); + final java.lang.String _colkey = rs.getString(1); + java.util.List _collist = _colret.get(_colkey); + if(_collist == null) { + _collist = new java.util.ArrayList(); + _colret.put(_colkey, _collist); + } + _collist.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.lang.String getFirstName(final long personNo, final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ? and last_name = ?"); + ps.setObject(1, personNo); + ps.setObject(2, lastName); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.String ret = rs.getString(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Calendar getBirthDateCalendar(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Calendar ret = com.moparisthebest.jdbc.util.ResultSetUtil.getCalendar(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Calendar getBirthDateCalendar(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Calendar ret = com.moparisthebest.jdbc.util.ResultSetUtil.getCalendar(rs, 1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Timestamp getBirthDateTimestamp(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Timestamp ret = rs.getTimestamp(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Timestamp getBirthDateTimestamp(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Timestamp ret = rs.getTimestamp(1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Time getBirthDateTime(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Time ret = rs.getTime(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Time getBirthDateTime(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Time ret = rs.getTime(1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Date getBirthDateSqlDate(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Date ret = rs.getDate(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Date getBirthDateSqlDate(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Date ret = rs.getDate(1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Date getBirthDateUtilDate(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Date ret = com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Date getBirthDateUtilDate(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Date ret = com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPersonCleanFieldPerson(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + return clean == null ? ret : clean.clean(ret); + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPersonCleanPerson(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + return clean == null ? ret : clean.clean(ret); + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPersonCleanObject(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + return clean == null ? ret : clean.clean(ret); + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPersonCleanPersonList(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.add(clean == null ? ret : clean.clean(ret)); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonCleanPersonMap(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.put(rs.getString(1), clean == null ? ret : clean.clean(ret)); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map> getPersonCleanPersonMapList(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + final java.util.Map> _colret = new java.util.HashMap>(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + final java.lang.String _colkey = rs.getString(1); + java.util.List _collist = _colret.get(_colkey); + if(_collist == null) { + _collist = new java.util.ArrayList(); + _colret.put(_colkey, _collist); + } + _collist.add(clean == null ? ret : clean.clean(ret)); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonDynamicLimit(final long personNo, final byte maxRows) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + byte _rowCount = 0; + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.put(rs.getString(1), ret); + if(maxRows > 0 && ++_rowCount == maxRows) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonDynamicLimit(final long personNo, final short arrayMaxLength) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + short _rowCount = 0; + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.put(rs.getString(1), ret); + if(arrayMaxLength > 0 && ++_rowCount == arrayMaxLength) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPersonDynamicLimit(final long personNo, final int maxRows) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + int _rowCount = 0; + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.add(ret); + if(maxRows > 0 && ++_rowCount == maxRows) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map> getPersonDynamicLimit(final long personNo, final long rowLimit) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + long _rowCount = 0; + final java.util.Map> _colret = new java.util.HashMap>(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + final java.lang.String _colkey = rs.getString(1); + java.util.List _collist = _colret.get(_colkey); + if(_collist == null) { + _collist = new java.util.ArrayList(); + _colret.put(_colkey, _collist); + } + _collist.add(ret); + if(rowLimit > 0 && ++_rowCount == rowLimit) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPersonStaticLimitListByte(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + byte _rowCount = 0; + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.add(ret); + if(++_rowCount == 127) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPersonStaticLimitList(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + short _rowCount = 0; + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.add(ret); + if(++_rowCount == 32767) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonStaticLimitMap(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + int _rowCount = 0; + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.put(rs.getString(1), ret); + if(++_rowCount == 2147483647) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map> getPersonStaticLimitMapList(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + long _rowCount = 0; + final java.util.Map> _colret = new java.util.HashMap>(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + final java.lang.String _colkey = rs.getString(1); + java.util.List _collist = _colret.get(_colkey); + if(_collist == null) { + _collist = new java.util.ArrayList(); + _colret.put(_colkey, _collist); + } + _collist.add(ret); + if(++_rowCount == 9223372036854775807L) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeopleList(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no, birth_date, last_name, first_name from person WHERE person_no IN (?,?,?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 2), +rs.getString(4), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.util.ResultSetIterable getPeopleResultSetIterable(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no, birth_date, last_name, first_name from person WHERE person_no IN (?,?,?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + return com.moparisthebest.jdbc.util.ResultSetIterable.getResultSetIterable(rs, + rs.next() ? (_rs, _cal) -> { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 2), +_rs.getString(4), +_rs.getString(3)); + return ret; + } + : null, null).setPreparedStatementToClose(ps); + } catch(Throwable e) { + tryClose(rs); + tryClose(ps); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public com.moparisthebest.jdbc.util.ResultSetIterable getPeopleResultSetIterableCachedPreparedStatement(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(1, "SELECT person_no, birth_date, last_name, first_name from person WHERE person_no IN (?,?,?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + return com.moparisthebest.jdbc.util.ResultSetIterable.getResultSetIterable(rs, + rs.next() ? (_rs, _cal) -> { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 2), +_rs.getString(4), +_rs.getString(3)); + return ret; + } + : null, null); + } catch(Throwable e) { + tryClose(rs); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public java.util.stream.Stream getPeopleStream(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no, birth_date, last_name, first_name from person WHERE person_no IN (?,?,?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + final PreparedStatement finalPs = ps; + return com.moparisthebest.jdbc.util.ResultSetIterable.getStream(rs, + rs.next() ? (_rs, _cal) -> { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 2), +_rs.getString(4), +_rs.getString(3)); + return ret; + } + : null, null).onClose(() -> tryClose(finalPs)); + } catch(Throwable e) { + tryClose(rs); + tryClose(ps); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public java.util.stream.Stream getPeopleStreamCachedPreparedStatement(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(2, "SELECT person_no, birth_date, last_name, first_name from person WHERE person_no IN (?,?,?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + return com.moparisthebest.jdbc.util.ResultSetIterable.getStream(rs, + rs.next() ? (_rs, _cal) -> { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 2), +_rs.getString(4), +_rs.getString(3)); + return ret; + } + : null, null); + } catch(Throwable e) { + tryClose(rs); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPersonConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson( +com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FirstName getFirstNameEnum(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPersonNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val as first_name, str_val as last_name FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FirstName getEnumNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.CaseSensitivePerson getCaseSensitivePerson(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name AS M_PERSON_FIRST_NAME FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.CaseSensitivePerson ret = new com.moparisthebest.jdbc.dto.CaseSensitivePerson(); +ret.setmPersonFirstName(rs.getString(1)); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson getSameClassPathEnumPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson ret = new com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson getSameClassPathEnumPersonConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson ret = new com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson( +com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName getSameClassPathFirstNameEnum(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson getSameClassPathEnumPersonNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val as first_name, str_val as last_name FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson ret = new com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName getSameClassPathEnumNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeopleInListArray(final java.lang.Long[] personNos) { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("NUMERIC", personNos); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (person_no = ANY(?))"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeopleInListCollection(final java.util.Collection personNos) { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("NUMERIC", personNos.toArray(new java.lang.Long[personNos.size()])); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (person_no = ANY(?))"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.stream.Stream getPeopleInListStream(final java.util.stream.Stream personNos, final java.util.stream.Stream names) { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[2]; + try { + _bindArrays[0] = conn.createArrayOf("NUMERIC", personNos.toArray(java.lang.Long[]::new)); + _bindArrays[1] = conn.createArrayOf("TEXT", names.toArray(java.lang.String[]::new)); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (person_no = ANY(?)) OR (first_name = ANY(?)) OR (last_name = ANY(?))"); + ps.setArray(1, _bindArrays[0]); + ps.setArray(2, _bindArrays[1]); + ps.setArray(3, _bindArrays[1]); + rs = ps.executeQuery(); + final PreparedStatement finalPs = ps; + return com.moparisthebest.jdbc.util.ResultSetIterable.getStream(rs, + rs.next() ? (_rs, _cal) -> { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, _rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, _rs.getString(2)); + return ret; + } + : null, null).onClose(() -> tryClose(finalPs)); + } catch(Throwable e) { + tryClose(rs); + tryClose(ps); + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + } + } + + @Override + public java.time.Instant getBirthDateInstant(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.Instant ret = com.moparisthebest.jdbc.util.ResultSetUtil.getInstant(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.LocalDateTime getBirthDateLocalDateTime(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.LocalDateTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getLocalDateTime(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.LocalDate getBirthDateLocalDate(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.LocalDate ret = com.moparisthebest.jdbc.util.ResultSetUtil.getLocalDate(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.LocalTime getBirthDateLocalTime(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.LocalTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getLocalTime(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.ZonedDateTime getBirthDateZonedDateTime(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.ZonedDateTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getZonedDateTime(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.OffsetDateTime getBirthDateOffsetDateTime(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.OffsetDateTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getOffsetDateTime(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.OffsetTime getBirthDateZonedOffsetTime(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.OffsetTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getOffsetTime(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.Year getYearInt(final long valNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT num_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.Year ret = com.moparisthebest.jdbc.util.ResultSetUtil.getYear(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.Year getYearString(final long valNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.Year ret = com.moparisthebest.jdbc.util.ResultSetUtil.getYear(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.ZoneId getZoneId(final long valNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.ZoneId ret = com.moparisthebest.jdbc.util.ResultSetUtil.getZoneId(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.ZoneOffset getZoneOffsetInt(final long valNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT num_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.ZoneOffset ret = com.moparisthebest.jdbc.util.ResultSetUtil.getZoneOffset(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.ZoneOffset getZoneOffsetStr(final long valNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.ZoneOffset ret = com.moparisthebest.jdbc.util.ResultSetUtil.getZoneOffset(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.Person getPersonInTransaction(final java.lang.String lastName) throws java.sql.SQLException { + return com.moparisthebest.jdbc.QueryRunner.runInTransaction(this, dao -> PersonDAO.super.getPersonInTransaction(lastName)); + } + + @Override + public byte[] getBlob(final long valNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT some_blob FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final byte[] ret = rs.getBytes(1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.lang.String[] getSinglePersonNameArray(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.String[] ret = new java.lang.String[2]; +ret[0] = rs.getString(1); +ret[1] = rs.getString(2); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getSinglePersonNameMap(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Map ret = new java.util.HashMap(); +ret.put("first_name", rs.getString(1)); +ret.put("last_name", rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + private static final java.lang.reflect.Field[] _fields = new java.lang.reflect.Field[] { + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "firstName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "lastName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "birthDate"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "personNo"), + }; + + private final PreparedStatement[] psCache = new PreparedStatement[3]; + + private PreparedStatement prepareStatement(final int index, final String sql) throws SQLException { + final PreparedStatement ps = psCache[index]; + return ps == null ? (psCache[index] = conn.prepareStatement(sql)) : ps; + } + + @Override + public void close() { + for(final PreparedStatement ps : psCache) + tryClose(ps); + if(closeConn) + tryClose(conn); + } + + public PersonDAOBean(final Factory connectionFactory) throws SQLException { + this(connectionFactory.create(), true); + } + + public PersonDAOBean(final String jndiName) throws SQLException { + this(com.moparisthebest.jdbc.codegen.JdbcMapperFactory.connectionFactory(jndiName)); + } + + @Override + public SqlBuilder sqlBuilder() { + return SqlBuilder.of(conn, com.moparisthebest.jdbc.ArrayInList.instance()); + } +} diff --git a/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOBindBean.java b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOBindBean.java new file mode 100644 index 0000000..aa373eb --- /dev/null +++ b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOBindBean.java @@ -0,0 +1,2013 @@ +package com.moparisthebest.jdbc.codegen; + +import com.moparisthebest.jdbc.util.SqlBuilder; +import com.moparisthebest.jdbc.Factory; + +import java.sql.*; + +import static com.moparisthebest.jdbc.util.ResultSetUtil.*; +import static com.moparisthebest.jdbc.TryClose.tryClose; + +public class PersonDAOBindBean implements PersonDAO { + + private final Connection conn; + private final boolean closeConn; + + private static final Factory _conFactory = com.moparisthebest.jdbc.codegen.JdbcMapperFactory.connectionFactory("bob"); + + public PersonDAOBindBean() throws SQLException { + this(_conFactory); + } + + private PersonDAOBindBean(final Connection conn, final boolean closeConn) { + this.conn = conn; + this.closeConn = closeConn; + if (this.conn == null) + throw new NullPointerException("Connection needs to be non-null for JdbcMapper..."); + } + + public PersonDAOBindBean(Connection conn) { + this(conn, false); + } + + public Connection getConnection() { + return this.conn; + } + + @Override + public void createTablePerson() { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("CREATE TABLE person (person_no NUMERIC, first_name VARCHAR(40), last_name VARCHAR(40), birth_date TIMESTAMP)"); + ps.executeUpdate(); + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public int insertPerson(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)"); + ps.setObject(1, personNo); + ps.setObject(2, birthDate == null ? null : new java.sql.Timestamp(birthDate.getTime())); + ps.setObject(3, firstName); + ps.setObject(4, lastName); + return ps.executeUpdate(); + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public long insertPersonGeneratedKey(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)", java.sql.Statement.RETURN_GENERATED_KEYS); + ps.setObject(1, personNo); + ps.setObject(2, birthDate == null ? null : new java.sql.Timestamp(birthDate.getTime())); + ps.setObject(3, firstName); + ps.setObject(4, lastName); + ps.executeUpdate(); + ResultSet rs = null; + try { + rs = ps.getGeneratedKeys(); + return rs.next() ? rs.getLong(1) : 0; + } finally { + tryClose(rs); + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public java.lang.Long insertPersonGeneratedKeyLong(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)", java.sql.Statement.RETURN_GENERATED_KEYS); + ps.setObject(1, personNo); + ps.setObject(2, birthDate == null ? null : new java.sql.Timestamp(birthDate.getTime())); + ps.setObject(3, firstName); + ps.setObject(4, lastName); + ps.executeUpdate(); + ResultSet rs = null; + try { + rs = ps.getGeneratedKeys(); + return rs.next() ? com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1) : null; + } finally { + tryClose(rs); + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public int setFirstName(final java.lang.String firstName, final java.lang.String lastName) { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE last_name = ?"); + ps.setObject(1, firstName); + ps.setObject(2, lastName); + return ps.executeUpdate(); + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public void setFirstName(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.setObject(1, firstName); + ps.setObject(2, personNo); + ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + @Override + public void setFirstNameBlob(final byte[] firstName, final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE person_no = ?"); + ps.setBlob(1, firstName == null ? null : new java.io.ByteArrayInputStream(firstName)); + ps.setObject(2, personNo); + ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + @Override + public void setFirstNameBlob(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-8"))); + } catch (java.io.UnsupportedEncodingException e) { + throw new SQLException("String to Blob UnsupportedEncodingException", e); + } + 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; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + if(rs.next()) { +final long ret = rs.getLong(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public long getPersonNoUnusedParam(final java.lang.String lastName, final java.lang.String _bla) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + if(rs.next()) { +final long ret = rs.getLong(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.ResultSet getPeopleResultSet(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + return new com.moparisthebest.jdbc.StatementClosingResultSet(rs, ps); + } catch(Throwable e) { + tryClose(rs); + tryClose(ps); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public java.sql.ResultSet getPeopleResultSetCached(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(0, "SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + return rs; + } catch(Throwable e) { + tryClose(rs); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public java.lang.String getFirstNameColumnNames(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.String ret = rs.getString(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.lang.String getFirstName(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.String ret = rs.getString(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public int getFirstNameUpdate(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + return ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPersonColumnNames(final long personNo) 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPerson(final long personNo) 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.BuilderPerson getBuilderPerson(final long personNo) 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.BuilderPerson ret = new com.moparisthebest.jdbc.dto.BuilderPerson(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPerson(final long personNo, final java.util.Calendar cal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3, 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; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeople(final java.lang.String[] lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("TEXT", lastName); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (NOT(last_name = ANY(?)))"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeople(final java.util.List lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("TEXT", lastName.toArray(new java.lang.String[lastName.size()])); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (last_name = ANY(?))"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson[] getPeopleArray(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret.toArray(new com.moparisthebest.jdbc.dto.FieldPerson[_colret.size()]); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Iterator getPeopleIterator(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret.iterator(); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.ListIterator getPeopleListIterator(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret.listIterator(); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonMap(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, rs.getLong(3)); + _colret.put(rs.getString(1), ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map> getPersonMapList(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.Map> _colret = new java.util.HashMap>(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, rs.getLong(3)); + final java.lang.String _colkey = rs.getString(1); + java.util.List _collist = _colret.get(_colkey); + if(_collist == null) { + _collist = new java.util.ArrayList(); + _colret.put(_colkey, _collist); + } + _collist.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.lang.String getFirstName(final long personNo, final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ? and last_name = ?"); + ps.setObject(1, personNo); + ps.setObject(2, lastName); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.String ret = rs.getString(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Calendar getBirthDateCalendar(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Calendar ret = com.moparisthebest.jdbc.util.ResultSetUtil.getCalendar(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Calendar getBirthDateCalendar(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Calendar ret = com.moparisthebest.jdbc.util.ResultSetUtil.getCalendar(rs, 1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Timestamp getBirthDateTimestamp(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Timestamp ret = rs.getTimestamp(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Timestamp getBirthDateTimestamp(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Timestamp ret = rs.getTimestamp(1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Time getBirthDateTime(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Time ret = rs.getTime(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Time getBirthDateTime(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Time ret = rs.getTime(1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Date getBirthDateSqlDate(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Date ret = rs.getDate(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Date getBirthDateSqlDate(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Date ret = rs.getDate(1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Date getBirthDateUtilDate(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Date ret = com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Date getBirthDateUtilDate(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Date ret = com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPersonCleanFieldPerson(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + return clean == null ? ret : clean.clean(ret); + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPersonCleanPerson(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + return clean == null ? ret : clean.clean(ret); + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPersonCleanObject(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + return clean == null ? ret : clean.clean(ret); + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPersonCleanPersonList(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.add(clean == null ? ret : clean.clean(ret)); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonCleanPersonMap(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.put(rs.getString(1), clean == null ? ret : clean.clean(ret)); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map> getPersonCleanPersonMapList(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + final java.util.Map> _colret = new java.util.HashMap>(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + final java.lang.String _colkey = rs.getString(1); + java.util.List _collist = _colret.get(_colkey); + if(_collist == null) { + _collist = new java.util.ArrayList(); + _colret.put(_colkey, _collist); + } + _collist.add(clean == null ? ret : clean.clean(ret)); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonDynamicLimit(final long personNo, final byte maxRows) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + byte _rowCount = 0; + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.put(rs.getString(1), ret); + if(maxRows > 0 && ++_rowCount == maxRows) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonDynamicLimit(final long personNo, final short arrayMaxLength) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + short _rowCount = 0; + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.put(rs.getString(1), ret); + if(arrayMaxLength > 0 && ++_rowCount == arrayMaxLength) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPersonDynamicLimit(final long personNo, final int maxRows) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + int _rowCount = 0; + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.add(ret); + if(maxRows > 0 && ++_rowCount == maxRows) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map> getPersonDynamicLimit(final long personNo, final long rowLimit) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + long _rowCount = 0; + final java.util.Map> _colret = new java.util.HashMap>(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + final java.lang.String _colkey = rs.getString(1); + java.util.List _collist = _colret.get(_colkey); + if(_collist == null) { + _collist = new java.util.ArrayList(); + _colret.put(_colkey, _collist); + } + _collist.add(ret); + if(rowLimit > 0 && ++_rowCount == rowLimit) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPersonStaticLimitListByte(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + byte _rowCount = 0; + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.add(ret); + if(++_rowCount == 127) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPersonStaticLimitList(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + short _rowCount = 0; + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.add(ret); + if(++_rowCount == 32767) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonStaticLimitMap(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + int _rowCount = 0; + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.put(rs.getString(1), ret); + if(++_rowCount == 2147483647) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map> getPersonStaticLimitMapList(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + long _rowCount = 0; + final java.util.Map> _colret = new java.util.HashMap>(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + final java.lang.String _colkey = rs.getString(1); + java.util.List _collist = _colret.get(_colkey); + if(_collist == null) { + _collist = new java.util.ArrayList(); + _colret.put(_colkey, _collist); + } + _collist.add(ret); + if(++_rowCount == 9223372036854775807L) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeopleList(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no, birth_date, last_name, first_name from person WHERE person_no IN (?,?,?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 2), +rs.getString(4), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.util.ResultSetIterable getPeopleResultSetIterable(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no, birth_date, last_name, first_name from person WHERE person_no IN (?,?,?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + return com.moparisthebest.jdbc.util.ResultSetIterable.getResultSetIterable(rs, + rs.next() ? (_rs, _cal) -> { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 2), +_rs.getString(4), +_rs.getString(3)); + return ret; + } + : null, null).setPreparedStatementToClose(ps); + } catch(Throwable e) { + tryClose(rs); + tryClose(ps); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public com.moparisthebest.jdbc.util.ResultSetIterable getPeopleResultSetIterableCachedPreparedStatement(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(1, "SELECT person_no, birth_date, last_name, first_name from person WHERE person_no IN (?,?,?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + return com.moparisthebest.jdbc.util.ResultSetIterable.getResultSetIterable(rs, + rs.next() ? (_rs, _cal) -> { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 2), +_rs.getString(4), +_rs.getString(3)); + return ret; + } + : null, null); + } catch(Throwable e) { + tryClose(rs); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public java.util.stream.Stream getPeopleStream(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no, birth_date, last_name, first_name from person WHERE person_no IN (?,?,?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + final PreparedStatement finalPs = ps; + return com.moparisthebest.jdbc.util.ResultSetIterable.getStream(rs, + rs.next() ? (_rs, _cal) -> { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 2), +_rs.getString(4), +_rs.getString(3)); + return ret; + } + : null, null).onClose(() -> tryClose(finalPs)); + } catch(Throwable e) { + tryClose(rs); + tryClose(ps); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public java.util.stream.Stream getPeopleStreamCachedPreparedStatement(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(2, "SELECT person_no, birth_date, last_name, first_name from person WHERE person_no IN (?,?,?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + return com.moparisthebest.jdbc.util.ResultSetIterable.getStream(rs, + rs.next() ? (_rs, _cal) -> { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 2), +_rs.getString(4), +_rs.getString(3)); + return ret; + } + : null, null); + } catch(Throwable e) { + tryClose(rs); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPersonConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson( +com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FirstName getFirstNameEnum(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPersonNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val as first_name, str_val as last_name FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FirstName getEnumNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.CaseSensitivePerson getCaseSensitivePerson(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name AS M_PERSON_FIRST_NAME FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.CaseSensitivePerson ret = new com.moparisthebest.jdbc.dto.CaseSensitivePerson(); +ret.setmPersonFirstName(rs.getString(1)); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson getSameClassPathEnumPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson ret = new com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson getSameClassPathEnumPersonConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson ret = new com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson( +com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName getSameClassPathFirstNameEnum(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson getSameClassPathEnumPersonNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val as first_name, str_val as last_name FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson ret = new com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName getSameClassPathEnumNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeopleInListArray(final java.lang.Long[] personNos) { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("NUMERIC", personNos); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (person_no = ANY(?))"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeopleInListCollection(final java.util.Collection personNos) { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("NUMERIC", personNos.toArray(new java.lang.Long[personNos.size()])); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (person_no = ANY(?))"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.stream.Stream getPeopleInListStream(final java.util.stream.Stream personNos, final java.util.stream.Stream names) { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[2]; + try { + _bindArrays[0] = conn.createArrayOf("NUMERIC", personNos.toArray(java.lang.Long[]::new)); + _bindArrays[1] = conn.createArrayOf("TEXT", names.toArray(java.lang.String[]::new)); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (person_no = ANY(?)) OR (first_name = ANY(?)) OR (last_name = ANY(?))"); + ps.setArray(1, _bindArrays[0]); + ps.setArray(2, _bindArrays[1]); + ps.setArray(3, _bindArrays[1]); + rs = ps.executeQuery(); + final PreparedStatement finalPs = ps; + return com.moparisthebest.jdbc.util.ResultSetIterable.getStream(rs, + rs.next() ? (_rs, _cal) -> { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, _rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, _rs.getString(2)); + return ret; + } + : null, null).onClose(() -> tryClose(finalPs)); + } catch(Throwable e) { + tryClose(rs); + tryClose(ps); + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + } + } + + @Override + public java.time.Instant getBirthDateInstant(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.Instant ret = com.moparisthebest.jdbc.util.ResultSetUtil.getInstant(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.LocalDateTime getBirthDateLocalDateTime(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.LocalDateTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getLocalDateTime(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.LocalDate getBirthDateLocalDate(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.LocalDate ret = com.moparisthebest.jdbc.util.ResultSetUtil.getLocalDate(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.LocalTime getBirthDateLocalTime(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.LocalTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getLocalTime(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.ZonedDateTime getBirthDateZonedDateTime(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.ZonedDateTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getZonedDateTime(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.OffsetDateTime getBirthDateOffsetDateTime(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.OffsetDateTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getOffsetDateTime(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.OffsetTime getBirthDateZonedOffsetTime(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.OffsetTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getOffsetTime(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.Year getYearInt(final long valNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT num_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.Year ret = com.moparisthebest.jdbc.util.ResultSetUtil.getYear(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.Year getYearString(final long valNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.Year ret = com.moparisthebest.jdbc.util.ResultSetUtil.getYear(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.ZoneId getZoneId(final long valNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.ZoneId ret = com.moparisthebest.jdbc.util.ResultSetUtil.getZoneId(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.ZoneOffset getZoneOffsetInt(final long valNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT num_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.ZoneOffset ret = com.moparisthebest.jdbc.util.ResultSetUtil.getZoneOffset(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.ZoneOffset getZoneOffsetStr(final long valNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.ZoneOffset ret = com.moparisthebest.jdbc.util.ResultSetUtil.getZoneOffset(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.Person getPersonInTransaction(final java.lang.String lastName) throws java.sql.SQLException { + return com.moparisthebest.jdbc.QueryRunner.runInTransaction(this, dao -> PersonDAO.super.getPersonInTransaction(lastName)); + } + + @Override + public byte[] getBlob(final long valNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT some_blob FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final byte[] ret = rs.getBytes(1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.lang.String[] getSinglePersonNameArray(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.String[] ret = new java.lang.String[2]; +ret[0] = rs.getString(1); +ret[1] = rs.getString(2); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getSinglePersonNameMap(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Map ret = new java.util.HashMap(); +ret.put("first_name", rs.getString(1)); +ret.put("last_name", rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + private static final java.lang.reflect.Field[] _fields = new java.lang.reflect.Field[] { + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "firstName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "lastName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "birthDate"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "personNo"), + }; + + private final PreparedStatement[] psCache = new PreparedStatement[3]; + + private PreparedStatement prepareStatement(final int index, final String sql) throws SQLException { + final PreparedStatement ps = psCache[index]; + return ps == null ? (psCache[index] = conn.prepareStatement(sql)) : ps; + } + + @Override + public void close() { + for(final PreparedStatement ps : psCache) + tryClose(ps); + if(closeConn) + tryClose(conn); + } + + public PersonDAOBindBean(final Factory connectionFactory) throws SQLException { + this(connectionFactory.create(), true); + } + + public PersonDAOBindBean(final String jndiName) throws SQLException { + this(com.moparisthebest.jdbc.codegen.JdbcMapperFactory.connectionFactory(jndiName)); + } + + @Override + public SqlBuilder sqlBuilder() { + return SqlBuilder.of(conn, com.moparisthebest.jdbc.ArrayInList.instance()); + } +} diff --git a/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOOracleBean.java b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOOracleBean.java new file mode 100644 index 0000000..8d3752a --- /dev/null +++ b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOOracleBean.java @@ -0,0 +1,2013 @@ +package com.moparisthebest.jdbc.codegen; + +import com.moparisthebest.jdbc.util.SqlBuilder; +import com.moparisthebest.jdbc.Factory; + +import java.sql.*; + +import static com.moparisthebest.jdbc.util.ResultSetUtil.*; +import static com.moparisthebest.jdbc.TryClose.tryClose; + +public class PersonDAOOracleBean implements PersonDAO { + + private final Connection conn; + private final boolean closeConn; + + private static final Factory _conFactory = com.moparisthebest.jdbc.codegen.JdbcMapperFactory.connectionFactory("bob"); + + public PersonDAOOracleBean() throws SQLException { + this(_conFactory); + } + + private PersonDAOOracleBean(final Connection conn, final boolean closeConn) { + this.conn = conn; + this.closeConn = closeConn; + if (this.conn == null) + throw new NullPointerException("Connection needs to be non-null for JdbcMapper..."); + } + + public PersonDAOOracleBean(Connection conn) { + this(conn, false); + } + + public Connection getConnection() { + return this.conn; + } + + @Override + public void createTablePerson() { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("CREATE TABLE person (person_no NUMERIC, first_name VARCHAR(40), last_name VARCHAR(40), birth_date TIMESTAMP)"); + ps.executeUpdate(); + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public int insertPerson(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)"); + ps.setObject(1, personNo); + ps.setObject(2, birthDate == null ? null : new java.sql.Timestamp(birthDate.getTime())); + ps.setObject(3, firstName); + ps.setObject(4, lastName); + return ps.executeUpdate(); + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public long insertPersonGeneratedKey(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)", java.sql.Statement.RETURN_GENERATED_KEYS); + ps.setObject(1, personNo); + ps.setObject(2, birthDate == null ? null : new java.sql.Timestamp(birthDate.getTime())); + ps.setObject(3, firstName); + ps.setObject(4, lastName); + ps.executeUpdate(); + ResultSet rs = null; + try { + rs = ps.getGeneratedKeys(); + return rs.next() ? rs.getLong(1) : 0; + } finally { + tryClose(rs); + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public java.lang.Long insertPersonGeneratedKeyLong(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)", java.sql.Statement.RETURN_GENERATED_KEYS); + ps.setObject(1, personNo); + ps.setObject(2, birthDate == null ? null : new java.sql.Timestamp(birthDate.getTime())); + ps.setObject(3, firstName); + ps.setObject(4, lastName); + ps.executeUpdate(); + ResultSet rs = null; + try { + rs = ps.getGeneratedKeys(); + return rs.next() ? com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1) : null; + } finally { + tryClose(rs); + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public int setFirstName(final java.lang.String firstName, final java.lang.String lastName) { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE last_name = ?"); + ps.setObject(1, firstName); + ps.setObject(2, lastName); + return ps.executeUpdate(); + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public void setFirstName(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.setObject(1, firstName); + ps.setObject(2, personNo); + ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + @Override + public void setFirstNameBlob(final byte[] firstName, final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE person_no = ?"); + ps.setBlob(1, firstName == null ? null : new java.io.ByteArrayInputStream(firstName)); + ps.setObject(2, personNo); + ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + @Override + public void setFirstNameBlob(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-8"))); + } catch (java.io.UnsupportedEncodingException e) { + throw new SQLException("String to Blob UnsupportedEncodingException", e); + } + 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; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + if(rs.next()) { +final long ret = rs.getLong(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public long getPersonNoUnusedParam(final java.lang.String lastName, final java.lang.String _bla) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + if(rs.next()) { +final long ret = rs.getLong(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.ResultSet getPeopleResultSet(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + return new com.moparisthebest.jdbc.StatementClosingResultSet(rs, ps); + } catch(Throwable e) { + tryClose(rs); + tryClose(ps); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public java.sql.ResultSet getPeopleResultSetCached(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(0, "SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + return rs; + } catch(Throwable e) { + tryClose(rs); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public java.lang.String getFirstNameColumnNames(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.String ret = rs.getString(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.lang.String getFirstName(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.String ret = rs.getString(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public int getFirstNameUpdate(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + return ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPersonColumnNames(final long personNo) 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPerson(final long personNo) 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.BuilderPerson getBuilderPerson(final long personNo) 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.BuilderPerson ret = new com.moparisthebest.jdbc.dto.BuilderPerson(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPerson(final long personNo, final java.util.Calendar cal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3, 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; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeople(final java.lang.String[] lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("TEXT", lastName); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (NOT(last_name = ANY(?)))"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeople(final java.util.List lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("TEXT", lastName.toArray(new java.lang.String[lastName.size()])); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (last_name = ANY(?))"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson[] getPeopleArray(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret.toArray(new com.moparisthebest.jdbc.dto.FieldPerson[_colret.size()]); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Iterator getPeopleIterator(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret.iterator(); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.ListIterator getPeopleListIterator(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret.listIterator(); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonMap(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, rs.getLong(3)); + _colret.put(rs.getString(1), ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map> getPersonMapList(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.Map> _colret = new java.util.HashMap>(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, rs.getLong(3)); + final java.lang.String _colkey = rs.getString(1); + java.util.List _collist = _colret.get(_colkey); + if(_collist == null) { + _collist = new java.util.ArrayList(); + _colret.put(_colkey, _collist); + } + _collist.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.lang.String getFirstName(final long personNo, final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ? and last_name = ?"); + ps.setObject(1, personNo); + ps.setObject(2, lastName); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.String ret = rs.getString(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Calendar getBirthDateCalendar(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Calendar ret = com.moparisthebest.jdbc.util.ResultSetUtil.getCalendar(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Calendar getBirthDateCalendar(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Calendar ret = com.moparisthebest.jdbc.util.ResultSetUtil.getCalendar(rs, 1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Timestamp getBirthDateTimestamp(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Timestamp ret = rs.getTimestamp(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Timestamp getBirthDateTimestamp(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Timestamp ret = rs.getTimestamp(1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Time getBirthDateTime(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Time ret = rs.getTime(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Time getBirthDateTime(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Time ret = rs.getTime(1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Date getBirthDateSqlDate(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Date ret = rs.getDate(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Date getBirthDateSqlDate(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Date ret = rs.getDate(1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Date getBirthDateUtilDate(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Date ret = com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Date getBirthDateUtilDate(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Date ret = com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPersonCleanFieldPerson(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + return clean == null ? ret : clean.clean(ret); + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPersonCleanPerson(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + return clean == null ? ret : clean.clean(ret); + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPersonCleanObject(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + return clean == null ? ret : clean.clean(ret); + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPersonCleanPersonList(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.add(clean == null ? ret : clean.clean(ret)); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonCleanPersonMap(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.put(rs.getString(1), clean == null ? ret : clean.clean(ret)); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map> getPersonCleanPersonMapList(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + final java.util.Map> _colret = new java.util.HashMap>(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + final java.lang.String _colkey = rs.getString(1); + java.util.List _collist = _colret.get(_colkey); + if(_collist == null) { + _collist = new java.util.ArrayList(); + _colret.put(_colkey, _collist); + } + _collist.add(clean == null ? ret : clean.clean(ret)); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonDynamicLimit(final long personNo, final byte maxRows) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + byte _rowCount = 0; + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.put(rs.getString(1), ret); + if(maxRows > 0 && ++_rowCount == maxRows) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonDynamicLimit(final long personNo, final short arrayMaxLength) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + short _rowCount = 0; + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.put(rs.getString(1), ret); + if(arrayMaxLength > 0 && ++_rowCount == arrayMaxLength) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPersonDynamicLimit(final long personNo, final int maxRows) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + int _rowCount = 0; + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.add(ret); + if(maxRows > 0 && ++_rowCount == maxRows) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map> getPersonDynamicLimit(final long personNo, final long rowLimit) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + long _rowCount = 0; + final java.util.Map> _colret = new java.util.HashMap>(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + final java.lang.String _colkey = rs.getString(1); + java.util.List _collist = _colret.get(_colkey); + if(_collist == null) { + _collist = new java.util.ArrayList(); + _colret.put(_colkey, _collist); + } + _collist.add(ret); + if(rowLimit > 0 && ++_rowCount == rowLimit) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPersonStaticLimitListByte(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + byte _rowCount = 0; + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.add(ret); + if(++_rowCount == 127) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPersonStaticLimitList(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + short _rowCount = 0; + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.add(ret); + if(++_rowCount == 32767) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonStaticLimitMap(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + int _rowCount = 0; + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.put(rs.getString(1), ret); + if(++_rowCount == 2147483647) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map> getPersonStaticLimitMapList(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + long _rowCount = 0; + final java.util.Map> _colret = new java.util.HashMap>(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + final java.lang.String _colkey = rs.getString(1); + java.util.List _collist = _colret.get(_colkey); + if(_collist == null) { + _collist = new java.util.ArrayList(); + _colret.put(_colkey, _collist); + } + _collist.add(ret); + if(++_rowCount == 9223372036854775807L) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeopleList(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no, birth_date, last_name, first_name from person WHERE person_no IN (?,?,?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 2), +rs.getString(4), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.util.ResultSetIterable getPeopleResultSetIterable(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no, birth_date, last_name, first_name from person WHERE person_no IN (?,?,?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + return com.moparisthebest.jdbc.util.ResultSetIterable.getResultSetIterable(rs, + rs.next() ? (_rs, _cal) -> { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 2), +_rs.getString(4), +_rs.getString(3)); + return ret; + } + : null, null).setPreparedStatementToClose(ps); + } catch(Throwable e) { + tryClose(rs); + tryClose(ps); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public com.moparisthebest.jdbc.util.ResultSetIterable getPeopleResultSetIterableCachedPreparedStatement(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(1, "SELECT person_no, birth_date, last_name, first_name from person WHERE person_no IN (?,?,?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + return com.moparisthebest.jdbc.util.ResultSetIterable.getResultSetIterable(rs, + rs.next() ? (_rs, _cal) -> { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 2), +_rs.getString(4), +_rs.getString(3)); + return ret; + } + : null, null); + } catch(Throwable e) { + tryClose(rs); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public java.util.stream.Stream getPeopleStream(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no, birth_date, last_name, first_name from person WHERE person_no IN (?,?,?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + final PreparedStatement finalPs = ps; + return com.moparisthebest.jdbc.util.ResultSetIterable.getStream(rs, + rs.next() ? (_rs, _cal) -> { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 2), +_rs.getString(4), +_rs.getString(3)); + return ret; + } + : null, null).onClose(() -> tryClose(finalPs)); + } catch(Throwable e) { + tryClose(rs); + tryClose(ps); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public java.util.stream.Stream getPeopleStreamCachedPreparedStatement(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(2, "SELECT person_no, birth_date, last_name, first_name from person WHERE person_no IN (?,?,?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + return com.moparisthebest.jdbc.util.ResultSetIterable.getStream(rs, + rs.next() ? (_rs, _cal) -> { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 2), +_rs.getString(4), +_rs.getString(3)); + return ret; + } + : null, null); + } catch(Throwable e) { + tryClose(rs); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPersonConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson( +com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FirstName getFirstNameEnum(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPersonNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val as first_name, str_val as last_name FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FirstName getEnumNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.CaseSensitivePerson getCaseSensitivePerson(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name AS M_PERSON_FIRST_NAME FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.CaseSensitivePerson ret = new com.moparisthebest.jdbc.dto.CaseSensitivePerson(); +ret.setmPersonFirstName(rs.getString(1)); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson getSameClassPathEnumPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson ret = new com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson getSameClassPathEnumPersonConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson ret = new com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson( +com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName getSameClassPathFirstNameEnum(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson getSameClassPathEnumPersonNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val as first_name, str_val as last_name FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson ret = new com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName getSameClassPathEnumNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeopleInListArray(final java.lang.Long[] personNos) { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("NUMERIC", personNos); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (person_no = ANY(?))"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeopleInListCollection(final java.util.Collection personNos) { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("NUMERIC", personNos.toArray(new java.lang.Long[personNos.size()])); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (person_no = ANY(?))"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.stream.Stream getPeopleInListStream(final java.util.stream.Stream personNos, final java.util.stream.Stream names) { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[2]; + try { + _bindArrays[0] = conn.createArrayOf("NUMERIC", personNos.toArray(java.lang.Long[]::new)); + _bindArrays[1] = conn.createArrayOf("TEXT", names.toArray(java.lang.String[]::new)); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (person_no = ANY(?)) OR (first_name = ANY(?)) OR (last_name = ANY(?))"); + ps.setArray(1, _bindArrays[0]); + ps.setArray(2, _bindArrays[1]); + ps.setArray(3, _bindArrays[1]); + rs = ps.executeQuery(); + final PreparedStatement finalPs = ps; + return com.moparisthebest.jdbc.util.ResultSetIterable.getStream(rs, + rs.next() ? (_rs, _cal) -> { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, _rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, _rs.getString(2)); + return ret; + } + : null, null).onClose(() -> tryClose(finalPs)); + } catch(Throwable e) { + tryClose(rs); + tryClose(ps); + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + } + } + + @Override + public java.time.Instant getBirthDateInstant(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.Instant ret = com.moparisthebest.jdbc.util.ResultSetUtil.getInstant(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.LocalDateTime getBirthDateLocalDateTime(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.LocalDateTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getLocalDateTime(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.LocalDate getBirthDateLocalDate(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.LocalDate ret = com.moparisthebest.jdbc.util.ResultSetUtil.getLocalDate(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.LocalTime getBirthDateLocalTime(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.LocalTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getLocalTime(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.ZonedDateTime getBirthDateZonedDateTime(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.ZonedDateTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getZonedDateTime(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.OffsetDateTime getBirthDateOffsetDateTime(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.OffsetDateTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getOffsetDateTime(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.OffsetTime getBirthDateZonedOffsetTime(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.OffsetTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getOffsetTime(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.Year getYearInt(final long valNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT num_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.Year ret = com.moparisthebest.jdbc.util.ResultSetUtil.getYear(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.Year getYearString(final long valNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.Year ret = com.moparisthebest.jdbc.util.ResultSetUtil.getYear(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.ZoneId getZoneId(final long valNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.ZoneId ret = com.moparisthebest.jdbc.util.ResultSetUtil.getZoneId(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.ZoneOffset getZoneOffsetInt(final long valNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT num_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.ZoneOffset ret = com.moparisthebest.jdbc.util.ResultSetUtil.getZoneOffset(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.ZoneOffset getZoneOffsetStr(final long valNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.ZoneOffset ret = com.moparisthebest.jdbc.util.ResultSetUtil.getZoneOffset(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.Person getPersonInTransaction(final java.lang.String lastName) throws java.sql.SQLException { + return com.moparisthebest.jdbc.QueryRunner.runInTransaction(this, dao -> PersonDAO.super.getPersonInTransaction(lastName)); + } + + @Override + public byte[] getBlob(final long valNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT some_blob FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final byte[] ret = rs.getBytes(1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.lang.String[] getSinglePersonNameArray(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.String[] ret = new java.lang.String[2]; +ret[0] = rs.getString(1); +ret[1] = rs.getString(2); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getSinglePersonNameMap(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Map ret = new java.util.HashMap(); +ret.put("first_name", rs.getString(1)); +ret.put("last_name", rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + private static final java.lang.reflect.Field[] _fields = new java.lang.reflect.Field[] { + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "firstName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "lastName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "birthDate"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "personNo"), + }; + + private final PreparedStatement[] psCache = new PreparedStatement[3]; + + private PreparedStatement prepareStatement(final int index, final String sql) throws SQLException { + final PreparedStatement ps = psCache[index]; + return ps == null ? (psCache[index] = conn.prepareStatement(sql)) : ps; + } + + @Override + public void close() { + for(final PreparedStatement ps : psCache) + tryClose(ps); + if(closeConn) + tryClose(conn); + } + + public PersonDAOOracleBean(final Factory connectionFactory) throws SQLException { + this(connectionFactory.create(), true); + } + + public PersonDAOOracleBean(final String jndiName) throws SQLException { + this(com.moparisthebest.jdbc.codegen.JdbcMapperFactory.connectionFactory(jndiName)); + } + + @Override + public SqlBuilder sqlBuilder() { + return SqlBuilder.of(conn, com.moparisthebest.jdbc.ArrayInList.instance()); + } +} diff --git a/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOUnNestBean.java b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOUnNestBean.java new file mode 100644 index 0000000..7b1c299 --- /dev/null +++ b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/PersonDAOUnNestBean.java @@ -0,0 +1,2013 @@ +package com.moparisthebest.jdbc.codegen; + +import com.moparisthebest.jdbc.util.SqlBuilder; +import com.moparisthebest.jdbc.Factory; + +import java.sql.*; + +import static com.moparisthebest.jdbc.util.ResultSetUtil.*; +import static com.moparisthebest.jdbc.TryClose.tryClose; + +public class PersonDAOUnNestBean implements PersonDAO { + + private final Connection conn; + private final boolean closeConn; + + private static final Factory _conFactory = com.moparisthebest.jdbc.codegen.JdbcMapperFactory.connectionFactory("bob"); + + public PersonDAOUnNestBean() throws SQLException { + this(_conFactory); + } + + private PersonDAOUnNestBean(final Connection conn, final boolean closeConn) { + this.conn = conn; + this.closeConn = closeConn; + if (this.conn == null) + throw new NullPointerException("Connection needs to be non-null for JdbcMapper..."); + } + + public PersonDAOUnNestBean(Connection conn) { + this(conn, false); + } + + public Connection getConnection() { + return this.conn; + } + + @Override + public void createTablePerson() { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("CREATE TABLE person (person_no NUMERIC, first_name VARCHAR(40), last_name VARCHAR(40), birth_date TIMESTAMP)"); + ps.executeUpdate(); + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public int insertPerson(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)"); + ps.setObject(1, personNo); + ps.setObject(2, birthDate == null ? null : new java.sql.Timestamp(birthDate.getTime())); + ps.setObject(3, firstName); + ps.setObject(4, lastName); + return ps.executeUpdate(); + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public long insertPersonGeneratedKey(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)", java.sql.Statement.RETURN_GENERATED_KEYS); + ps.setObject(1, personNo); + ps.setObject(2, birthDate == null ? null : new java.sql.Timestamp(birthDate.getTime())); + ps.setObject(3, firstName); + ps.setObject(4, lastName); + ps.executeUpdate(); + ResultSet rs = null; + try { + rs = ps.getGeneratedKeys(); + return rs.next() ? rs.getLong(1) : 0; + } finally { + tryClose(rs); + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public java.lang.Long insertPersonGeneratedKeyLong(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)", java.sql.Statement.RETURN_GENERATED_KEYS); + ps.setObject(1, personNo); + ps.setObject(2, birthDate == null ? null : new java.sql.Timestamp(birthDate.getTime())); + ps.setObject(3, firstName); + ps.setObject(4, lastName); + ps.executeUpdate(); + ResultSet rs = null; + try { + rs = ps.getGeneratedKeys(); + return rs.next() ? com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1) : null; + } finally { + tryClose(rs); + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public int setFirstName(final java.lang.String firstName, final java.lang.String lastName) { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE last_name = ?"); + ps.setObject(1, firstName); + ps.setObject(2, lastName); + return ps.executeUpdate(); + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public void setFirstName(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.setObject(1, firstName); + ps.setObject(2, personNo); + ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + @Override + public void setFirstNameBlob(final byte[] firstName, final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE person_no = ?"); + ps.setBlob(1, firstName == null ? null : new java.io.ByteArrayInputStream(firstName)); + ps.setObject(2, personNo); + ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + @Override + public void setFirstNameBlob(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-8"))); + } catch (java.io.UnsupportedEncodingException e) { + throw new SQLException("String to Blob UnsupportedEncodingException", e); + } + 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; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + if(rs.next()) { +final long ret = rs.getLong(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public long getPersonNoUnusedParam(final java.lang.String lastName, final java.lang.String _bla) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + if(rs.next()) { +final long ret = rs.getLong(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.ResultSet getPeopleResultSet(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + return new com.moparisthebest.jdbc.StatementClosingResultSet(rs, ps); + } catch(Throwable e) { + tryClose(rs); + tryClose(ps); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public java.sql.ResultSet getPeopleResultSetCached(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(0, "SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + return rs; + } catch(Throwable e) { + tryClose(rs); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public java.lang.String getFirstNameColumnNames(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.String ret = rs.getString(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.lang.String getFirstName(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.String ret = rs.getString(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public int getFirstNameUpdate(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + return ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPersonColumnNames(final long personNo) 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPerson(final long personNo) 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.BuilderPerson getBuilderPerson(final long personNo) 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.BuilderPerson ret = new com.moparisthebest.jdbc.dto.BuilderPerson(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPerson(final long personNo, final java.util.Calendar cal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3, 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; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeople(final java.lang.String[] lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("TEXT", lastName); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (NOT(last_name = ANY(?)))"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeople(final java.util.List lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("TEXT", lastName.toArray(new java.lang.String[lastName.size()])); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (last_name = ANY(?))"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson[] getPeopleArray(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret.toArray(new com.moparisthebest.jdbc.dto.FieldPerson[_colret.size()]); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Iterator getPeopleIterator(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret.iterator(); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.ListIterator getPeopleListIterator(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret.listIterator(); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonMap(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, rs.getLong(3)); + _colret.put(rs.getString(1), ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map> getPersonMapList(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.Map> _colret = new java.util.HashMap>(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, rs.getLong(3)); + final java.lang.String _colkey = rs.getString(1); + java.util.List _collist = _colret.get(_colkey); + if(_collist == null) { + _collist = new java.util.ArrayList(); + _colret.put(_colkey, _collist); + } + _collist.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.lang.String getFirstName(final long personNo, final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ? and last_name = ?"); + ps.setObject(1, personNo); + ps.setObject(2, lastName); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.String ret = rs.getString(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Calendar getBirthDateCalendar(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Calendar ret = com.moparisthebest.jdbc.util.ResultSetUtil.getCalendar(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Calendar getBirthDateCalendar(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Calendar ret = com.moparisthebest.jdbc.util.ResultSetUtil.getCalendar(rs, 1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Timestamp getBirthDateTimestamp(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Timestamp ret = rs.getTimestamp(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Timestamp getBirthDateTimestamp(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Timestamp ret = rs.getTimestamp(1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Time getBirthDateTime(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Time ret = rs.getTime(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Time getBirthDateTime(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Time ret = rs.getTime(1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Date getBirthDateSqlDate(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Date ret = rs.getDate(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Date getBirthDateSqlDate(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Date ret = rs.getDate(1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Date getBirthDateUtilDate(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Date ret = com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Date getBirthDateUtilDate(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Date ret = com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPersonCleanFieldPerson(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + return clean == null ? ret : clean.clean(ret); + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPersonCleanPerson(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + return clean == null ? ret : clean.clean(ret); + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPersonCleanObject(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + return clean == null ? ret : clean.clean(ret); + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPersonCleanPersonList(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.add(clean == null ? ret : clean.clean(ret)); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonCleanPersonMap(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.put(rs.getString(1), clean == null ? ret : clean.clean(ret)); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map> getPersonCleanPersonMapList(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + final java.util.Map> _colret = new java.util.HashMap>(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + final java.lang.String _colkey = rs.getString(1); + java.util.List _collist = _colret.get(_colkey); + if(_collist == null) { + _collist = new java.util.ArrayList(); + _colret.put(_colkey, _collist); + } + _collist.add(clean == null ? ret : clean.clean(ret)); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonDynamicLimit(final long personNo, final byte maxRows) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + byte _rowCount = 0; + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.put(rs.getString(1), ret); + if(maxRows > 0 && ++_rowCount == maxRows) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonDynamicLimit(final long personNo, final short arrayMaxLength) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + short _rowCount = 0; + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.put(rs.getString(1), ret); + if(arrayMaxLength > 0 && ++_rowCount == arrayMaxLength) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPersonDynamicLimit(final long personNo, final int maxRows) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + int _rowCount = 0; + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.add(ret); + if(maxRows > 0 && ++_rowCount == maxRows) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map> getPersonDynamicLimit(final long personNo, final long rowLimit) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + long _rowCount = 0; + final java.util.Map> _colret = new java.util.HashMap>(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + final java.lang.String _colkey = rs.getString(1); + java.util.List _collist = _colret.get(_colkey); + if(_collist == null) { + _collist = new java.util.ArrayList(); + _colret.put(_colkey, _collist); + } + _collist.add(ret); + if(rowLimit > 0 && ++_rowCount == rowLimit) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPersonStaticLimitListByte(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + byte _rowCount = 0; + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.add(ret); + if(++_rowCount == 127) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPersonStaticLimitList(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + short _rowCount = 0; + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.add(ret); + if(++_rowCount == 32767) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonStaticLimitMap(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + int _rowCount = 0; + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.put(rs.getString(1), ret); + if(++_rowCount == 2147483647) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map> getPersonStaticLimitMapList(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + long _rowCount = 0; + final java.util.Map> _colret = new java.util.HashMap>(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + final java.lang.String _colkey = rs.getString(1); + java.util.List _collist = _colret.get(_colkey); + if(_collist == null) { + _collist = new java.util.ArrayList(); + _colret.put(_colkey, _collist); + } + _collist.add(ret); + if(++_rowCount == 9223372036854775807L) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeopleList(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no, birth_date, last_name, first_name from person WHERE person_no IN (?,?,?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 2), +rs.getString(4), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.util.ResultSetIterable getPeopleResultSetIterable(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no, birth_date, last_name, first_name from person WHERE person_no IN (?,?,?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + return com.moparisthebest.jdbc.util.ResultSetIterable.getResultSetIterable(rs, + rs.next() ? (_rs, _cal) -> { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 2), +_rs.getString(4), +_rs.getString(3)); + return ret; + } + : null, null).setPreparedStatementToClose(ps); + } catch(Throwable e) { + tryClose(rs); + tryClose(ps); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public com.moparisthebest.jdbc.util.ResultSetIterable getPeopleResultSetIterableCachedPreparedStatement(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(1, "SELECT person_no, birth_date, last_name, first_name from person WHERE person_no IN (?,?,?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + return com.moparisthebest.jdbc.util.ResultSetIterable.getResultSetIterable(rs, + rs.next() ? (_rs, _cal) -> { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 2), +_rs.getString(4), +_rs.getString(3)); + return ret; + } + : null, null); + } catch(Throwable e) { + tryClose(rs); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public java.util.stream.Stream getPeopleStream(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no, birth_date, last_name, first_name from person WHERE person_no IN (?,?,?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + final PreparedStatement finalPs = ps; + return com.moparisthebest.jdbc.util.ResultSetIterable.getStream(rs, + rs.next() ? (_rs, _cal) -> { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 2), +_rs.getString(4), +_rs.getString(3)); + return ret; + } + : null, null).onClose(() -> tryClose(finalPs)); + } catch(Throwable e) { + tryClose(rs); + tryClose(ps); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public java.util.stream.Stream getPeopleStreamCachedPreparedStatement(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(2, "SELECT person_no, birth_date, last_name, first_name from person WHERE person_no IN (?,?,?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + return com.moparisthebest.jdbc.util.ResultSetIterable.getStream(rs, + rs.next() ? (_rs, _cal) -> { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 2), +_rs.getString(4), +_rs.getString(3)); + return ret; + } + : null, null); + } catch(Throwable e) { + tryClose(rs); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPersonConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson( +com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FirstName getFirstNameEnum(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPersonNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val as first_name, str_val as last_name FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FirstName getEnumNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.CaseSensitivePerson getCaseSensitivePerson(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name AS M_PERSON_FIRST_NAME FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.CaseSensitivePerson ret = new com.moparisthebest.jdbc.dto.CaseSensitivePerson(); +ret.setmPersonFirstName(rs.getString(1)); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson getSameClassPathEnumPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson ret = new com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson getSameClassPathEnumPersonConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson ret = new com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson( +com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName getSameClassPathFirstNameEnum(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson getSameClassPathEnumPersonNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val as first_name, str_val as last_name FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson ret = new com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName getSameClassPathEnumNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeopleInListArray(final java.lang.Long[] personNos) { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("NUMERIC", personNos); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (person_no = ANY(?))"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeopleInListCollection(final java.util.Collection personNos) { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("NUMERIC", personNos.toArray(new java.lang.Long[personNos.size()])); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (person_no = ANY(?))"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.stream.Stream getPeopleInListStream(final java.util.stream.Stream personNos, final java.util.stream.Stream names) { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[2]; + try { + _bindArrays[0] = conn.createArrayOf("NUMERIC", personNos.toArray(java.lang.Long[]::new)); + _bindArrays[1] = conn.createArrayOf("TEXT", names.toArray(java.lang.String[]::new)); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (person_no = ANY(?)) OR (first_name = ANY(?)) OR (last_name = ANY(?))"); + ps.setArray(1, _bindArrays[0]); + ps.setArray(2, _bindArrays[1]); + ps.setArray(3, _bindArrays[1]); + rs = ps.executeQuery(); + final PreparedStatement finalPs = ps; + return com.moparisthebest.jdbc.util.ResultSetIterable.getStream(rs, + rs.next() ? (_rs, _cal) -> { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, _rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, _rs.getString(2)); + return ret; + } + : null, null).onClose(() -> tryClose(finalPs)); + } catch(Throwable e) { + tryClose(rs); + tryClose(ps); + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + } + } + + @Override + public java.time.Instant getBirthDateInstant(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.Instant ret = com.moparisthebest.jdbc.util.ResultSetUtil.getInstant(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.LocalDateTime getBirthDateLocalDateTime(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.LocalDateTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getLocalDateTime(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.LocalDate getBirthDateLocalDate(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.LocalDate ret = com.moparisthebest.jdbc.util.ResultSetUtil.getLocalDate(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.LocalTime getBirthDateLocalTime(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.LocalTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getLocalTime(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.ZonedDateTime getBirthDateZonedDateTime(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.ZonedDateTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getZonedDateTime(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.OffsetDateTime getBirthDateOffsetDateTime(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.OffsetDateTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getOffsetDateTime(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.OffsetTime getBirthDateZonedOffsetTime(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.OffsetTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getOffsetTime(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.Year getYearInt(final long valNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT num_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.Year ret = com.moparisthebest.jdbc.util.ResultSetUtil.getYear(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.Year getYearString(final long valNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.Year ret = com.moparisthebest.jdbc.util.ResultSetUtil.getYear(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.ZoneId getZoneId(final long valNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.ZoneId ret = com.moparisthebest.jdbc.util.ResultSetUtil.getZoneId(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.ZoneOffset getZoneOffsetInt(final long valNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT num_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.ZoneOffset ret = com.moparisthebest.jdbc.util.ResultSetUtil.getZoneOffset(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.time.ZoneOffset getZoneOffsetStr(final long valNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.ZoneOffset ret = com.moparisthebest.jdbc.util.ResultSetUtil.getZoneOffset(rs, 1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.Person getPersonInTransaction(final java.lang.String lastName) throws java.sql.SQLException { + return com.moparisthebest.jdbc.QueryRunner.runInTransaction(this, dao -> PersonDAO.super.getPersonInTransaction(lastName)); + } + + @Override + public byte[] getBlob(final long valNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT some_blob FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final byte[] ret = rs.getBytes(1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.lang.String[] getSinglePersonNameArray(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.String[] ret = new java.lang.String[2]; +ret[0] = rs.getString(1); +ret[1] = rs.getString(2); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getSinglePersonNameMap(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Map ret = new java.util.HashMap(); +ret.put("first_name", rs.getString(1)); +ret.put("last_name", rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + private static final java.lang.reflect.Field[] _fields = new java.lang.reflect.Field[] { + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "firstName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "lastName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "birthDate"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "personNo"), + }; + + private final PreparedStatement[] psCache = new PreparedStatement[3]; + + private PreparedStatement prepareStatement(final int index, final String sql) throws SQLException { + final PreparedStatement ps = psCache[index]; + return ps == null ? (psCache[index] = conn.prepareStatement(sql)) : ps; + } + + @Override + public void close() { + for(final PreparedStatement ps : psCache) + tryClose(ps); + if(closeConn) + tryClose(conn); + } + + public PersonDAOUnNestBean(final Factory connectionFactory) throws SQLException { + this(connectionFactory.create(), true); + } + + public PersonDAOUnNestBean(final String jndiName) throws SQLException { + this(com.moparisthebest.jdbc.codegen.JdbcMapperFactory.connectionFactory(jndiName)); + } + + @Override + public SqlBuilder sqlBuilder() { + return SqlBuilder.of(conn, com.moparisthebest.jdbc.ArrayInList.instance()); + } +} diff --git a/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/QmDaoAnyBean.java b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/QmDaoAnyBean.java new file mode 100644 index 0000000..8adfc98 --- /dev/null +++ b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/QmDaoAnyBean.java @@ -0,0 +1,1604 @@ +package com.moparisthebest.jdbc.codegen; + +import com.moparisthebest.jdbc.util.SqlBuilder; +import com.moparisthebest.jdbc.Factory; + +import java.sql.*; + +import static com.moparisthebest.jdbc.util.ResultSetUtil.*; +import static com.moparisthebest.jdbc.TryClose.tryClose; + +public class QmDaoAnyBean implements QmDao { + + private final Connection conn; + private final boolean closeConn; + + + private QmDaoAnyBean(final Connection conn, final boolean closeConn) { + this.conn = conn; + this.closeConn = closeConn; + if (this.conn == null) + throw new NullPointerException("Connection needs to be non-null for JdbcMapper..."); + } + + public QmDaoAnyBean(Connection conn) { + this(conn, false); + } + + public Connection getConnection() { + return this.conn; + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getFieldRegularPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(0, "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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.BuilderPerson getBuilderPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(1, "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.BuilderPerson ret = new com.moparisthebest.jdbc.dto.BuilderPerson(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegularAndUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(2, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(6)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegularAndUnderscoreReverse(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(3, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegularAndUnderscoreNoConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(4, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name, p.first_name AS dummy FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[5], ret, rs.getString(6)); +ret.setDummy(rs.getString(7)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegularAndUnderscoreReverseNoConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(5, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName, p.first_name AS dummy FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[5], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(6)); +ret.setDummy(rs.getString(7)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegular(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(6, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(7, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[5], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetPerson getSetRegularPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(8, "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.SetPerson ret = new com.moparisthebest.jdbc.dto.SetPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetPerson getSetRegularPersonNoConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(9, "SELECT person_no, first_name, last_name, birth_date, first_name AS dummy FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetPerson ret = new com.moparisthebest.jdbc.dto.SetPerson(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDummy(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetBoss getSetRegularAndUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(10, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetBoss ret = new com.moparisthebest.jdbc.dto.SetBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(6)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetBoss getSetRegularAndUnderscoreReverse(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(11, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetBoss ret = new com.moparisthebest.jdbc.dto.SetBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetBoss getSetRegular(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(12, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetBoss ret = new com.moparisthebest.jdbc.dto.SetBoss(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDepartment(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetBoss getSetUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(13, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetBoss ret = new com.moparisthebest.jdbc.dto.SetBoss(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirst_name(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDepartment(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldPerson getReverseFieldRegularPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(14, "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.ReverseFieldPerson ret = new com.moparisthebest.jdbc.dto.ReverseFieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldBoss getReverseFieldRegularAndUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(15, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseFieldBoss ret = new com.moparisthebest.jdbc.dto.ReverseFieldBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(6)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldBoss getReverseFieldRegularAndUnderscoreReverse(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(16, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseFieldBoss ret = new com.moparisthebest.jdbc.dto.ReverseFieldBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldBoss getReverseFieldRegular(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(17, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseFieldBoss ret = new com.moparisthebest.jdbc.dto.ReverseFieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[6], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[7], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[8], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[9], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[10], ret, rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldBoss getReverseFieldUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(18, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseFieldBoss ret = new com.moparisthebest.jdbc.dto.ReverseFieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[6], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[11], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[8], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[9], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[10], ret, rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetPerson getReverseSetRegularPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(19, "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.ReverseSetPerson ret = new com.moparisthebest.jdbc.dto.ReverseSetPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetBoss getReverseSetRegularAndUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(20, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseSetBoss ret = new com.moparisthebest.jdbc.dto.ReverseSetBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(6)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetBoss getReverseSetRegularAndUnderscoreReverse(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(21, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseSetBoss ret = new com.moparisthebest.jdbc.dto.ReverseSetBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetBoss getReverseSetRegular(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(22, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseSetBoss ret = new com.moparisthebest.jdbc.dto.ReverseSetBoss(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDepartment(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetBoss getReverseSetUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(23, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseSetBoss ret = new com.moparisthebest.jdbc.dto.ReverseSetBoss(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirst_name(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDepartment(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.lang.Long getPersonNo(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(24, "SELECT person_no FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public long getPersonNoPrimitive(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(25, "SELECT person_no FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final long ret = rs.getLong(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + } + } + + @Override + public int getPersonNoPrimitiveInt(final int personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(26, "SELECT person_no FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final int ret = rs.getInt(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.lang.Long[] getPersonNoObjectArray(final java.lang.Long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(27, "SELECT person_no FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret.toArray(new java.lang.Long[_colret.size()]); + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List> getAllNames() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(28, "SELECT first_name, last_name FROM person WHERE person_no < 4"); + rs = ps.executeQuery(); + final java.util.List> _colret = new java.util.ArrayList>(); + while(rs.next()) { +final java.util.Map ret = new java.util.HashMap(); +ret.put("first_name", rs.getString(1)); +ret.put("last_name", rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.Map[] getAllNamesArray() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(29, "SELECT first_name, last_name FROM person WHERE person_no < 4"); + rs = ps.executeQuery(); + final java.util.List> _colret = new java.util.ArrayList>(); + while(rs.next()) { +final java.util.Map ret = new java.util.HashMap(); +ret.put("first_name", rs.getString(1)); +ret.put("last_name", rs.getString(2)); + _colret.add(ret); + } + @SuppressWarnings("unchecked") + final java.util.Map[] _warnret = _colret.toArray(new java.util.Map[_colret.size()]); + return _warnret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.Map getAllNameMap() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(30, "SELECT first_name, last_name FROM person WHERE person_no < 4"); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final java.lang.String ret = rs.getString(2); + _colret.put(rs.getString(1), ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.Map getMapLongPerson() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(31, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no in (2,3,4)"); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); + _colret.put(com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1), ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.Map getMapLongLong() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(32, "SELECT person_no AS first_no, person_no AS last_no FROM person WHERE person_no < 4"); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 2); + _colret.put(com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1), ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.lang.Long[] getLongObjectArray() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(33, "SELECT 1, 2, 3 FROM person WHERE person_no = 1"); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.Long[] ret = new java.lang.Long[3]; +ret[0] = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); +ret[1] = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 2); +ret[2] = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 3); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public long[] getLongPrimitiveArray() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(34, "SELECT 1, 2, 3 FROM person WHERE person_no = 1"); + rs = ps.executeQuery(); + if(rs.next()) { +final long[] ret = new long[3]; +ret[0] = rs.getLong(1); +ret[1] = rs.getLong(2); +ret[2] = rs.getLong(3); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List> getBobTomMap() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(35, "SELECT 'bob' as bob, 'tom' as tom FROM person WHERE person_no = 1"); + rs = ps.executeQuery(); + final java.util.List> _colret = new java.util.ArrayList>(); + while(rs.next()) { +final java.util.Map ret = new java.util.HashMap(); +ret.put("bob", rs.getString(1)); +ret.put("tom", rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List> getBobTomMapCaseInsensitive() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(36, "SELECT 'bob' as bob, 'tom' as tom FROM person WHERE person_no = 1"); + rs = ps.executeQuery(); + final java.util.List> _colret = new java.util.ArrayList>(); + while(rs.next()) { +final com.moparisthebest.jdbc.util.CaseInsensitiveHashMap ret = new com.moparisthebest.jdbc.util.CaseInsensitiveHashMap(); +ret.put("bob", rs.getString(1)); +ret.put("tom", rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List getThreePeople(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(37, "SELECT person_no, first_name, last_name, birth_date from person WHERE person_no IN (?, ?, ?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.util.ResultSetIterable getThreePeopleResultSetIterable(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(38, "SELECT person_no, first_name, last_name, birth_date from person WHERE person_no IN (?, ?, ?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + return com.moparisthebest.jdbc.util.ResultSetIterable.getResultSetIterable(rs, + rs.next() ? (_rs, _cal) -> { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 4), +_rs.getString(2), +_rs.getString(3)); + return ret; + } + : null, null); + } catch(Throwable e) { + tryClose(rs); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public java.util.stream.Stream getThreePeopleStream(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(39, "SELECT person_no, first_name, last_name, birth_date from person WHERE person_no IN (?, ?, ?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + return com.moparisthebest.jdbc.util.ResultSetIterable.getStream(rs, + rs.next() ? (_rs, _cal) -> { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 4), +_rs.getString(2), +_rs.getString(3)); + return ret; + } + : null, null); + } catch(Throwable e) { + tryClose(rs); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(40, "SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPersonConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(41, "SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson( +com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FirstName getFirstName(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(42, "SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPersonNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(43, "SELECT str_val as first_name, str_val as last_name FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FirstName getFirstNameNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(44, "SELECT str_val FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.CaseSensitivePerson getCaseSensitivePerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(45, "SELECT first_name AS M_PERSON_FIRST_NAME FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.CaseSensitivePerson ret = new com.moparisthebest.jdbc.dto.CaseSensitivePerson(); +ret.setmPersonFirstName(rs.getString(1)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.Instant getBirthdateInstant(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(46, "SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.Instant ret = com.moparisthebest.jdbc.util.ResultSetUtil.getInstant(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.LocalDateTime getBirthdateLocalDateTime(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(47, "SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.LocalDateTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getLocalDateTime(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.LocalDate getBirthdateLocalDate(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(48, "SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.LocalDate ret = com.moparisthebest.jdbc.util.ResultSetUtil.getLocalDate(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.LocalTime getBirthdateLocalTime(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(49, "SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.LocalTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getLocalTime(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.ZonedDateTime getBirthdateZonedDateTime(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(50, "SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.ZonedDateTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getZonedDateTime(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.OffsetDateTime getBirthdateOffsetDateTime(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(51, "SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.OffsetDateTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getOffsetDateTime(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.OffsetTime getBirthdateOffsetTime(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(52, "SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.OffsetTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getOffsetTime(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.Year getYearInt(final long valNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(53, "SELECT num_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.Year ret = com.moparisthebest.jdbc.util.ResultSetUtil.getYear(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.Year getYearString(final long valNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(54, "SELECT str_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.Year ret = com.moparisthebest.jdbc.util.ResultSetUtil.getYear(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.ZoneId getZoneId(final long valNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(55, "SELECT str_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.ZoneId ret = com.moparisthebest.jdbc.util.ResultSetUtil.getZoneId(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.ZoneOffset getZoneOffsetInt(final long valNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(56, "SELECT str_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.ZoneOffset ret = com.moparisthebest.jdbc.util.ResultSetUtil.getZoneOffset(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.ZoneOffset getZoneOffsetString(final long valNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(57, "SELECT str_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.ZoneOffset ret = com.moparisthebest.jdbc.util.ResultSetUtil.getZoneOffset(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List getFieldPeopleStream(final java.util.stream.Stream personNos) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("NUMERIC", personNos.toArray(java.lang.Long[]::new)); + ps = this.prepareStatement(58, "SELECT person_no, first_name, last_name, birth_date from person WHERE (person_no = ANY(?)) ORDER BY person_no"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + } + } + + @Override + public java.util.List getFieldPeople(final java.util.List personNos) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("NUMERIC", personNos.toArray(new java.lang.Long[personNos.size()])); + ps = this.prepareStatement(59, "SELECT person_no, first_name, last_name, birth_date from person WHERE (person_no = ANY(?)) ORDER BY person_no"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + } + } + + @Override + public java.util.List getFieldPeopleByName(final java.util.List personNos, final java.util.List names) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[2]; + try { + _bindArrays[0] = conn.createArrayOf("NUMERIC", personNos.toArray(new java.lang.Long[personNos.size()])); + _bindArrays[1] = conn.createArrayOf("TEXT", names.toArray(new java.lang.String[names.size()])); + ps = this.prepareStatement(60, "SELECT person_no, first_name, last_name, birth_date from person WHERE (person_no = ANY(?)) AND ((first_name = ANY(?)) OR (last_name = ANY(?))) ORDER BY person_no"); + ps.setArray(1, _bindArrays[0]); + ps.setArray(2, _bindArrays[1]); + ps.setArray(3, _bindArrays[1]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + } + } + + @Override + public java.util.List getFieldPeopleNotIn(final java.util.List personNos) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("NUMERIC", personNos.toArray(new java.lang.Long[personNos.size()])); + ps = this.prepareStatement(61, "SELECT person_no, first_name, last_name, birth_date from person WHERE (NOT(person_no = ANY(?))) ORDER BY person_no"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + } + } + + @Override + public long insertGetGeneratedKeyOracle(final long value) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO a_thaoeu_table (a_thaoeu_table_no, a_thaoeu_table_val) VALUES (a_thaoeu_table_seq.nextval, ?)", java.sql.Statement.RETURN_GENERATED_KEYS); + ps.setObject(1, value); + ps.executeUpdate(); + ResultSet rs = null; + try { + rs = ps.getGeneratedKeys(); + return rs.next() ? rs.getLong(1) : 0; + } finally { + tryClose(rs); + } + } finally { + tryClose(ps); + } + } + + @Override + public long insertGetGeneratedKey(final long value) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO a_thaoeu_table (a_thaoeu_table_val) VALUES (?)", java.sql.Statement.RETURN_GENERATED_KEYS); + ps.setObject(1, value); + ps.executeUpdate(); + ResultSet rs = null; + try { + rs = ps.getGeneratedKeys(); + return rs.next() ? rs.getLong(1) : 0; + } finally { + tryClose(rs); + } + } finally { + tryClose(ps); + } + } + + @Override + public java.util.List selectRandomSql(final java.lang.String sql) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE " + sql + ""); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List selectRandomSqlBuilder(final com.moparisthebest.jdbc.util.SqlBuilder sql) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE " + sql + ""); + int psParamCount = 0; + psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, sql); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List selectRandomSql(final long personNo1, final java.lang.String sql, final java.lang.String firstName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE person_no = ? " + sql + " OR first_name = ?"); + ps.setObject(1, personNo1); + ps.setObject(2, firstName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List selectRandomSqlBuilder(final long personNo1, final com.moparisthebest.jdbc.util.Bindable sql, final java.lang.String firstName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE person_no = ? " + sql + " OR first_name = ?"); + int psParamCount = 0; + ps.setObject(++psParamCount, personNo1); + psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, sql.getBindObject()); + ps.setObject(++psParamCount, firstName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public void insertRandomSqlCollection(final java.util.Collection sql) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT " + sql + ""); + int psParamCount = 0; + psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, sql); + ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + @Override + public void insertRandomSqlIterable(final java.lang.Iterable sql) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT " + sql + ""); + int psParamCount = 0; + psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, sql); + ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + private static final java.lang.reflect.Field[] _fields = new java.lang.reflect.Field[] { + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "personNo"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "firstName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "lastName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "birthDate"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldBoss.class, "department"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldBoss.class, "first_name"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldPerson.class, "personNo"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldBoss.class, "firstName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldPerson.class, "lastName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldPerson.class, "birthDate"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldBoss.class, "department"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldPerson.class, "first_name"), + }; + + private final PreparedStatement[] psCache = new PreparedStatement[62]; + + private PreparedStatement prepareStatement(final int index, final String sql) throws SQLException { + final PreparedStatement ps = psCache[index]; + return ps == null ? (psCache[index] = conn.prepareStatement(sql)) : ps; + } + + @Override + public void close() { + for(final PreparedStatement ps : psCache) + tryClose(ps); + } + + public QmDaoAnyBean(final Factory connectionFactory) throws SQLException { + this(connectionFactory.create(), true); + } + + public QmDaoAnyBean(final String jndiName) throws SQLException { + this(com.moparisthebest.jdbc.codegen.JdbcMapperFactory.connectionFactory(jndiName)); + } + + @Override + public SqlBuilder sqlBuilder() { + return SqlBuilder.of(conn, com.moparisthebest.jdbc.ArrayInList.instance()); + } +} diff --git a/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/QmDaoBean.java b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/QmDaoBean.java new file mode 100644 index 0000000..10163a1 --- /dev/null +++ b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/QmDaoBean.java @@ -0,0 +1,1602 @@ +package com.moparisthebest.jdbc.codegen; + +import com.moparisthebest.jdbc.util.SqlBuilder; +import com.moparisthebest.jdbc.Factory; + +import java.sql.*; + +import static com.moparisthebest.jdbc.util.ResultSetUtil.*; +import static com.moparisthebest.jdbc.TryClose.tryClose; + +public class QmDaoBean implements QmDao { + + private final Connection conn; + private final boolean closeConn; + + + private QmDaoBean(final Connection conn, final boolean closeConn) { + this.conn = conn; + this.closeConn = closeConn; + if (this.conn == null) + throw new NullPointerException("Connection needs to be non-null for JdbcMapper..."); + } + + public QmDaoBean(Connection conn) { + this(conn, false); + } + + public Connection getConnection() { + return this.conn; + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getFieldRegularPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(0, "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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.BuilderPerson getBuilderPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(1, "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.BuilderPerson ret = new com.moparisthebest.jdbc.dto.BuilderPerson(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegularAndUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(2, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(6)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegularAndUnderscoreReverse(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(3, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegularAndUnderscoreNoConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(4, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name, p.first_name AS dummy FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[5], ret, rs.getString(6)); +ret.setDummy(rs.getString(7)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegularAndUnderscoreReverseNoConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(5, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName, p.first_name AS dummy FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[5], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(6)); +ret.setDummy(rs.getString(7)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegular(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(6, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(7, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[5], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetPerson getSetRegularPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(8, "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.SetPerson ret = new com.moparisthebest.jdbc.dto.SetPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetPerson getSetRegularPersonNoConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(9, "SELECT person_no, first_name, last_name, birth_date, first_name AS dummy FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetPerson ret = new com.moparisthebest.jdbc.dto.SetPerson(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDummy(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetBoss getSetRegularAndUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(10, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetBoss ret = new com.moparisthebest.jdbc.dto.SetBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(6)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetBoss getSetRegularAndUnderscoreReverse(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(11, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetBoss ret = new com.moparisthebest.jdbc.dto.SetBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetBoss getSetRegular(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(12, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetBoss ret = new com.moparisthebest.jdbc.dto.SetBoss(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDepartment(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetBoss getSetUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(13, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetBoss ret = new com.moparisthebest.jdbc.dto.SetBoss(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirst_name(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDepartment(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldPerson getReverseFieldRegularPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(14, "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.ReverseFieldPerson ret = new com.moparisthebest.jdbc.dto.ReverseFieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldBoss getReverseFieldRegularAndUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(15, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseFieldBoss ret = new com.moparisthebest.jdbc.dto.ReverseFieldBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(6)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldBoss getReverseFieldRegularAndUnderscoreReverse(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(16, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseFieldBoss ret = new com.moparisthebest.jdbc.dto.ReverseFieldBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldBoss getReverseFieldRegular(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(17, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseFieldBoss ret = new com.moparisthebest.jdbc.dto.ReverseFieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[6], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[7], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[8], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[9], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[10], ret, rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldBoss getReverseFieldUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(18, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseFieldBoss ret = new com.moparisthebest.jdbc.dto.ReverseFieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[6], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[11], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[8], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[9], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[10], ret, rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetPerson getReverseSetRegularPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(19, "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.ReverseSetPerson ret = new com.moparisthebest.jdbc.dto.ReverseSetPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetBoss getReverseSetRegularAndUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(20, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseSetBoss ret = new com.moparisthebest.jdbc.dto.ReverseSetBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(6)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetBoss getReverseSetRegularAndUnderscoreReverse(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(21, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseSetBoss ret = new com.moparisthebest.jdbc.dto.ReverseSetBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetBoss getReverseSetRegular(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(22, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseSetBoss ret = new com.moparisthebest.jdbc.dto.ReverseSetBoss(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDepartment(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetBoss getReverseSetUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(23, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseSetBoss ret = new com.moparisthebest.jdbc.dto.ReverseSetBoss(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirst_name(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDepartment(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.lang.Long getPersonNo(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(24, "SELECT person_no FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public long getPersonNoPrimitive(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(25, "SELECT person_no FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final long ret = rs.getLong(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + } + } + + @Override + public int getPersonNoPrimitiveInt(final int personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(26, "SELECT person_no FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final int ret = rs.getInt(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.lang.Long[] getPersonNoObjectArray(final java.lang.Long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(27, "SELECT person_no FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret.toArray(new java.lang.Long[_colret.size()]); + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List> getAllNames() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(28, "SELECT first_name, last_name FROM person WHERE person_no < 4"); + rs = ps.executeQuery(); + final java.util.List> _colret = new java.util.ArrayList>(); + while(rs.next()) { +final java.util.Map ret = new java.util.HashMap(); +ret.put("first_name", rs.getString(1)); +ret.put("last_name", rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.Map[] getAllNamesArray() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(29, "SELECT first_name, last_name FROM person WHERE person_no < 4"); + rs = ps.executeQuery(); + final java.util.List> _colret = new java.util.ArrayList>(); + while(rs.next()) { +final java.util.Map ret = new java.util.HashMap(); +ret.put("first_name", rs.getString(1)); +ret.put("last_name", rs.getString(2)); + _colret.add(ret); + } + @SuppressWarnings("unchecked") + final java.util.Map[] _warnret = _colret.toArray(new java.util.Map[_colret.size()]); + return _warnret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.Map getAllNameMap() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(30, "SELECT first_name, last_name FROM person WHERE person_no < 4"); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final java.lang.String ret = rs.getString(2); + _colret.put(rs.getString(1), ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.Map getMapLongPerson() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(31, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no in (2,3,4)"); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); + _colret.put(com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1), ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.Map getMapLongLong() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(32, "SELECT person_no AS first_no, person_no AS last_no FROM person WHERE person_no < 4"); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 2); + _colret.put(com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1), ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.lang.Long[] getLongObjectArray() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(33, "SELECT 1, 2, 3 FROM person WHERE person_no = 1"); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.Long[] ret = new java.lang.Long[3]; +ret[0] = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); +ret[1] = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 2); +ret[2] = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 3); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public long[] getLongPrimitiveArray() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(34, "SELECT 1, 2, 3 FROM person WHERE person_no = 1"); + rs = ps.executeQuery(); + if(rs.next()) { +final long[] ret = new long[3]; +ret[0] = rs.getLong(1); +ret[1] = rs.getLong(2); +ret[2] = rs.getLong(3); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List> getBobTomMap() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(35, "SELECT 'bob' as bob, 'tom' as tom FROM person WHERE person_no = 1"); + rs = ps.executeQuery(); + final java.util.List> _colret = new java.util.ArrayList>(); + while(rs.next()) { +final java.util.Map ret = new java.util.HashMap(); +ret.put("bob", rs.getString(1)); +ret.put("tom", rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List> getBobTomMapCaseInsensitive() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(36, "SELECT 'bob' as bob, 'tom' as tom FROM person WHERE person_no = 1"); + rs = ps.executeQuery(); + final java.util.List> _colret = new java.util.ArrayList>(); + while(rs.next()) { +final com.moparisthebest.jdbc.util.CaseInsensitiveHashMap ret = new com.moparisthebest.jdbc.util.CaseInsensitiveHashMap(); +ret.put("bob", rs.getString(1)); +ret.put("tom", rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List getThreePeople(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(37, "SELECT person_no, first_name, last_name, birth_date from person WHERE person_no IN (?, ?, ?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.util.ResultSetIterable getThreePeopleResultSetIterable(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(38, "SELECT person_no, first_name, last_name, birth_date from person WHERE person_no IN (?, ?, ?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + return com.moparisthebest.jdbc.util.ResultSetIterable.getResultSetIterable(rs, + rs.next() ? (_rs, _cal) -> { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 4), +_rs.getString(2), +_rs.getString(3)); + return ret; + } + : null, null); + } catch(Throwable e) { + tryClose(rs); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public java.util.stream.Stream getThreePeopleStream(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(39, "SELECT person_no, first_name, last_name, birth_date from person WHERE person_no IN (?, ?, ?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + return com.moparisthebest.jdbc.util.ResultSetIterable.getStream(rs, + rs.next() ? (_rs, _cal) -> { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 4), +_rs.getString(2), +_rs.getString(3)); + return ret; + } + : null, null); + } catch(Throwable e) { + tryClose(rs); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(40, "SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPersonConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(41, "SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson( +com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FirstName getFirstName(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(42, "SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPersonNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(43, "SELECT str_val as first_name, str_val as last_name FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FirstName getFirstNameNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(44, "SELECT str_val FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.CaseSensitivePerson getCaseSensitivePerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(45, "SELECT first_name AS M_PERSON_FIRST_NAME FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.CaseSensitivePerson ret = new com.moparisthebest.jdbc.dto.CaseSensitivePerson(); +ret.setmPersonFirstName(rs.getString(1)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.Instant getBirthdateInstant(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(46, "SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.Instant ret = com.moparisthebest.jdbc.util.ResultSetUtil.getInstant(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.LocalDateTime getBirthdateLocalDateTime(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(47, "SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.LocalDateTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getLocalDateTime(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.LocalDate getBirthdateLocalDate(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(48, "SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.LocalDate ret = com.moparisthebest.jdbc.util.ResultSetUtil.getLocalDate(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.LocalTime getBirthdateLocalTime(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(49, "SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.LocalTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getLocalTime(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.ZonedDateTime getBirthdateZonedDateTime(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(50, "SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.ZonedDateTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getZonedDateTime(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.OffsetDateTime getBirthdateOffsetDateTime(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(51, "SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.OffsetDateTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getOffsetDateTime(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.OffsetTime getBirthdateOffsetTime(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(52, "SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.OffsetTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getOffsetTime(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.Year getYearInt(final long valNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(53, "SELECT num_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.Year ret = com.moparisthebest.jdbc.util.ResultSetUtil.getYear(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.Year getYearString(final long valNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(54, "SELECT str_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.Year ret = com.moparisthebest.jdbc.util.ResultSetUtil.getYear(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.ZoneId getZoneId(final long valNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(55, "SELECT str_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.ZoneId ret = com.moparisthebest.jdbc.util.ResultSetUtil.getZoneId(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.ZoneOffset getZoneOffsetInt(final long valNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(56, "SELECT str_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.ZoneOffset ret = com.moparisthebest.jdbc.util.ResultSetUtil.getZoneOffset(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.ZoneOffset getZoneOffsetString(final long valNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(57, "SELECT str_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.ZoneOffset ret = com.moparisthebest.jdbc.util.ResultSetUtil.getZoneOffset(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List getFieldPeopleStream(final java.util.stream.Stream personNos) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + final java.lang.Long[] _personNosStreamAsBindArray = personNos.toArray(java.lang.Long[]::new); + ps = conn.prepareStatement("SELECT person_no, first_name, last_name, birth_date from person WHERE " + com.moparisthebest.jdbc.util.InListUtil.toInList("person_no", _personNosStreamAsBindArray) + " ORDER BY person_no"); + int psParamCount = 0; + for(final java.lang.Long _bindInListParam : _personNosStreamAsBindArray) + ps.setObject(++psParamCount, _bindInListParam); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getFieldPeople(final java.util.List personNos) 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 " + com.moparisthebest.jdbc.util.InListUtil.toInList("person_no", personNos) + " ORDER BY person_no"); + int psParamCount = 0; + for(final java.lang.Long _bindInListParam : personNos) + ps.setObject(++psParamCount, _bindInListParam); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getFieldPeopleByName(final java.util.List personNos, final java.util.List names) 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 " + com.moparisthebest.jdbc.util.InListUtil.toInList("person_no", personNos) + " AND (" + com.moparisthebest.jdbc.util.InListUtil.toInList("first_name", names) + " OR " + com.moparisthebest.jdbc.util.InListUtil.toInList("last_name", names) + ") ORDER BY person_no"); + int psParamCount = 0; + for(final java.lang.Long _bindInListParam : personNos) + ps.setObject(++psParamCount, _bindInListParam); + for(final java.lang.String _bindInListParam : names) + ps.setObject(++psParamCount, _bindInListParam); + for(final java.lang.String _bindInListParam : names) + ps.setObject(++psParamCount, _bindInListParam); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getFieldPeopleNotIn(final java.util.List personNos) 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 " + com.moparisthebest.jdbc.util.InListUtil.toNotInList("person_no", personNos) + " ORDER BY person_no"); + int psParamCount = 0; + for(final java.lang.Long _bindInListParam : personNos) + ps.setObject(++psParamCount, _bindInListParam); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public long insertGetGeneratedKeyOracle(final long value) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO a_thaoeu_table (a_thaoeu_table_no, a_thaoeu_table_val) VALUES (a_thaoeu_table_seq.nextval, ?)", java.sql.Statement.RETURN_GENERATED_KEYS); + ps.setObject(1, value); + ps.executeUpdate(); + ResultSet rs = null; + try { + rs = ps.getGeneratedKeys(); + return rs.next() ? rs.getLong(1) : 0; + } finally { + tryClose(rs); + } + } finally { + tryClose(ps); + } + } + + @Override + public long insertGetGeneratedKey(final long value) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO a_thaoeu_table (a_thaoeu_table_val) VALUES (?)", java.sql.Statement.RETURN_GENERATED_KEYS); + ps.setObject(1, value); + ps.executeUpdate(); + ResultSet rs = null; + try { + rs = ps.getGeneratedKeys(); + return rs.next() ? rs.getLong(1) : 0; + } finally { + tryClose(rs); + } + } finally { + tryClose(ps); + } + } + + @Override + public java.util.List selectRandomSql(final java.lang.String sql) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE " + sql + ""); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List selectRandomSqlBuilder(final com.moparisthebest.jdbc.util.SqlBuilder sql) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE " + sql + ""); + int psParamCount = 0; + psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, sql); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List selectRandomSql(final long personNo1, final java.lang.String sql, final java.lang.String firstName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE person_no = ? " + sql + " OR first_name = ?"); + ps.setObject(1, personNo1); + ps.setObject(2, firstName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List selectRandomSqlBuilder(final long personNo1, final com.moparisthebest.jdbc.util.Bindable sql, final java.lang.String firstName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE person_no = ? " + sql + " OR first_name = ?"); + int psParamCount = 0; + ps.setObject(++psParamCount, personNo1); + psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, sql.getBindObject()); + ps.setObject(++psParamCount, firstName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public void insertRandomSqlCollection(final java.util.Collection sql) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT " + sql + ""); + int psParamCount = 0; + psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, sql); + ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + @Override + public void insertRandomSqlIterable(final java.lang.Iterable sql) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT " + sql + ""); + int psParamCount = 0; + psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, sql); + ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + private static final java.lang.reflect.Field[] _fields = new java.lang.reflect.Field[] { + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "personNo"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "firstName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "lastName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "birthDate"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldBoss.class, "department"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldBoss.class, "first_name"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldPerson.class, "personNo"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldBoss.class, "firstName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldPerson.class, "lastName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldPerson.class, "birthDate"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldBoss.class, "department"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldPerson.class, "first_name"), + }; + + private final PreparedStatement[] psCache = new PreparedStatement[58]; + + private PreparedStatement prepareStatement(final int index, final String sql) throws SQLException { + final PreparedStatement ps = psCache[index]; + return ps == null ? (psCache[index] = conn.prepareStatement(sql)) : ps; + } + + @Override + public void close() { + for(final PreparedStatement ps : psCache) + tryClose(ps); + } + + public QmDaoBean(final Factory connectionFactory) throws SQLException { + this(connectionFactory.create(), true); + } + + public QmDaoBean(final String jndiName) throws SQLException { + this(com.moparisthebest.jdbc.codegen.JdbcMapperFactory.connectionFactory(jndiName)); + } + + @Override + public SqlBuilder sqlBuilder() { + return SqlBuilder.of(conn, com.moparisthebest.jdbc.BindInList.instance()); + } +} diff --git a/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/QmDaoBindBean.java b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/QmDaoBindBean.java new file mode 100644 index 0000000..0b167f9 --- /dev/null +++ b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/QmDaoBindBean.java @@ -0,0 +1,1602 @@ +package com.moparisthebest.jdbc.codegen; + +import com.moparisthebest.jdbc.util.SqlBuilder; +import com.moparisthebest.jdbc.Factory; + +import java.sql.*; + +import static com.moparisthebest.jdbc.util.ResultSetUtil.*; +import static com.moparisthebest.jdbc.TryClose.tryClose; + +public class QmDaoBindBean implements QmDao { + + private final Connection conn; + private final boolean closeConn; + + + private QmDaoBindBean(final Connection conn, final boolean closeConn) { + this.conn = conn; + this.closeConn = closeConn; + if (this.conn == null) + throw new NullPointerException("Connection needs to be non-null for JdbcMapper..."); + } + + public QmDaoBindBean(Connection conn) { + this(conn, false); + } + + public Connection getConnection() { + return this.conn; + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getFieldRegularPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(0, "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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.BuilderPerson getBuilderPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(1, "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.BuilderPerson ret = new com.moparisthebest.jdbc.dto.BuilderPerson(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegularAndUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(2, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(6)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegularAndUnderscoreReverse(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(3, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegularAndUnderscoreNoConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(4, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name, p.first_name AS dummy FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[5], ret, rs.getString(6)); +ret.setDummy(rs.getString(7)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegularAndUnderscoreReverseNoConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(5, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName, p.first_name AS dummy FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[5], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(6)); +ret.setDummy(rs.getString(7)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegular(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(6, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(7, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[5], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetPerson getSetRegularPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(8, "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.SetPerson ret = new com.moparisthebest.jdbc.dto.SetPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetPerson getSetRegularPersonNoConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(9, "SELECT person_no, first_name, last_name, birth_date, first_name AS dummy FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetPerson ret = new com.moparisthebest.jdbc.dto.SetPerson(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDummy(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetBoss getSetRegularAndUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(10, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetBoss ret = new com.moparisthebest.jdbc.dto.SetBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(6)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetBoss getSetRegularAndUnderscoreReverse(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(11, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetBoss ret = new com.moparisthebest.jdbc.dto.SetBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetBoss getSetRegular(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(12, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetBoss ret = new com.moparisthebest.jdbc.dto.SetBoss(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDepartment(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetBoss getSetUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(13, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetBoss ret = new com.moparisthebest.jdbc.dto.SetBoss(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirst_name(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDepartment(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldPerson getReverseFieldRegularPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(14, "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.ReverseFieldPerson ret = new com.moparisthebest.jdbc.dto.ReverseFieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldBoss getReverseFieldRegularAndUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(15, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseFieldBoss ret = new com.moparisthebest.jdbc.dto.ReverseFieldBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(6)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldBoss getReverseFieldRegularAndUnderscoreReverse(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(16, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseFieldBoss ret = new com.moparisthebest.jdbc.dto.ReverseFieldBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldBoss getReverseFieldRegular(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(17, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseFieldBoss ret = new com.moparisthebest.jdbc.dto.ReverseFieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[6], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[7], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[8], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[9], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[10], ret, rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldBoss getReverseFieldUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(18, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseFieldBoss ret = new com.moparisthebest.jdbc.dto.ReverseFieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[6], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[11], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[8], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[9], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[10], ret, rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetPerson getReverseSetRegularPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(19, "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.ReverseSetPerson ret = new com.moparisthebest.jdbc.dto.ReverseSetPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetBoss getReverseSetRegularAndUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(20, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseSetBoss ret = new com.moparisthebest.jdbc.dto.ReverseSetBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(6)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetBoss getReverseSetRegularAndUnderscoreReverse(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(21, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseSetBoss ret = new com.moparisthebest.jdbc.dto.ReverseSetBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetBoss getReverseSetRegular(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(22, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseSetBoss ret = new com.moparisthebest.jdbc.dto.ReverseSetBoss(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDepartment(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetBoss getReverseSetUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(23, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseSetBoss ret = new com.moparisthebest.jdbc.dto.ReverseSetBoss(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirst_name(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDepartment(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.lang.Long getPersonNo(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(24, "SELECT person_no FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public long getPersonNoPrimitive(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(25, "SELECT person_no FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final long ret = rs.getLong(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + } + } + + @Override + public int getPersonNoPrimitiveInt(final int personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(26, "SELECT person_no FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final int ret = rs.getInt(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.lang.Long[] getPersonNoObjectArray(final java.lang.Long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(27, "SELECT person_no FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret.toArray(new java.lang.Long[_colret.size()]); + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List> getAllNames() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(28, "SELECT first_name, last_name FROM person WHERE person_no < 4"); + rs = ps.executeQuery(); + final java.util.List> _colret = new java.util.ArrayList>(); + while(rs.next()) { +final java.util.Map ret = new java.util.HashMap(); +ret.put("first_name", rs.getString(1)); +ret.put("last_name", rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.Map[] getAllNamesArray() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(29, "SELECT first_name, last_name FROM person WHERE person_no < 4"); + rs = ps.executeQuery(); + final java.util.List> _colret = new java.util.ArrayList>(); + while(rs.next()) { +final java.util.Map ret = new java.util.HashMap(); +ret.put("first_name", rs.getString(1)); +ret.put("last_name", rs.getString(2)); + _colret.add(ret); + } + @SuppressWarnings("unchecked") + final java.util.Map[] _warnret = _colret.toArray(new java.util.Map[_colret.size()]); + return _warnret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.Map getAllNameMap() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(30, "SELECT first_name, last_name FROM person WHERE person_no < 4"); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final java.lang.String ret = rs.getString(2); + _colret.put(rs.getString(1), ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.Map getMapLongPerson() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(31, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no in (2,3,4)"); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); + _colret.put(com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1), ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.Map getMapLongLong() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(32, "SELECT person_no AS first_no, person_no AS last_no FROM person WHERE person_no < 4"); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 2); + _colret.put(com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1), ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.lang.Long[] getLongObjectArray() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(33, "SELECT 1, 2, 3 FROM person WHERE person_no = 1"); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.Long[] ret = new java.lang.Long[3]; +ret[0] = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); +ret[1] = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 2); +ret[2] = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 3); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public long[] getLongPrimitiveArray() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(34, "SELECT 1, 2, 3 FROM person WHERE person_no = 1"); + rs = ps.executeQuery(); + if(rs.next()) { +final long[] ret = new long[3]; +ret[0] = rs.getLong(1); +ret[1] = rs.getLong(2); +ret[2] = rs.getLong(3); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List> getBobTomMap() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(35, "SELECT 'bob' as bob, 'tom' as tom FROM person WHERE person_no = 1"); + rs = ps.executeQuery(); + final java.util.List> _colret = new java.util.ArrayList>(); + while(rs.next()) { +final java.util.Map ret = new java.util.HashMap(); +ret.put("bob", rs.getString(1)); +ret.put("tom", rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List> getBobTomMapCaseInsensitive() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(36, "SELECT 'bob' as bob, 'tom' as tom FROM person WHERE person_no = 1"); + rs = ps.executeQuery(); + final java.util.List> _colret = new java.util.ArrayList>(); + while(rs.next()) { +final com.moparisthebest.jdbc.util.CaseInsensitiveHashMap ret = new com.moparisthebest.jdbc.util.CaseInsensitiveHashMap(); +ret.put("bob", rs.getString(1)); +ret.put("tom", rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List getThreePeople(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(37, "SELECT person_no, first_name, last_name, birth_date from person WHERE person_no IN (?, ?, ?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.util.ResultSetIterable getThreePeopleResultSetIterable(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(38, "SELECT person_no, first_name, last_name, birth_date from person WHERE person_no IN (?, ?, ?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + return com.moparisthebest.jdbc.util.ResultSetIterable.getResultSetIterable(rs, + rs.next() ? (_rs, _cal) -> { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 4), +_rs.getString(2), +_rs.getString(3)); + return ret; + } + : null, null); + } catch(Throwable e) { + tryClose(rs); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public java.util.stream.Stream getThreePeopleStream(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(39, "SELECT person_no, first_name, last_name, birth_date from person WHERE person_no IN (?, ?, ?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + return com.moparisthebest.jdbc.util.ResultSetIterable.getStream(rs, + rs.next() ? (_rs, _cal) -> { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 4), +_rs.getString(2), +_rs.getString(3)); + return ret; + } + : null, null); + } catch(Throwable e) { + tryClose(rs); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(40, "SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPersonConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(41, "SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson( +com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FirstName getFirstName(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(42, "SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPersonNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(43, "SELECT str_val as first_name, str_val as last_name FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FirstName getFirstNameNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(44, "SELECT str_val FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.CaseSensitivePerson getCaseSensitivePerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(45, "SELECT first_name AS M_PERSON_FIRST_NAME FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.CaseSensitivePerson ret = new com.moparisthebest.jdbc.dto.CaseSensitivePerson(); +ret.setmPersonFirstName(rs.getString(1)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.Instant getBirthdateInstant(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(46, "SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.Instant ret = com.moparisthebest.jdbc.util.ResultSetUtil.getInstant(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.LocalDateTime getBirthdateLocalDateTime(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(47, "SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.LocalDateTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getLocalDateTime(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.LocalDate getBirthdateLocalDate(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(48, "SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.LocalDate ret = com.moparisthebest.jdbc.util.ResultSetUtil.getLocalDate(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.LocalTime getBirthdateLocalTime(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(49, "SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.LocalTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getLocalTime(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.ZonedDateTime getBirthdateZonedDateTime(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(50, "SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.ZonedDateTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getZonedDateTime(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.OffsetDateTime getBirthdateOffsetDateTime(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(51, "SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.OffsetDateTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getOffsetDateTime(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.OffsetTime getBirthdateOffsetTime(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(52, "SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.OffsetTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getOffsetTime(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.Year getYearInt(final long valNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(53, "SELECT num_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.Year ret = com.moparisthebest.jdbc.util.ResultSetUtil.getYear(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.Year getYearString(final long valNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(54, "SELECT str_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.Year ret = com.moparisthebest.jdbc.util.ResultSetUtil.getYear(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.ZoneId getZoneId(final long valNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(55, "SELECT str_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.ZoneId ret = com.moparisthebest.jdbc.util.ResultSetUtil.getZoneId(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.ZoneOffset getZoneOffsetInt(final long valNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(56, "SELECT str_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.ZoneOffset ret = com.moparisthebest.jdbc.util.ResultSetUtil.getZoneOffset(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.ZoneOffset getZoneOffsetString(final long valNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(57, "SELECT str_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.ZoneOffset ret = com.moparisthebest.jdbc.util.ResultSetUtil.getZoneOffset(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List getFieldPeopleStream(final java.util.stream.Stream personNos) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + final java.lang.Long[] _personNosStreamAsBindArray = personNos.toArray(java.lang.Long[]::new); + ps = conn.prepareStatement("SELECT person_no, first_name, last_name, birth_date from person WHERE " + com.moparisthebest.jdbc.util.InListUtil.toInList("person_no", _personNosStreamAsBindArray) + " ORDER BY person_no"); + int psParamCount = 0; + for(final java.lang.Long _bindInListParam : _personNosStreamAsBindArray) + ps.setObject(++psParamCount, _bindInListParam); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getFieldPeople(final java.util.List personNos) 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 " + com.moparisthebest.jdbc.util.InListUtil.toInList("person_no", personNos) + " ORDER BY person_no"); + int psParamCount = 0; + for(final java.lang.Long _bindInListParam : personNos) + ps.setObject(++psParamCount, _bindInListParam); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getFieldPeopleByName(final java.util.List personNos, final java.util.List names) 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 " + com.moparisthebest.jdbc.util.InListUtil.toInList("person_no", personNos) + " AND (" + com.moparisthebest.jdbc.util.InListUtil.toInList("first_name", names) + " OR " + com.moparisthebest.jdbc.util.InListUtil.toInList("last_name", names) + ") ORDER BY person_no"); + int psParamCount = 0; + for(final java.lang.Long _bindInListParam : personNos) + ps.setObject(++psParamCount, _bindInListParam); + for(final java.lang.String _bindInListParam : names) + ps.setObject(++psParamCount, _bindInListParam); + for(final java.lang.String _bindInListParam : names) + ps.setObject(++psParamCount, _bindInListParam); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getFieldPeopleNotIn(final java.util.List personNos) 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 " + com.moparisthebest.jdbc.util.InListUtil.toNotInList("person_no", personNos) + " ORDER BY person_no"); + int psParamCount = 0; + for(final java.lang.Long _bindInListParam : personNos) + ps.setObject(++psParamCount, _bindInListParam); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public long insertGetGeneratedKeyOracle(final long value) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO a_thaoeu_table (a_thaoeu_table_no, a_thaoeu_table_val) VALUES (a_thaoeu_table_seq.nextval, ?)", java.sql.Statement.RETURN_GENERATED_KEYS); + ps.setObject(1, value); + ps.executeUpdate(); + ResultSet rs = null; + try { + rs = ps.getGeneratedKeys(); + return rs.next() ? rs.getLong(1) : 0; + } finally { + tryClose(rs); + } + } finally { + tryClose(ps); + } + } + + @Override + public long insertGetGeneratedKey(final long value) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO a_thaoeu_table (a_thaoeu_table_val) VALUES (?)", java.sql.Statement.RETURN_GENERATED_KEYS); + ps.setObject(1, value); + ps.executeUpdate(); + ResultSet rs = null; + try { + rs = ps.getGeneratedKeys(); + return rs.next() ? rs.getLong(1) : 0; + } finally { + tryClose(rs); + } + } finally { + tryClose(ps); + } + } + + @Override + public java.util.List selectRandomSql(final java.lang.String sql) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE " + sql + ""); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List selectRandomSqlBuilder(final com.moparisthebest.jdbc.util.SqlBuilder sql) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE " + sql + ""); + int psParamCount = 0; + psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, sql); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List selectRandomSql(final long personNo1, final java.lang.String sql, final java.lang.String firstName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE person_no = ? " + sql + " OR first_name = ?"); + ps.setObject(1, personNo1); + ps.setObject(2, firstName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List selectRandomSqlBuilder(final long personNo1, final com.moparisthebest.jdbc.util.Bindable sql, final java.lang.String firstName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE person_no = ? " + sql + " OR first_name = ?"); + int psParamCount = 0; + ps.setObject(++psParamCount, personNo1); + psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, sql.getBindObject()); + ps.setObject(++psParamCount, firstName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public void insertRandomSqlCollection(final java.util.Collection sql) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT " + sql + ""); + int psParamCount = 0; + psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, sql); + ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + @Override + public void insertRandomSqlIterable(final java.lang.Iterable sql) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT " + sql + ""); + int psParamCount = 0; + psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, sql); + ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + private static final java.lang.reflect.Field[] _fields = new java.lang.reflect.Field[] { + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "personNo"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "firstName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "lastName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "birthDate"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldBoss.class, "department"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldBoss.class, "first_name"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldPerson.class, "personNo"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldBoss.class, "firstName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldPerson.class, "lastName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldPerson.class, "birthDate"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldBoss.class, "department"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldPerson.class, "first_name"), + }; + + private final PreparedStatement[] psCache = new PreparedStatement[58]; + + private PreparedStatement prepareStatement(final int index, final String sql) throws SQLException { + final PreparedStatement ps = psCache[index]; + return ps == null ? (psCache[index] = conn.prepareStatement(sql)) : ps; + } + + @Override + public void close() { + for(final PreparedStatement ps : psCache) + tryClose(ps); + } + + public QmDaoBindBean(final Factory connectionFactory) throws SQLException { + this(connectionFactory.create(), true); + } + + public QmDaoBindBean(final String jndiName) throws SQLException { + this(com.moparisthebest.jdbc.codegen.JdbcMapperFactory.connectionFactory(jndiName)); + } + + @Override + public SqlBuilder sqlBuilder() { + return SqlBuilder.of(conn, com.moparisthebest.jdbc.BindInList.instance()); + } +} diff --git a/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/QmDaoOracleBean.java b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/QmDaoOracleBean.java new file mode 100644 index 0000000..baafb49 --- /dev/null +++ b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/QmDaoOracleBean.java @@ -0,0 +1,1604 @@ +package com.moparisthebest.jdbc.codegen; + +import com.moparisthebest.jdbc.util.SqlBuilder; +import com.moparisthebest.jdbc.Factory; + +import java.sql.*; + +import static com.moparisthebest.jdbc.util.ResultSetUtil.*; +import static com.moparisthebest.jdbc.TryClose.tryClose; + +public class QmDaoOracleBean implements QmDao { + + private final Connection conn; + private final boolean closeConn; + + + private QmDaoOracleBean(final Connection conn, final boolean closeConn) { + this.conn = conn; + this.closeConn = closeConn; + if (this.conn == null) + throw new NullPointerException("Connection needs to be non-null for JdbcMapper..."); + } + + public QmDaoOracleBean(Connection conn) { + this(conn, false); + } + + public Connection getConnection() { + return this.conn; + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getFieldRegularPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(0, "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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.BuilderPerson getBuilderPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(1, "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.BuilderPerson ret = new com.moparisthebest.jdbc.dto.BuilderPerson(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegularAndUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(2, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(6)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegularAndUnderscoreReverse(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(3, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegularAndUnderscoreNoConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(4, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name, p.first_name AS dummy FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[5], ret, rs.getString(6)); +ret.setDummy(rs.getString(7)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegularAndUnderscoreReverseNoConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(5, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName, p.first_name AS dummy FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[5], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(6)); +ret.setDummy(rs.getString(7)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegular(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(6, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(7, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[5], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetPerson getSetRegularPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(8, "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.SetPerson ret = new com.moparisthebest.jdbc.dto.SetPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetPerson getSetRegularPersonNoConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(9, "SELECT person_no, first_name, last_name, birth_date, first_name AS dummy FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetPerson ret = new com.moparisthebest.jdbc.dto.SetPerson(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDummy(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetBoss getSetRegularAndUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(10, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetBoss ret = new com.moparisthebest.jdbc.dto.SetBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(6)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetBoss getSetRegularAndUnderscoreReverse(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(11, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetBoss ret = new com.moparisthebest.jdbc.dto.SetBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetBoss getSetRegular(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(12, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetBoss ret = new com.moparisthebest.jdbc.dto.SetBoss(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDepartment(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetBoss getSetUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(13, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetBoss ret = new com.moparisthebest.jdbc.dto.SetBoss(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirst_name(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDepartment(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldPerson getReverseFieldRegularPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(14, "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.ReverseFieldPerson ret = new com.moparisthebest.jdbc.dto.ReverseFieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldBoss getReverseFieldRegularAndUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(15, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseFieldBoss ret = new com.moparisthebest.jdbc.dto.ReverseFieldBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(6)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldBoss getReverseFieldRegularAndUnderscoreReverse(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(16, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseFieldBoss ret = new com.moparisthebest.jdbc.dto.ReverseFieldBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldBoss getReverseFieldRegular(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(17, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseFieldBoss ret = new com.moparisthebest.jdbc.dto.ReverseFieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[6], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[7], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[8], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[9], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[10], ret, rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldBoss getReverseFieldUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(18, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseFieldBoss ret = new com.moparisthebest.jdbc.dto.ReverseFieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[6], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[11], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[8], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[9], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[10], ret, rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetPerson getReverseSetRegularPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(19, "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.ReverseSetPerson ret = new com.moparisthebest.jdbc.dto.ReverseSetPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetBoss getReverseSetRegularAndUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(20, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseSetBoss ret = new com.moparisthebest.jdbc.dto.ReverseSetBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(6)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetBoss getReverseSetRegularAndUnderscoreReverse(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(21, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseSetBoss ret = new com.moparisthebest.jdbc.dto.ReverseSetBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetBoss getReverseSetRegular(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(22, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseSetBoss ret = new com.moparisthebest.jdbc.dto.ReverseSetBoss(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDepartment(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetBoss getReverseSetUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(23, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseSetBoss ret = new com.moparisthebest.jdbc.dto.ReverseSetBoss(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirst_name(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDepartment(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.lang.Long getPersonNo(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(24, "SELECT person_no FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public long getPersonNoPrimitive(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(25, "SELECT person_no FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final long ret = rs.getLong(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + } + } + + @Override + public int getPersonNoPrimitiveInt(final int personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(26, "SELECT person_no FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final int ret = rs.getInt(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.lang.Long[] getPersonNoObjectArray(final java.lang.Long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(27, "SELECT person_no FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret.toArray(new java.lang.Long[_colret.size()]); + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List> getAllNames() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(28, "SELECT first_name, last_name FROM person WHERE person_no < 4"); + rs = ps.executeQuery(); + final java.util.List> _colret = new java.util.ArrayList>(); + while(rs.next()) { +final java.util.Map ret = new java.util.HashMap(); +ret.put("first_name", rs.getString(1)); +ret.put("last_name", rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.Map[] getAllNamesArray() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(29, "SELECT first_name, last_name FROM person WHERE person_no < 4"); + rs = ps.executeQuery(); + final java.util.List> _colret = new java.util.ArrayList>(); + while(rs.next()) { +final java.util.Map ret = new java.util.HashMap(); +ret.put("first_name", rs.getString(1)); +ret.put("last_name", rs.getString(2)); + _colret.add(ret); + } + @SuppressWarnings("unchecked") + final java.util.Map[] _warnret = _colret.toArray(new java.util.Map[_colret.size()]); + return _warnret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.Map getAllNameMap() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(30, "SELECT first_name, last_name FROM person WHERE person_no < 4"); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final java.lang.String ret = rs.getString(2); + _colret.put(rs.getString(1), ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.Map getMapLongPerson() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(31, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no in (2,3,4)"); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); + _colret.put(com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1), ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.Map getMapLongLong() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(32, "SELECT person_no AS first_no, person_no AS last_no FROM person WHERE person_no < 4"); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 2); + _colret.put(com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1), ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.lang.Long[] getLongObjectArray() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(33, "SELECT 1, 2, 3 FROM person WHERE person_no = 1"); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.Long[] ret = new java.lang.Long[3]; +ret[0] = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); +ret[1] = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 2); +ret[2] = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 3); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public long[] getLongPrimitiveArray() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(34, "SELECT 1, 2, 3 FROM person WHERE person_no = 1"); + rs = ps.executeQuery(); + if(rs.next()) { +final long[] ret = new long[3]; +ret[0] = rs.getLong(1); +ret[1] = rs.getLong(2); +ret[2] = rs.getLong(3); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List> getBobTomMap() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(35, "SELECT 'bob' as bob, 'tom' as tom FROM person WHERE person_no = 1"); + rs = ps.executeQuery(); + final java.util.List> _colret = new java.util.ArrayList>(); + while(rs.next()) { +final java.util.Map ret = new java.util.HashMap(); +ret.put("bob", rs.getString(1)); +ret.put("tom", rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List> getBobTomMapCaseInsensitive() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(36, "SELECT 'bob' as bob, 'tom' as tom FROM person WHERE person_no = 1"); + rs = ps.executeQuery(); + final java.util.List> _colret = new java.util.ArrayList>(); + while(rs.next()) { +final com.moparisthebest.jdbc.util.CaseInsensitiveHashMap ret = new com.moparisthebest.jdbc.util.CaseInsensitiveHashMap(); +ret.put("bob", rs.getString(1)); +ret.put("tom", rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List getThreePeople(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(37, "SELECT person_no, first_name, last_name, birth_date from person WHERE person_no IN (?, ?, ?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.util.ResultSetIterable getThreePeopleResultSetIterable(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(38, "SELECT person_no, first_name, last_name, birth_date from person WHERE person_no IN (?, ?, ?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + return com.moparisthebest.jdbc.util.ResultSetIterable.getResultSetIterable(rs, + rs.next() ? (_rs, _cal) -> { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 4), +_rs.getString(2), +_rs.getString(3)); + return ret; + } + : null, null); + } catch(Throwable e) { + tryClose(rs); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public java.util.stream.Stream getThreePeopleStream(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(39, "SELECT person_no, first_name, last_name, birth_date from person WHERE person_no IN (?, ?, ?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + return com.moparisthebest.jdbc.util.ResultSetIterable.getStream(rs, + rs.next() ? (_rs, _cal) -> { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 4), +_rs.getString(2), +_rs.getString(3)); + return ret; + } + : null, null); + } catch(Throwable e) { + tryClose(rs); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(40, "SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPersonConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(41, "SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson( +com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FirstName getFirstName(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(42, "SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPersonNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(43, "SELECT str_val as first_name, str_val as last_name FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FirstName getFirstNameNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(44, "SELECT str_val FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.CaseSensitivePerson getCaseSensitivePerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(45, "SELECT first_name AS M_PERSON_FIRST_NAME FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.CaseSensitivePerson ret = new com.moparisthebest.jdbc.dto.CaseSensitivePerson(); +ret.setmPersonFirstName(rs.getString(1)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.Instant getBirthdateInstant(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(46, "SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.Instant ret = com.moparisthebest.jdbc.util.ResultSetUtil.getInstant(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.LocalDateTime getBirthdateLocalDateTime(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(47, "SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.LocalDateTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getLocalDateTime(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.LocalDate getBirthdateLocalDate(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(48, "SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.LocalDate ret = com.moparisthebest.jdbc.util.ResultSetUtil.getLocalDate(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.LocalTime getBirthdateLocalTime(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(49, "SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.LocalTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getLocalTime(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.ZonedDateTime getBirthdateZonedDateTime(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(50, "SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.ZonedDateTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getZonedDateTime(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.OffsetDateTime getBirthdateOffsetDateTime(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(51, "SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.OffsetDateTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getOffsetDateTime(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.OffsetTime getBirthdateOffsetTime(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(52, "SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.OffsetTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getOffsetTime(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.Year getYearInt(final long valNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(53, "SELECT num_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.Year ret = com.moparisthebest.jdbc.util.ResultSetUtil.getYear(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.Year getYearString(final long valNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(54, "SELECT str_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.Year ret = com.moparisthebest.jdbc.util.ResultSetUtil.getYear(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.ZoneId getZoneId(final long valNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(55, "SELECT str_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.ZoneId ret = com.moparisthebest.jdbc.util.ResultSetUtil.getZoneId(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.ZoneOffset getZoneOffsetInt(final long valNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(56, "SELECT str_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.ZoneOffset ret = com.moparisthebest.jdbc.util.ResultSetUtil.getZoneOffset(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.ZoneOffset getZoneOffsetString(final long valNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(57, "SELECT str_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.ZoneOffset ret = com.moparisthebest.jdbc.util.ResultSetUtil.getZoneOffset(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List getFieldPeopleStream(final java.util.stream.Stream personNos) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.unwrap(oracle.jdbc.OracleConnection.class).createOracleArray("ARRAY_NUM_TYPE", personNos.toArray(java.lang.Long[]::new)); + ps = this.prepareStatement(58, "SELECT person_no, first_name, last_name, birth_date from person WHERE (person_no IN(select column_value from table(?))) ORDER BY person_no"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + } + } + + @Override + public java.util.List getFieldPeople(final java.util.List personNos) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.unwrap(oracle.jdbc.OracleConnection.class).createOracleArray("ARRAY_NUM_TYPE", personNos.toArray(new java.lang.Long[personNos.size()])); + ps = this.prepareStatement(59, "SELECT person_no, first_name, last_name, birth_date from person WHERE (person_no IN(select column_value from table(?))) ORDER BY person_no"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + } + } + + @Override + public java.util.List getFieldPeopleByName(final java.util.List personNos, final java.util.List names) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[2]; + try { + _bindArrays[0] = conn.unwrap(oracle.jdbc.OracleConnection.class).createOracleArray("ARRAY_NUM_TYPE", personNos.toArray(new java.lang.Long[personNos.size()])); + _bindArrays[1] = conn.unwrap(oracle.jdbc.OracleConnection.class).createOracleArray("ARRAY_STR_TYPE", names.toArray(new java.lang.String[names.size()])); + ps = this.prepareStatement(60, "SELECT person_no, first_name, last_name, birth_date from person WHERE (person_no IN(select column_value from table(?))) AND ((first_name IN(select column_value from table(?))) OR (last_name IN(select column_value from table(?)))) ORDER BY person_no"); + ps.setArray(1, _bindArrays[0]); + ps.setArray(2, _bindArrays[1]); + ps.setArray(3, _bindArrays[1]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + } + } + + @Override + public java.util.List getFieldPeopleNotIn(final java.util.List personNos) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.unwrap(oracle.jdbc.OracleConnection.class).createOracleArray("ARRAY_NUM_TYPE", personNos.toArray(new java.lang.Long[personNos.size()])); + ps = this.prepareStatement(61, "SELECT person_no, first_name, last_name, birth_date from person WHERE (person_no NOT IN(select column_value from table(?))) ORDER BY person_no"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + } + } + + @Override + public long insertGetGeneratedKeyOracle(final long value) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO a_thaoeu_table (a_thaoeu_table_no, a_thaoeu_table_val) VALUES (a_thaoeu_table_seq.nextval, ?)", new int[]{1}); + ps.setObject(1, value); + ps.executeUpdate(); + ResultSet rs = null; + try { + rs = ps.getGeneratedKeys(); + return rs.next() ? rs.getLong(1) : 0; + } finally { + tryClose(rs); + } + } finally { + tryClose(ps); + } + } + + @Override + public long insertGetGeneratedKey(final long value) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO a_thaoeu_table (a_thaoeu_table_val) VALUES (?)", new int[]{1}); + ps.setObject(1, value); + ps.executeUpdate(); + ResultSet rs = null; + try { + rs = ps.getGeneratedKeys(); + return rs.next() ? rs.getLong(1) : 0; + } finally { + tryClose(rs); + } + } finally { + tryClose(ps); + } + } + + @Override + public java.util.List selectRandomSql(final java.lang.String sql) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE " + sql + ""); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List selectRandomSqlBuilder(final com.moparisthebest.jdbc.util.SqlBuilder sql) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE " + sql + ""); + int psParamCount = 0; + psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, sql); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List selectRandomSql(final long personNo1, final java.lang.String sql, final java.lang.String firstName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE person_no = ? " + sql + " OR first_name = ?"); + ps.setObject(1, personNo1); + ps.setObject(2, firstName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List selectRandomSqlBuilder(final long personNo1, final com.moparisthebest.jdbc.util.Bindable sql, final java.lang.String firstName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE person_no = ? " + sql + " OR first_name = ?"); + int psParamCount = 0; + ps.setObject(++psParamCount, personNo1); + psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, sql.getBindObject()); + ps.setObject(++psParamCount, firstName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public void insertRandomSqlCollection(final java.util.Collection sql) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT " + sql + ""); + int psParamCount = 0; + psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, sql); + ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + @Override + public void insertRandomSqlIterable(final java.lang.Iterable sql) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT " + sql + ""); + int psParamCount = 0; + psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, sql); + ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + private static final java.lang.reflect.Field[] _fields = new java.lang.reflect.Field[] { + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "personNo"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "firstName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "lastName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "birthDate"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldBoss.class, "department"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldBoss.class, "first_name"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldPerson.class, "personNo"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldBoss.class, "firstName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldPerson.class, "lastName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldPerson.class, "birthDate"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldBoss.class, "department"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldPerson.class, "first_name"), + }; + + private final PreparedStatement[] psCache = new PreparedStatement[62]; + + private PreparedStatement prepareStatement(final int index, final String sql) throws SQLException { + final PreparedStatement ps = psCache[index]; + return ps == null ? (psCache[index] = conn.prepareStatement(sql)) : ps; + } + + @Override + public void close() { + for(final PreparedStatement ps : psCache) + tryClose(ps); + } + + public QmDaoOracleBean(final Factory connectionFactory) throws SQLException { + this(connectionFactory.create(), true); + } + + public QmDaoOracleBean(final String jndiName) throws SQLException { + this(com.moparisthebest.jdbc.codegen.JdbcMapperFactory.connectionFactory(jndiName)); + } + + @Override + public SqlBuilder sqlBuilder() { + return SqlBuilder.of(conn, com.moparisthebest.jdbc.OracleArrayInList.instance()); + } +} diff --git a/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/QmDaoUnNestBean.java b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/QmDaoUnNestBean.java new file mode 100644 index 0000000..5df3775 --- /dev/null +++ b/test/src/test/snapshot/com/moparisthebest/jdbc/codegen/QmDaoUnNestBean.java @@ -0,0 +1,1604 @@ +package com.moparisthebest.jdbc.codegen; + +import com.moparisthebest.jdbc.util.SqlBuilder; +import com.moparisthebest.jdbc.Factory; + +import java.sql.*; + +import static com.moparisthebest.jdbc.util.ResultSetUtil.*; +import static com.moparisthebest.jdbc.TryClose.tryClose; + +public class QmDaoUnNestBean implements QmDao { + + private final Connection conn; + private final boolean closeConn; + + + private QmDaoUnNestBean(final Connection conn, final boolean closeConn) { + this.conn = conn; + this.closeConn = closeConn; + if (this.conn == null) + throw new NullPointerException("Connection needs to be non-null for JdbcMapper..."); + } + + public QmDaoUnNestBean(Connection conn) { + this(conn, false); + } + + public Connection getConnection() { + return this.conn; + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getFieldRegularPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(0, "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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.BuilderPerson getBuilderPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(1, "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.BuilderPerson ret = new com.moparisthebest.jdbc.dto.BuilderPerson(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegularAndUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(2, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(6)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegularAndUnderscoreReverse(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(3, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegularAndUnderscoreNoConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(4, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name, p.first_name AS dummy FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[5], ret, rs.getString(6)); +ret.setDummy(rs.getString(7)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegularAndUnderscoreReverseNoConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(5, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName, p.first_name AS dummy FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[5], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(6)); +ret.setDummy(rs.getString(7)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegular(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(6, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(7, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[5], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetPerson getSetRegularPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(8, "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.SetPerson ret = new com.moparisthebest.jdbc.dto.SetPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetPerson getSetRegularPersonNoConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(9, "SELECT person_no, first_name, last_name, birth_date, first_name AS dummy FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetPerson ret = new com.moparisthebest.jdbc.dto.SetPerson(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDummy(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetBoss getSetRegularAndUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(10, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetBoss ret = new com.moparisthebest.jdbc.dto.SetBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(6)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetBoss getSetRegularAndUnderscoreReverse(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(11, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetBoss ret = new com.moparisthebest.jdbc.dto.SetBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetBoss getSetRegular(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(12, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetBoss ret = new com.moparisthebest.jdbc.dto.SetBoss(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDepartment(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetBoss getSetUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(13, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetBoss ret = new com.moparisthebest.jdbc.dto.SetBoss(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirst_name(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDepartment(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldPerson getReverseFieldRegularPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(14, "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.ReverseFieldPerson ret = new com.moparisthebest.jdbc.dto.ReverseFieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldBoss getReverseFieldRegularAndUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(15, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseFieldBoss ret = new com.moparisthebest.jdbc.dto.ReverseFieldBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(6)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldBoss getReverseFieldRegularAndUnderscoreReverse(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(16, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseFieldBoss ret = new com.moparisthebest.jdbc.dto.ReverseFieldBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldBoss getReverseFieldRegular(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(17, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseFieldBoss ret = new com.moparisthebest.jdbc.dto.ReverseFieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[6], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[7], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[8], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[9], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[10], ret, rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldBoss getReverseFieldUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(18, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseFieldBoss ret = new com.moparisthebest.jdbc.dto.ReverseFieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[6], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[11], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[8], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[9], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[10], ret, rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetPerson getReverseSetRegularPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(19, "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.ReverseSetPerson ret = new com.moparisthebest.jdbc.dto.ReverseSetPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetBoss getReverseSetRegularAndUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(20, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseSetBoss ret = new com.moparisthebest.jdbc.dto.ReverseSetBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(6)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetBoss getReverseSetRegularAndUnderscoreReverse(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(21, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseSetBoss ret = new com.moparisthebest.jdbc.dto.ReverseSetBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetBoss getReverseSetRegular(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(22, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseSetBoss ret = new com.moparisthebest.jdbc.dto.ReverseSetBoss(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDepartment(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetBoss getReverseSetUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(23, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseSetBoss ret = new com.moparisthebest.jdbc.dto.ReverseSetBoss(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirst_name(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDepartment(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.lang.Long getPersonNo(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(24, "SELECT person_no FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public long getPersonNoPrimitive(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(25, "SELECT person_no FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final long ret = rs.getLong(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + } + } + + @Override + public int getPersonNoPrimitiveInt(final int personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(26, "SELECT person_no FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final int ret = rs.getInt(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.lang.Long[] getPersonNoObjectArray(final java.lang.Long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(27, "SELECT person_no FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret.toArray(new java.lang.Long[_colret.size()]); + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List> getAllNames() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(28, "SELECT first_name, last_name FROM person WHERE person_no < 4"); + rs = ps.executeQuery(); + final java.util.List> _colret = new java.util.ArrayList>(); + while(rs.next()) { +final java.util.Map ret = new java.util.HashMap(); +ret.put("first_name", rs.getString(1)); +ret.put("last_name", rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.Map[] getAllNamesArray() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(29, "SELECT first_name, last_name FROM person WHERE person_no < 4"); + rs = ps.executeQuery(); + final java.util.List> _colret = new java.util.ArrayList>(); + while(rs.next()) { +final java.util.Map ret = new java.util.HashMap(); +ret.put("first_name", rs.getString(1)); +ret.put("last_name", rs.getString(2)); + _colret.add(ret); + } + @SuppressWarnings("unchecked") + final java.util.Map[] _warnret = _colret.toArray(new java.util.Map[_colret.size()]); + return _warnret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.Map getAllNameMap() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(30, "SELECT first_name, last_name FROM person WHERE person_no < 4"); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final java.lang.String ret = rs.getString(2); + _colret.put(rs.getString(1), ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.Map getMapLongPerson() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(31, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no in (2,3,4)"); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); + _colret.put(com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1), ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.Map getMapLongLong() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(32, "SELECT person_no AS first_no, person_no AS last_no FROM person WHERE person_no < 4"); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 2); + _colret.put(com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1), ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.lang.Long[] getLongObjectArray() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(33, "SELECT 1, 2, 3 FROM person WHERE person_no = 1"); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.Long[] ret = new java.lang.Long[3]; +ret[0] = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); +ret[1] = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 2); +ret[2] = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 3); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public long[] getLongPrimitiveArray() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(34, "SELECT 1, 2, 3 FROM person WHERE person_no = 1"); + rs = ps.executeQuery(); + if(rs.next()) { +final long[] ret = new long[3]; +ret[0] = rs.getLong(1); +ret[1] = rs.getLong(2); +ret[2] = rs.getLong(3); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List> getBobTomMap() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(35, "SELECT 'bob' as bob, 'tom' as tom FROM person WHERE person_no = 1"); + rs = ps.executeQuery(); + final java.util.List> _colret = new java.util.ArrayList>(); + while(rs.next()) { +final java.util.Map ret = new java.util.HashMap(); +ret.put("bob", rs.getString(1)); +ret.put("tom", rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List> getBobTomMapCaseInsensitive() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(36, "SELECT 'bob' as bob, 'tom' as tom FROM person WHERE person_no = 1"); + rs = ps.executeQuery(); + final java.util.List> _colret = new java.util.ArrayList>(); + while(rs.next()) { +final com.moparisthebest.jdbc.util.CaseInsensitiveHashMap ret = new com.moparisthebest.jdbc.util.CaseInsensitiveHashMap(); +ret.put("bob", rs.getString(1)); +ret.put("tom", rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List getThreePeople(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(37, "SELECT person_no, first_name, last_name, birth_date from person WHERE person_no IN (?, ?, ?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.util.ResultSetIterable getThreePeopleResultSetIterable(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(38, "SELECT person_no, first_name, last_name, birth_date from person WHERE person_no IN (?, ?, ?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + return com.moparisthebest.jdbc.util.ResultSetIterable.getResultSetIterable(rs, + rs.next() ? (_rs, _cal) -> { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 4), +_rs.getString(2), +_rs.getString(3)); + return ret; + } + : null, null); + } catch(Throwable e) { + tryClose(rs); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public java.util.stream.Stream getThreePeopleStream(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(39, "SELECT person_no, first_name, last_name, birth_date from person WHERE person_no IN (?, ?, ?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + return com.moparisthebest.jdbc.util.ResultSetIterable.getStream(rs, + rs.next() ? (_rs, _cal) -> { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 4), +_rs.getString(2), +_rs.getString(3)); + return ret; + } + : null, null); + } catch(Throwable e) { + tryClose(rs); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(40, "SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPersonConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(41, "SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson( +com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FirstName getFirstName(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(42, "SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPersonNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(43, "SELECT str_val as first_name, str_val as last_name FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FirstName getFirstNameNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(44, "SELECT str_val FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.CaseSensitivePerson getCaseSensitivePerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(45, "SELECT first_name AS M_PERSON_FIRST_NAME FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.CaseSensitivePerson ret = new com.moparisthebest.jdbc.dto.CaseSensitivePerson(); +ret.setmPersonFirstName(rs.getString(1)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.Instant getBirthdateInstant(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(46, "SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.Instant ret = com.moparisthebest.jdbc.util.ResultSetUtil.getInstant(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.LocalDateTime getBirthdateLocalDateTime(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(47, "SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.LocalDateTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getLocalDateTime(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.LocalDate getBirthdateLocalDate(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(48, "SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.LocalDate ret = com.moparisthebest.jdbc.util.ResultSetUtil.getLocalDate(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.LocalTime getBirthdateLocalTime(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(49, "SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.LocalTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getLocalTime(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.ZonedDateTime getBirthdateZonedDateTime(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(50, "SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.ZonedDateTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getZonedDateTime(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.OffsetDateTime getBirthdateOffsetDateTime(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(51, "SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.OffsetDateTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getOffsetDateTime(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.OffsetTime getBirthdateOffsetTime(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(52, "SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.OffsetTime ret = com.moparisthebest.jdbc.util.ResultSetUtil.getOffsetTime(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.Year getYearInt(final long valNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(53, "SELECT num_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.Year ret = com.moparisthebest.jdbc.util.ResultSetUtil.getYear(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.Year getYearString(final long valNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(54, "SELECT str_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.Year ret = com.moparisthebest.jdbc.util.ResultSetUtil.getYear(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.ZoneId getZoneId(final long valNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(55, "SELECT str_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.ZoneId ret = com.moparisthebest.jdbc.util.ResultSetUtil.getZoneId(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.ZoneOffset getZoneOffsetInt(final long valNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(56, "SELECT str_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.ZoneOffset ret = com.moparisthebest.jdbc.util.ResultSetUtil.getZoneOffset(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.time.ZoneOffset getZoneOffsetString(final long valNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(57, "SELECT str_val FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.time.ZoneOffset ret = com.moparisthebest.jdbc.util.ResultSetUtil.getZoneOffset(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List getFieldPeopleStream(final java.util.stream.Stream personNos) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("NUMERIC", personNos.toArray(java.lang.Long[]::new)); + ps = this.prepareStatement(58, "SELECT person_no, first_name, last_name, birth_date from person WHERE (person_no IN(UNNEST(?))) ORDER BY person_no"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + } + } + + @Override + public java.util.List getFieldPeople(final java.util.List personNos) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("NUMERIC", personNos.toArray(new java.lang.Long[personNos.size()])); + ps = this.prepareStatement(59, "SELECT person_no, first_name, last_name, birth_date from person WHERE (person_no IN(UNNEST(?))) ORDER BY person_no"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + } + } + + @Override + public java.util.List getFieldPeopleByName(final java.util.List personNos, final java.util.List names) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[2]; + try { + _bindArrays[0] = conn.createArrayOf("NUMERIC", personNos.toArray(new java.lang.Long[personNos.size()])); + _bindArrays[1] = conn.createArrayOf("VARCHAR", names.toArray(new java.lang.String[names.size()])); + ps = this.prepareStatement(60, "SELECT person_no, first_name, last_name, birth_date from person WHERE (person_no IN(UNNEST(?))) AND ((first_name IN(UNNEST(?))) OR (last_name IN(UNNEST(?)))) ORDER BY person_no"); + ps.setArray(1, _bindArrays[0]); + ps.setArray(2, _bindArrays[1]); + ps.setArray(3, _bindArrays[1]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + } + } + + @Override + public java.util.List getFieldPeopleNotIn(final java.util.List personNos) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("NUMERIC", personNos.toArray(new java.lang.Long[personNos.size()])); + ps = this.prepareStatement(61, "SELECT person_no, first_name, last_name, birth_date from person WHERE (person_no NOT IN(UNNEST(?))) ORDER BY person_no"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + } + } + + @Override + public long insertGetGeneratedKeyOracle(final long value) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO a_thaoeu_table (a_thaoeu_table_no, a_thaoeu_table_val) VALUES (a_thaoeu_table_seq.nextval, ?)", java.sql.Statement.RETURN_GENERATED_KEYS); + ps.setObject(1, value); + ps.executeUpdate(); + ResultSet rs = null; + try { + rs = ps.getGeneratedKeys(); + return rs.next() ? rs.getLong(1) : 0; + } finally { + tryClose(rs); + } + } finally { + tryClose(ps); + } + } + + @Override + public long insertGetGeneratedKey(final long value) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO a_thaoeu_table (a_thaoeu_table_val) VALUES (?)", java.sql.Statement.RETURN_GENERATED_KEYS); + ps.setObject(1, value); + ps.executeUpdate(); + ResultSet rs = null; + try { + rs = ps.getGeneratedKeys(); + return rs.next() ? rs.getLong(1) : 0; + } finally { + tryClose(rs); + } + } finally { + tryClose(ps); + } + } + + @Override + public java.util.List selectRandomSql(final java.lang.String sql) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE " + sql + ""); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List selectRandomSqlBuilder(final com.moparisthebest.jdbc.util.SqlBuilder sql) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE " + sql + ""); + int psParamCount = 0; + psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, sql); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List selectRandomSql(final long personNo1, final java.lang.String sql, final java.lang.String firstName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE person_no = ? " + sql + " OR first_name = ?"); + ps.setObject(1, personNo1); + ps.setObject(2, firstName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List selectRandomSqlBuilder(final long personNo1, final com.moparisthebest.jdbc.util.Bindable sql, final java.lang.String firstName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE person_no = ? " + sql + " OR first_name = ?"); + int psParamCount = 0; + ps.setObject(++psParamCount, personNo1); + psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, sql.getBindObject()); + ps.setObject(++psParamCount, firstName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public void insertRandomSqlCollection(final java.util.Collection sql) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT " + sql + ""); + int psParamCount = 0; + psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, sql); + ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + @Override + public void insertRandomSqlIterable(final java.lang.Iterable sql) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT " + sql + ""); + int psParamCount = 0; + psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, sql); + ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + private static final java.lang.reflect.Field[] _fields = new java.lang.reflect.Field[] { + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "personNo"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "firstName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "lastName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "birthDate"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldBoss.class, "department"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldBoss.class, "first_name"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldPerson.class, "personNo"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldBoss.class, "firstName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldPerson.class, "lastName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldPerson.class, "birthDate"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldBoss.class, "department"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldPerson.class, "first_name"), + }; + + private final PreparedStatement[] psCache = new PreparedStatement[62]; + + private PreparedStatement prepareStatement(final int index, final String sql) throws SQLException { + final PreparedStatement ps = psCache[index]; + return ps == null ? (psCache[index] = conn.prepareStatement(sql)) : ps; + } + + @Override + public void close() { + for(final PreparedStatement ps : psCache) + tryClose(ps); + } + + public QmDaoUnNestBean(final Factory connectionFactory) throws SQLException { + this(connectionFactory.create(), true); + } + + public QmDaoUnNestBean(final String jndiName) throws SQLException { + this(com.moparisthebest.jdbc.codegen.JdbcMapperFactory.connectionFactory(jndiName)); + } + + @Override + public SqlBuilder sqlBuilder() { + return SqlBuilder.of(conn, com.moparisthebest.jdbc.UnNestArrayInList.instance()); + } +} diff --git a/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/AbstractDaoAnyBean.java b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/AbstractDaoAnyBean.java new file mode 100644 index 0000000..843a2ec --- /dev/null +++ b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/AbstractDaoAnyBean.java @@ -0,0 +1,74 @@ +package com.moparisthebest.jdbc.codegen; + +import com.moparisthebest.jdbc.Factory; + +import java.sql.*; + +import static com.moparisthebest.jdbc.util.ResultSetUtil.*; +import static com.moparisthebest.jdbc.TryClose.tryClose; + +public class AbstractDaoAnyBean extends AbstractDao { + + private final Connection conn; + private final boolean closeConn; + + + private AbstractDaoAnyBean(final Connection conn, final boolean closeConn) { + this.conn = conn; + this.closeConn = closeConn; + if (this.conn == null) + throw new NullPointerException("Connection needs to be non-null for JdbcMapper..."); + } + + public AbstractDaoAnyBean(Connection conn) { + this(conn, false); + } + + public Connection getConnection() { + return this.conn; + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPerson(final long personNo) 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public long getPersonNo(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + if(rs.next()) { +final long ret = rs.getLong(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } +} diff --git a/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/AbstractDaoBean.java b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/AbstractDaoBean.java new file mode 100644 index 0000000..21f7ae1 --- /dev/null +++ b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/AbstractDaoBean.java @@ -0,0 +1,74 @@ +package com.moparisthebest.jdbc.codegen; + +import com.moparisthebest.jdbc.Factory; + +import java.sql.*; + +import static com.moparisthebest.jdbc.util.ResultSetUtil.*; +import static com.moparisthebest.jdbc.TryClose.tryClose; + +public class AbstractDaoBean extends AbstractDao { + + private final Connection conn; + private final boolean closeConn; + + + private AbstractDaoBean(final Connection conn, final boolean closeConn) { + this.conn = conn; + this.closeConn = closeConn; + if (this.conn == null) + throw new NullPointerException("Connection needs to be non-null for JdbcMapper..."); + } + + public AbstractDaoBean(Connection conn) { + this(conn, false); + } + + public Connection getConnection() { + return this.conn; + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPerson(final long personNo) 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public long getPersonNo(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + if(rs.next()) { +final long ret = rs.getLong(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } +} diff --git a/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/AbstractDaoBindBean.java b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/AbstractDaoBindBean.java new file mode 100644 index 0000000..d1e0137 --- /dev/null +++ b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/AbstractDaoBindBean.java @@ -0,0 +1,74 @@ +package com.moparisthebest.jdbc.codegen; + +import com.moparisthebest.jdbc.Factory; + +import java.sql.*; + +import static com.moparisthebest.jdbc.util.ResultSetUtil.*; +import static com.moparisthebest.jdbc.TryClose.tryClose; + +public class AbstractDaoBindBean extends AbstractDao { + + private final Connection conn; + private final boolean closeConn; + + + private AbstractDaoBindBean(final Connection conn, final boolean closeConn) { + this.conn = conn; + this.closeConn = closeConn; + if (this.conn == null) + throw new NullPointerException("Connection needs to be non-null for JdbcMapper..."); + } + + public AbstractDaoBindBean(Connection conn) { + this(conn, false); + } + + public Connection getConnection() { + return this.conn; + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPerson(final long personNo) 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public long getPersonNo(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + if(rs.next()) { +final long ret = rs.getLong(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } +} diff --git a/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/AbstractDaoOracleBean.java b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/AbstractDaoOracleBean.java new file mode 100644 index 0000000..8e767fb --- /dev/null +++ b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/AbstractDaoOracleBean.java @@ -0,0 +1,74 @@ +package com.moparisthebest.jdbc.codegen; + +import com.moparisthebest.jdbc.Factory; + +import java.sql.*; + +import static com.moparisthebest.jdbc.util.ResultSetUtil.*; +import static com.moparisthebest.jdbc.TryClose.tryClose; + +public class AbstractDaoOracleBean extends AbstractDao { + + private final Connection conn; + private final boolean closeConn; + + + private AbstractDaoOracleBean(final Connection conn, final boolean closeConn) { + this.conn = conn; + this.closeConn = closeConn; + if (this.conn == null) + throw new NullPointerException("Connection needs to be non-null for JdbcMapper..."); + } + + public AbstractDaoOracleBean(Connection conn) { + this(conn, false); + } + + public Connection getConnection() { + return this.conn; + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPerson(final long personNo) 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public long getPersonNo(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + if(rs.next()) { +final long ret = rs.getLong(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } +} diff --git a/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/AbstractDaoUnNestBean.java b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/AbstractDaoUnNestBean.java new file mode 100644 index 0000000..315d719 --- /dev/null +++ b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/AbstractDaoUnNestBean.java @@ -0,0 +1,74 @@ +package com.moparisthebest.jdbc.codegen; + +import com.moparisthebest.jdbc.Factory; + +import java.sql.*; + +import static com.moparisthebest.jdbc.util.ResultSetUtil.*; +import static com.moparisthebest.jdbc.TryClose.tryClose; + +public class AbstractDaoUnNestBean extends AbstractDao { + + private final Connection conn; + private final boolean closeConn; + + + private AbstractDaoUnNestBean(final Connection conn, final boolean closeConn) { + this.conn = conn; + this.closeConn = closeConn; + if (this.conn == null) + throw new NullPointerException("Connection needs to be non-null for JdbcMapper..."); + } + + public AbstractDaoUnNestBean(Connection conn) { + this(conn, false); + } + + public Connection getConnection() { + return this.conn; + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPerson(final long personNo) 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public long getPersonNo(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + if(rs.next()) { +final long ret = rs.getLong(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } +} diff --git a/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/CleaningPersonDaoAnyBean.java b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/CleaningPersonDaoAnyBean.java new file mode 100644 index 0000000..9b77f2a --- /dev/null +++ b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/CleaningPersonDaoAnyBean.java @@ -0,0 +1,54 @@ +package com.moparisthebest.jdbc.codegen; + +import com.moparisthebest.jdbc.Factory; + +import java.sql.*; + +import static com.moparisthebest.jdbc.util.ResultSetUtil.*; +import static com.moparisthebest.jdbc.TryClose.tryClose; + +public class CleaningPersonDaoAnyBean implements CleaningPersonDao { + + private final Connection conn; + private final boolean closeConn; + + + private CleaningPersonDaoAnyBean(final Connection conn, final boolean closeConn) { + this.conn = conn; + this.closeConn = closeConn; + if (this.conn == null) + throw new NullPointerException("Connection needs to be non-null for JdbcMapper..."); + } + + public CleaningPersonDaoAnyBean(Connection conn) { + this(conn, false); + } + + public Connection getConnection() { + return this.conn; + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPerson(final long personNo, final com.moparisthebest.jdbc.Cleaner personCleaner) 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return personCleaner == null ? ret : personCleaner.clean(ret); + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } +} diff --git a/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/CleaningPersonDaoBean.java b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/CleaningPersonDaoBean.java new file mode 100644 index 0000000..951636c --- /dev/null +++ b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/CleaningPersonDaoBean.java @@ -0,0 +1,54 @@ +package com.moparisthebest.jdbc.codegen; + +import com.moparisthebest.jdbc.Factory; + +import java.sql.*; + +import static com.moparisthebest.jdbc.util.ResultSetUtil.*; +import static com.moparisthebest.jdbc.TryClose.tryClose; + +public class CleaningPersonDaoBean implements CleaningPersonDao { + + private final Connection conn; + private final boolean closeConn; + + + private CleaningPersonDaoBean(final Connection conn, final boolean closeConn) { + this.conn = conn; + this.closeConn = closeConn; + if (this.conn == null) + throw new NullPointerException("Connection needs to be non-null for JdbcMapper..."); + } + + public CleaningPersonDaoBean(Connection conn) { + this(conn, false); + } + + public Connection getConnection() { + return this.conn; + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPerson(final long personNo, final com.moparisthebest.jdbc.Cleaner personCleaner) 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return personCleaner == null ? ret : personCleaner.clean(ret); + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } +} diff --git a/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/CleaningPersonDaoBindBean.java b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/CleaningPersonDaoBindBean.java new file mode 100644 index 0000000..4f34f3e --- /dev/null +++ b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/CleaningPersonDaoBindBean.java @@ -0,0 +1,54 @@ +package com.moparisthebest.jdbc.codegen; + +import com.moparisthebest.jdbc.Factory; + +import java.sql.*; + +import static com.moparisthebest.jdbc.util.ResultSetUtil.*; +import static com.moparisthebest.jdbc.TryClose.tryClose; + +public class CleaningPersonDaoBindBean implements CleaningPersonDao { + + private final Connection conn; + private final boolean closeConn; + + + private CleaningPersonDaoBindBean(final Connection conn, final boolean closeConn) { + this.conn = conn; + this.closeConn = closeConn; + if (this.conn == null) + throw new NullPointerException("Connection needs to be non-null for JdbcMapper..."); + } + + public CleaningPersonDaoBindBean(Connection conn) { + this(conn, false); + } + + public Connection getConnection() { + return this.conn; + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPerson(final long personNo, final com.moparisthebest.jdbc.Cleaner personCleaner) 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return personCleaner == null ? ret : personCleaner.clean(ret); + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } +} diff --git a/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/CleaningPersonDaoOracleBean.java b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/CleaningPersonDaoOracleBean.java new file mode 100644 index 0000000..08bab04 --- /dev/null +++ b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/CleaningPersonDaoOracleBean.java @@ -0,0 +1,54 @@ +package com.moparisthebest.jdbc.codegen; + +import com.moparisthebest.jdbc.Factory; + +import java.sql.*; + +import static com.moparisthebest.jdbc.util.ResultSetUtil.*; +import static com.moparisthebest.jdbc.TryClose.tryClose; + +public class CleaningPersonDaoOracleBean implements CleaningPersonDao { + + private final Connection conn; + private final boolean closeConn; + + + private CleaningPersonDaoOracleBean(final Connection conn, final boolean closeConn) { + this.conn = conn; + this.closeConn = closeConn; + if (this.conn == null) + throw new NullPointerException("Connection needs to be non-null for JdbcMapper..."); + } + + public CleaningPersonDaoOracleBean(Connection conn) { + this(conn, false); + } + + public Connection getConnection() { + return this.conn; + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPerson(final long personNo, final com.moparisthebest.jdbc.Cleaner personCleaner) 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return personCleaner == null ? ret : personCleaner.clean(ret); + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } +} diff --git a/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/CleaningPersonDaoUnNestBean.java b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/CleaningPersonDaoUnNestBean.java new file mode 100644 index 0000000..497bb52 --- /dev/null +++ b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/CleaningPersonDaoUnNestBean.java @@ -0,0 +1,54 @@ +package com.moparisthebest.jdbc.codegen; + +import com.moparisthebest.jdbc.Factory; + +import java.sql.*; + +import static com.moparisthebest.jdbc.util.ResultSetUtil.*; +import static com.moparisthebest.jdbc.TryClose.tryClose; + +public class CleaningPersonDaoUnNestBean implements CleaningPersonDao { + + private final Connection conn; + private final boolean closeConn; + + + private CleaningPersonDaoUnNestBean(final Connection conn, final boolean closeConn) { + this.conn = conn; + this.closeConn = closeConn; + if (this.conn == null) + throw new NullPointerException("Connection needs to be non-null for JdbcMapper..."); + } + + public CleaningPersonDaoUnNestBean(Connection conn) { + this(conn, false); + } + + public Connection getConnection() { + return this.conn; + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPerson(final long personNo, final com.moparisthebest.jdbc.Cleaner personCleaner) 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return personCleaner == null ? ret : personCleaner.clean(ret); + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } +} 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 new file mode 100644 index 0000000..5bfb1fa --- /dev/null +++ b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/PersonDAOAnyBean.java @@ -0,0 +1,1652 @@ +package com.moparisthebest.jdbc.codegen; + +import com.moparisthebest.jdbc.util.SqlBuilder; +import com.moparisthebest.jdbc.Factory; + +import java.sql.*; + +import static com.moparisthebest.jdbc.util.ResultSetUtil.*; +import static com.moparisthebest.jdbc.TryClose.tryClose; + +public class PersonDAOAnyBean implements PersonDAO { + + private final Connection conn; + private final boolean closeConn; + + private static final Factory _conFactory = com.moparisthebest.jdbc.codegen.JdbcMapperFactory.connectionFactory("bob"); + + public PersonDAOAnyBean() throws SQLException { + this(_conFactory); + } + + private PersonDAOAnyBean(final Connection conn, final boolean closeConn) { + this.conn = conn; + this.closeConn = closeConn; + if (this.conn == null) + throw new NullPointerException("Connection needs to be non-null for JdbcMapper..."); + } + + public PersonDAOAnyBean(Connection conn) { + this(conn, false); + } + + public Connection getConnection() { + return this.conn; + } + + @Override + public void createTablePerson() { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("CREATE TABLE person (person_no NUMERIC, first_name VARCHAR(40), last_name VARCHAR(40), birth_date TIMESTAMP)"); + ps.executeUpdate(); + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public int insertPerson(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)"); + ps.setObject(1, personNo); + ps.setObject(2, birthDate == null ? null : new java.sql.Timestamp(birthDate.getTime())); + ps.setObject(3, firstName); + ps.setObject(4, lastName); + return ps.executeUpdate(); + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public long insertPersonGeneratedKey(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)", java.sql.Statement.RETURN_GENERATED_KEYS); + ps.setObject(1, personNo); + ps.setObject(2, birthDate == null ? null : new java.sql.Timestamp(birthDate.getTime())); + ps.setObject(3, firstName); + ps.setObject(4, lastName); + ps.executeUpdate(); + ResultSet rs = null; + try { + rs = ps.getGeneratedKeys(); + return rs.next() ? rs.getLong(1) : 0; + } finally { + tryClose(rs); + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public java.lang.Long insertPersonGeneratedKeyLong(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)", java.sql.Statement.RETURN_GENERATED_KEYS); + ps.setObject(1, personNo); + ps.setObject(2, birthDate == null ? null : new java.sql.Timestamp(birthDate.getTime())); + ps.setObject(3, firstName); + ps.setObject(4, lastName); + ps.executeUpdate(); + ResultSet rs = null; + try { + rs = ps.getGeneratedKeys(); + return rs.next() ? com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1) : null; + } finally { + tryClose(rs); + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public int setFirstName(final java.lang.String firstName, final java.lang.String lastName) { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE last_name = ?"); + ps.setObject(1, firstName); + ps.setObject(2, lastName); + return ps.executeUpdate(); + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public void setFirstName(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.setObject(1, firstName); + ps.setObject(2, personNo); + ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + @Override + public void setFirstNameBlob(final byte[] firstName, final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE person_no = ?"); + ps.setBlob(1, firstName == null ? null : new java.io.ByteArrayInputStream(firstName)); + ps.setObject(2, personNo); + ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + @Override + public void setFirstNameBlob(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-8"))); + } catch (java.io.UnsupportedEncodingException e) { + throw new SQLException("String to Blob UnsupportedEncodingException", e); + } + 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; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + if(rs.next()) { +final long ret = rs.getLong(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public long getPersonNoUnusedParam(final java.lang.String lastName, final java.lang.String _bla) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + if(rs.next()) { +final long ret = rs.getLong(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.ResultSet getPeopleResultSet(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + return new com.moparisthebest.jdbc.StatementClosingResultSet(rs, ps); + } catch(Throwable e) { + tryClose(rs); + tryClose(ps); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public java.sql.ResultSet getPeopleResultSetCached(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(0, "SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + return rs; + } catch(Throwable e) { + tryClose(rs); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public java.lang.String getFirstNameColumnNames(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.String ret = rs.getString(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.lang.String getFirstName(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.String ret = rs.getString(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public int getFirstNameUpdate(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + return ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPersonColumnNames(final long personNo) 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPerson(final long personNo) 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.BuilderPerson getBuilderPerson(final long personNo) 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.BuilderPerson ret = new com.moparisthebest.jdbc.dto.BuilderPerson(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPerson(final long personNo, final java.util.Calendar cal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3, 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; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeople(final java.lang.String[] lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("TEXT", lastName); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (NOT(last_name = ANY(?)))"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeople(final java.util.List lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("TEXT", lastName.toArray(new java.lang.String[lastName.size()])); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (last_name = ANY(?))"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson[] getPeopleArray(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret.toArray(new com.moparisthebest.jdbc.dto.FieldPerson[_colret.size()]); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Iterator getPeopleIterator(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret.iterator(); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.ListIterator getPeopleListIterator(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret.listIterator(); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonMap(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, rs.getLong(3)); + _colret.put(rs.getString(1), ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map> getPersonMapList(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.Map> _colret = new java.util.HashMap>(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, rs.getLong(3)); + final java.lang.String _colkey = rs.getString(1); + java.util.List _collist = _colret.get(_colkey); + if(_collist == null) { + _collist = new java.util.ArrayList(); + _colret.put(_colkey, _collist); + } + _collist.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.lang.String getFirstName(final long personNo, final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ? and last_name = ?"); + ps.setObject(1, personNo); + ps.setObject(2, lastName); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.String ret = rs.getString(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Calendar getBirthDateCalendar(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Calendar ret = com.moparisthebest.jdbc.util.ResultSetUtil.getCalendar(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Calendar getBirthDateCalendar(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Calendar ret = com.moparisthebest.jdbc.util.ResultSetUtil.getCalendar(rs, 1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Timestamp getBirthDateTimestamp(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Timestamp ret = rs.getTimestamp(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Timestamp getBirthDateTimestamp(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Timestamp ret = rs.getTimestamp(1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Time getBirthDateTime(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Time ret = rs.getTime(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Time getBirthDateTime(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Time ret = rs.getTime(1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Date getBirthDateSqlDate(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Date ret = rs.getDate(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Date getBirthDateSqlDate(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Date ret = rs.getDate(1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Date getBirthDateUtilDate(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Date ret = com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Date getBirthDateUtilDate(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Date ret = com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPersonCleanFieldPerson(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + return clean == null ? ret : clean.clean(ret); + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPersonCleanPerson(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + return clean == null ? ret : clean.clean(ret); + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPersonCleanObject(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + return clean == null ? ret : clean.clean(ret); + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPersonCleanPersonList(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.add(clean == null ? ret : clean.clean(ret)); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonCleanPersonMap(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.put(rs.getString(1), clean == null ? ret : clean.clean(ret)); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map> getPersonCleanPersonMapList(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + final java.util.Map> _colret = new java.util.HashMap>(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + final java.lang.String _colkey = rs.getString(1); + java.util.List _collist = _colret.get(_colkey); + if(_collist == null) { + _collist = new java.util.ArrayList(); + _colret.put(_colkey, _collist); + } + _collist.add(clean == null ? ret : clean.clean(ret)); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonDynamicLimit(final long personNo, final byte maxRows) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + byte _rowCount = 0; + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.put(rs.getString(1), ret); + if(maxRows > 0 && ++_rowCount == maxRows) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonDynamicLimit(final long personNo, final short arrayMaxLength) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + short _rowCount = 0; + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.put(rs.getString(1), ret); + if(arrayMaxLength > 0 && ++_rowCount == arrayMaxLength) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPersonDynamicLimit(final long personNo, final int maxRows) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + int _rowCount = 0; + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.add(ret); + if(maxRows > 0 && ++_rowCount == maxRows) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map> getPersonDynamicLimit(final long personNo, final long rowLimit) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + long _rowCount = 0; + final java.util.Map> _colret = new java.util.HashMap>(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + final java.lang.String _colkey = rs.getString(1); + java.util.List _collist = _colret.get(_colkey); + if(_collist == null) { + _collist = new java.util.ArrayList(); + _colret.put(_colkey, _collist); + } + _collist.add(ret); + if(rowLimit > 0 && ++_rowCount == rowLimit) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPersonStaticLimitListByte(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + byte _rowCount = 0; + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.add(ret); + if(++_rowCount == 127) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPersonStaticLimitList(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + short _rowCount = 0; + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.add(ret); + if(++_rowCount == 32767) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonStaticLimitMap(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + int _rowCount = 0; + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.put(rs.getString(1), ret); + if(++_rowCount == 2147483647) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map> getPersonStaticLimitMapList(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + long _rowCount = 0; + final java.util.Map> _colret = new java.util.HashMap>(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + final java.lang.String _colkey = rs.getString(1); + java.util.List _collist = _colret.get(_colkey); + if(_collist == null) { + _collist = new java.util.ArrayList(); + _colret.put(_colkey, _collist); + } + _collist.add(ret); + if(++_rowCount == 9223372036854775807L) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeopleList(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no, birth_date, last_name, first_name from person WHERE person_no IN (?,?,?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 2), +rs.getString(4), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.util.ResultSetIterable getPeopleResultSetIterable(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no, birth_date, last_name, first_name from person WHERE person_no IN (?,?,?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + return com.moparisthebest.jdbc.util.ResultSetIterable.getResultSetIterable(rs, + rs.next() ? new com.moparisthebest.jdbc.util.ResultSetToObject() { + public com.moparisthebest.jdbc.dto.FieldPerson toObject(final ResultSet _rs, final java.util.Calendar _cal) throws SQLException { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 2), +_rs.getString(4), +_rs.getString(3)); + return ret; + } + } + : null, null).setPreparedStatementToClose(ps); + } catch(Throwable e) { + tryClose(rs); + tryClose(ps); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public com.moparisthebest.jdbc.util.ResultSetIterable getPeopleResultSetIterableCachedPreparedStatement(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(1, "SELECT person_no, birth_date, last_name, first_name from person WHERE person_no IN (?,?,?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + return com.moparisthebest.jdbc.util.ResultSetIterable.getResultSetIterable(rs, + rs.next() ? new com.moparisthebest.jdbc.util.ResultSetToObject() { + public com.moparisthebest.jdbc.dto.FieldPerson toObject(final ResultSet _rs, final java.util.Calendar _cal) throws SQLException { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 2), +_rs.getString(4), +_rs.getString(3)); + return ret; + } + } + : null, null); + } catch(Throwable e) { + tryClose(rs); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPersonConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson( +com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FirstName getFirstNameEnum(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPersonNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val as first_name, str_val as last_name FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FirstName getEnumNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.CaseSensitivePerson getCaseSensitivePerson(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name AS M_PERSON_FIRST_NAME FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.CaseSensitivePerson ret = new com.moparisthebest.jdbc.dto.CaseSensitivePerson(); +ret.setmPersonFirstName(rs.getString(1)); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson getSameClassPathEnumPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson ret = new com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson getSameClassPathEnumPersonConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson ret = new com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson( +com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName getSameClassPathFirstNameEnum(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson getSameClassPathEnumPersonNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val as first_name, str_val as last_name FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson ret = new com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName getSameClassPathEnumNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeopleInListArray(final java.lang.Long[] personNos) { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("NUMERIC", personNos); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (person_no = ANY(?))"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeopleInListCollection(final java.util.Collection personNos) { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("NUMERIC", personNos.toArray(new java.lang.Long[personNos.size()])); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (person_no = ANY(?))"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + tryClose(ps); + } + } + + @Override + public byte[] getBlob(final long valNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT some_blob FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final byte[] ret = rs.getBytes(1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.lang.String[] getSinglePersonNameArray(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.String[] ret = new java.lang.String[2]; +ret[0] = rs.getString(1); +ret[1] = rs.getString(2); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getSinglePersonNameMap(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Map ret = new java.util.HashMap(); +ret.put("first_name", rs.getString(1)); +ret.put("last_name", rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + private static final java.lang.reflect.Field[] _fields = new java.lang.reflect.Field[] { + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "firstName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "lastName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "birthDate"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "personNo"), + }; + + private final PreparedStatement[] psCache = new PreparedStatement[2]; + + private PreparedStatement prepareStatement(final int index, final String sql) throws SQLException { + final PreparedStatement ps = psCache[index]; + return ps == null ? (psCache[index] = conn.prepareStatement(sql)) : ps; + } + + @Override + public void close() { + for(final PreparedStatement ps : psCache) + tryClose(ps); + if(closeConn) + tryClose(conn); + } + + public PersonDAOAnyBean(final Factory connectionFactory) throws SQLException { + this(connectionFactory.create(), true); + } + + public PersonDAOAnyBean(final String jndiName) throws SQLException { + this(com.moparisthebest.jdbc.codegen.JdbcMapperFactory.connectionFactory(jndiName)); + } + + @Override + public SqlBuilder sqlBuilder() { + return SqlBuilder.of(conn, com.moparisthebest.jdbc.ArrayInList.instance()); + } +} 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 new file mode 100644 index 0000000..0b2b2b5 --- /dev/null +++ b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/PersonDAOBean.java @@ -0,0 +1,1652 @@ +package com.moparisthebest.jdbc.codegen; + +import com.moparisthebest.jdbc.util.SqlBuilder; +import com.moparisthebest.jdbc.Factory; + +import java.sql.*; + +import static com.moparisthebest.jdbc.util.ResultSetUtil.*; +import static com.moparisthebest.jdbc.TryClose.tryClose; + +public class PersonDAOBean implements PersonDAO { + + private final Connection conn; + private final boolean closeConn; + + private static final Factory _conFactory = com.moparisthebest.jdbc.codegen.JdbcMapperFactory.connectionFactory("bob"); + + public PersonDAOBean() throws SQLException { + this(_conFactory); + } + + private PersonDAOBean(final Connection conn, final boolean closeConn) { + this.conn = conn; + this.closeConn = closeConn; + if (this.conn == null) + throw new NullPointerException("Connection needs to be non-null for JdbcMapper..."); + } + + public PersonDAOBean(Connection conn) { + this(conn, false); + } + + public Connection getConnection() { + return this.conn; + } + + @Override + public void createTablePerson() { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("CREATE TABLE person (person_no NUMERIC, first_name VARCHAR(40), last_name VARCHAR(40), birth_date TIMESTAMP)"); + ps.executeUpdate(); + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public int insertPerson(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)"); + ps.setObject(1, personNo); + ps.setObject(2, birthDate == null ? null : new java.sql.Timestamp(birthDate.getTime())); + ps.setObject(3, firstName); + ps.setObject(4, lastName); + return ps.executeUpdate(); + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public long insertPersonGeneratedKey(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)", java.sql.Statement.RETURN_GENERATED_KEYS); + ps.setObject(1, personNo); + ps.setObject(2, birthDate == null ? null : new java.sql.Timestamp(birthDate.getTime())); + ps.setObject(3, firstName); + ps.setObject(4, lastName); + ps.executeUpdate(); + ResultSet rs = null; + try { + rs = ps.getGeneratedKeys(); + return rs.next() ? rs.getLong(1) : 0; + } finally { + tryClose(rs); + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public java.lang.Long insertPersonGeneratedKeyLong(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)", java.sql.Statement.RETURN_GENERATED_KEYS); + ps.setObject(1, personNo); + ps.setObject(2, birthDate == null ? null : new java.sql.Timestamp(birthDate.getTime())); + ps.setObject(3, firstName); + ps.setObject(4, lastName); + ps.executeUpdate(); + ResultSet rs = null; + try { + rs = ps.getGeneratedKeys(); + return rs.next() ? com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1) : null; + } finally { + tryClose(rs); + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public int setFirstName(final java.lang.String firstName, final java.lang.String lastName) { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE last_name = ?"); + ps.setObject(1, firstName); + ps.setObject(2, lastName); + return ps.executeUpdate(); + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public void setFirstName(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.setObject(1, firstName); + ps.setObject(2, personNo); + ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + @Override + public void setFirstNameBlob(final byte[] firstName, final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE person_no = ?"); + ps.setBlob(1, firstName == null ? null : new java.io.ByteArrayInputStream(firstName)); + ps.setObject(2, personNo); + ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + @Override + public void setFirstNameBlob(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-8"))); + } catch (java.io.UnsupportedEncodingException e) { + throw new SQLException("String to Blob UnsupportedEncodingException", e); + } + 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; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + if(rs.next()) { +final long ret = rs.getLong(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public long getPersonNoUnusedParam(final java.lang.String lastName, final java.lang.String _bla) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + if(rs.next()) { +final long ret = rs.getLong(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.ResultSet getPeopleResultSet(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + return new com.moparisthebest.jdbc.StatementClosingResultSet(rs, ps); + } catch(Throwable e) { + tryClose(rs); + tryClose(ps); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public java.sql.ResultSet getPeopleResultSetCached(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(0, "SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + return rs; + } catch(Throwable e) { + tryClose(rs); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public java.lang.String getFirstNameColumnNames(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.String ret = rs.getString(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.lang.String getFirstName(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.String ret = rs.getString(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public int getFirstNameUpdate(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + return ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPersonColumnNames(final long personNo) 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPerson(final long personNo) 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.BuilderPerson getBuilderPerson(final long personNo) 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.BuilderPerson ret = new com.moparisthebest.jdbc.dto.BuilderPerson(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPerson(final long personNo, final java.util.Calendar cal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3, 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; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeople(final java.lang.String[] lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("TEXT", lastName); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (NOT(last_name = ANY(?)))"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeople(final java.util.List lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("TEXT", lastName.toArray(new java.lang.String[lastName.size()])); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (last_name = ANY(?))"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson[] getPeopleArray(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret.toArray(new com.moparisthebest.jdbc.dto.FieldPerson[_colret.size()]); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Iterator getPeopleIterator(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret.iterator(); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.ListIterator getPeopleListIterator(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret.listIterator(); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonMap(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, rs.getLong(3)); + _colret.put(rs.getString(1), ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map> getPersonMapList(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.Map> _colret = new java.util.HashMap>(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, rs.getLong(3)); + final java.lang.String _colkey = rs.getString(1); + java.util.List _collist = _colret.get(_colkey); + if(_collist == null) { + _collist = new java.util.ArrayList(); + _colret.put(_colkey, _collist); + } + _collist.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.lang.String getFirstName(final long personNo, final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ? and last_name = ?"); + ps.setObject(1, personNo); + ps.setObject(2, lastName); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.String ret = rs.getString(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Calendar getBirthDateCalendar(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Calendar ret = com.moparisthebest.jdbc.util.ResultSetUtil.getCalendar(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Calendar getBirthDateCalendar(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Calendar ret = com.moparisthebest.jdbc.util.ResultSetUtil.getCalendar(rs, 1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Timestamp getBirthDateTimestamp(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Timestamp ret = rs.getTimestamp(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Timestamp getBirthDateTimestamp(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Timestamp ret = rs.getTimestamp(1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Time getBirthDateTime(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Time ret = rs.getTime(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Time getBirthDateTime(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Time ret = rs.getTime(1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Date getBirthDateSqlDate(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Date ret = rs.getDate(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Date getBirthDateSqlDate(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Date ret = rs.getDate(1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Date getBirthDateUtilDate(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Date ret = com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Date getBirthDateUtilDate(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Date ret = com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPersonCleanFieldPerson(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + return clean == null ? ret : clean.clean(ret); + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPersonCleanPerson(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + return clean == null ? ret : clean.clean(ret); + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPersonCleanObject(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + return clean == null ? ret : clean.clean(ret); + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPersonCleanPersonList(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.add(clean == null ? ret : clean.clean(ret)); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonCleanPersonMap(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.put(rs.getString(1), clean == null ? ret : clean.clean(ret)); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map> getPersonCleanPersonMapList(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + final java.util.Map> _colret = new java.util.HashMap>(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + final java.lang.String _colkey = rs.getString(1); + java.util.List _collist = _colret.get(_colkey); + if(_collist == null) { + _collist = new java.util.ArrayList(); + _colret.put(_colkey, _collist); + } + _collist.add(clean == null ? ret : clean.clean(ret)); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonDynamicLimit(final long personNo, final byte maxRows) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + byte _rowCount = 0; + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.put(rs.getString(1), ret); + if(maxRows > 0 && ++_rowCount == maxRows) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonDynamicLimit(final long personNo, final short arrayMaxLength) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + short _rowCount = 0; + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.put(rs.getString(1), ret); + if(arrayMaxLength > 0 && ++_rowCount == arrayMaxLength) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPersonDynamicLimit(final long personNo, final int maxRows) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + int _rowCount = 0; + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.add(ret); + if(maxRows > 0 && ++_rowCount == maxRows) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map> getPersonDynamicLimit(final long personNo, final long rowLimit) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + long _rowCount = 0; + final java.util.Map> _colret = new java.util.HashMap>(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + final java.lang.String _colkey = rs.getString(1); + java.util.List _collist = _colret.get(_colkey); + if(_collist == null) { + _collist = new java.util.ArrayList(); + _colret.put(_colkey, _collist); + } + _collist.add(ret); + if(rowLimit > 0 && ++_rowCount == rowLimit) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPersonStaticLimitListByte(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + byte _rowCount = 0; + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.add(ret); + if(++_rowCount == 127) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPersonStaticLimitList(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + short _rowCount = 0; + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.add(ret); + if(++_rowCount == 32767) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonStaticLimitMap(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + int _rowCount = 0; + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.put(rs.getString(1), ret); + if(++_rowCount == 2147483647) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map> getPersonStaticLimitMapList(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + long _rowCount = 0; + final java.util.Map> _colret = new java.util.HashMap>(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + final java.lang.String _colkey = rs.getString(1); + java.util.List _collist = _colret.get(_colkey); + if(_collist == null) { + _collist = new java.util.ArrayList(); + _colret.put(_colkey, _collist); + } + _collist.add(ret); + if(++_rowCount == 9223372036854775807L) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeopleList(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no, birth_date, last_name, first_name from person WHERE person_no IN (?,?,?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 2), +rs.getString(4), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.util.ResultSetIterable getPeopleResultSetIterable(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no, birth_date, last_name, first_name from person WHERE person_no IN (?,?,?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + return com.moparisthebest.jdbc.util.ResultSetIterable.getResultSetIterable(rs, + rs.next() ? new com.moparisthebest.jdbc.util.ResultSetToObject() { + public com.moparisthebest.jdbc.dto.FieldPerson toObject(final ResultSet _rs, final java.util.Calendar _cal) throws SQLException { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 2), +_rs.getString(4), +_rs.getString(3)); + return ret; + } + } + : null, null).setPreparedStatementToClose(ps); + } catch(Throwable e) { + tryClose(rs); + tryClose(ps); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public com.moparisthebest.jdbc.util.ResultSetIterable getPeopleResultSetIterableCachedPreparedStatement(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(1, "SELECT person_no, birth_date, last_name, first_name from person WHERE person_no IN (?,?,?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + return com.moparisthebest.jdbc.util.ResultSetIterable.getResultSetIterable(rs, + rs.next() ? new com.moparisthebest.jdbc.util.ResultSetToObject() { + public com.moparisthebest.jdbc.dto.FieldPerson toObject(final ResultSet _rs, final java.util.Calendar _cal) throws SQLException { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 2), +_rs.getString(4), +_rs.getString(3)); + return ret; + } + } + : null, null); + } catch(Throwable e) { + tryClose(rs); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPersonConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson( +com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FirstName getFirstNameEnum(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPersonNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val as first_name, str_val as last_name FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FirstName getEnumNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.CaseSensitivePerson getCaseSensitivePerson(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name AS M_PERSON_FIRST_NAME FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.CaseSensitivePerson ret = new com.moparisthebest.jdbc.dto.CaseSensitivePerson(); +ret.setmPersonFirstName(rs.getString(1)); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson getSameClassPathEnumPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson ret = new com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson getSameClassPathEnumPersonConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson ret = new com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson( +com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName getSameClassPathFirstNameEnum(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson getSameClassPathEnumPersonNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val as first_name, str_val as last_name FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson ret = new com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName getSameClassPathEnumNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeopleInListArray(final java.lang.Long[] personNos) { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("NUMERIC", personNos); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (person_no = ANY(?))"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeopleInListCollection(final java.util.Collection personNos) { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("NUMERIC", personNos.toArray(new java.lang.Long[personNos.size()])); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (person_no = ANY(?))"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + tryClose(ps); + } + } + + @Override + public byte[] getBlob(final long valNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT some_blob FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final byte[] ret = rs.getBytes(1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.lang.String[] getSinglePersonNameArray(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.String[] ret = new java.lang.String[2]; +ret[0] = rs.getString(1); +ret[1] = rs.getString(2); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getSinglePersonNameMap(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Map ret = new java.util.HashMap(); +ret.put("first_name", rs.getString(1)); +ret.put("last_name", rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + private static final java.lang.reflect.Field[] _fields = new java.lang.reflect.Field[] { + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "firstName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "lastName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "birthDate"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "personNo"), + }; + + private final PreparedStatement[] psCache = new PreparedStatement[2]; + + private PreparedStatement prepareStatement(final int index, final String sql) throws SQLException { + final PreparedStatement ps = psCache[index]; + return ps == null ? (psCache[index] = conn.prepareStatement(sql)) : ps; + } + + @Override + public void close() { + for(final PreparedStatement ps : psCache) + tryClose(ps); + if(closeConn) + tryClose(conn); + } + + public PersonDAOBean(final Factory connectionFactory) throws SQLException { + this(connectionFactory.create(), true); + } + + public PersonDAOBean(final String jndiName) throws SQLException { + this(com.moparisthebest.jdbc.codegen.JdbcMapperFactory.connectionFactory(jndiName)); + } + + @Override + public SqlBuilder sqlBuilder() { + return SqlBuilder.of(conn, com.moparisthebest.jdbc.ArrayInList.instance()); + } +} 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 new file mode 100644 index 0000000..da2d99a --- /dev/null +++ b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/PersonDAOBindBean.java @@ -0,0 +1,1652 @@ +package com.moparisthebest.jdbc.codegen; + +import com.moparisthebest.jdbc.util.SqlBuilder; +import com.moparisthebest.jdbc.Factory; + +import java.sql.*; + +import static com.moparisthebest.jdbc.util.ResultSetUtil.*; +import static com.moparisthebest.jdbc.TryClose.tryClose; + +public class PersonDAOBindBean implements PersonDAO { + + private final Connection conn; + private final boolean closeConn; + + private static final Factory _conFactory = com.moparisthebest.jdbc.codegen.JdbcMapperFactory.connectionFactory("bob"); + + public PersonDAOBindBean() throws SQLException { + this(_conFactory); + } + + private PersonDAOBindBean(final Connection conn, final boolean closeConn) { + this.conn = conn; + this.closeConn = closeConn; + if (this.conn == null) + throw new NullPointerException("Connection needs to be non-null for JdbcMapper..."); + } + + public PersonDAOBindBean(Connection conn) { + this(conn, false); + } + + public Connection getConnection() { + return this.conn; + } + + @Override + public void createTablePerson() { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("CREATE TABLE person (person_no NUMERIC, first_name VARCHAR(40), last_name VARCHAR(40), birth_date TIMESTAMP)"); + ps.executeUpdate(); + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public int insertPerson(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)"); + ps.setObject(1, personNo); + ps.setObject(2, birthDate == null ? null : new java.sql.Timestamp(birthDate.getTime())); + ps.setObject(3, firstName); + ps.setObject(4, lastName); + return ps.executeUpdate(); + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public long insertPersonGeneratedKey(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)", java.sql.Statement.RETURN_GENERATED_KEYS); + ps.setObject(1, personNo); + ps.setObject(2, birthDate == null ? null : new java.sql.Timestamp(birthDate.getTime())); + ps.setObject(3, firstName); + ps.setObject(4, lastName); + ps.executeUpdate(); + ResultSet rs = null; + try { + rs = ps.getGeneratedKeys(); + return rs.next() ? rs.getLong(1) : 0; + } finally { + tryClose(rs); + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public java.lang.Long insertPersonGeneratedKeyLong(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)", java.sql.Statement.RETURN_GENERATED_KEYS); + ps.setObject(1, personNo); + ps.setObject(2, birthDate == null ? null : new java.sql.Timestamp(birthDate.getTime())); + ps.setObject(3, firstName); + ps.setObject(4, lastName); + ps.executeUpdate(); + ResultSet rs = null; + try { + rs = ps.getGeneratedKeys(); + return rs.next() ? com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1) : null; + } finally { + tryClose(rs); + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public int setFirstName(final java.lang.String firstName, final java.lang.String lastName) { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE last_name = ?"); + ps.setObject(1, firstName); + ps.setObject(2, lastName); + return ps.executeUpdate(); + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public void setFirstName(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.setObject(1, firstName); + ps.setObject(2, personNo); + ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + @Override + public void setFirstNameBlob(final byte[] firstName, final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE person_no = ?"); + ps.setBlob(1, firstName == null ? null : new java.io.ByteArrayInputStream(firstName)); + ps.setObject(2, personNo); + ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + @Override + public void setFirstNameBlob(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-8"))); + } catch (java.io.UnsupportedEncodingException e) { + throw new SQLException("String to Blob UnsupportedEncodingException", e); + } + 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; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + if(rs.next()) { +final long ret = rs.getLong(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public long getPersonNoUnusedParam(final java.lang.String lastName, final java.lang.String _bla) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + if(rs.next()) { +final long ret = rs.getLong(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.ResultSet getPeopleResultSet(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + return new com.moparisthebest.jdbc.StatementClosingResultSet(rs, ps); + } catch(Throwable e) { + tryClose(rs); + tryClose(ps); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public java.sql.ResultSet getPeopleResultSetCached(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(0, "SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + return rs; + } catch(Throwable e) { + tryClose(rs); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public java.lang.String getFirstNameColumnNames(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.String ret = rs.getString(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.lang.String getFirstName(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.String ret = rs.getString(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public int getFirstNameUpdate(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + return ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPersonColumnNames(final long personNo) 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPerson(final long personNo) 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.BuilderPerson getBuilderPerson(final long personNo) 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.BuilderPerson ret = new com.moparisthebest.jdbc.dto.BuilderPerson(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPerson(final long personNo, final java.util.Calendar cal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3, 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; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeople(final java.lang.String[] lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("TEXT", lastName); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (NOT(last_name = ANY(?)))"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeople(final java.util.List lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("TEXT", lastName.toArray(new java.lang.String[lastName.size()])); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (last_name = ANY(?))"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson[] getPeopleArray(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret.toArray(new com.moparisthebest.jdbc.dto.FieldPerson[_colret.size()]); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Iterator getPeopleIterator(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret.iterator(); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.ListIterator getPeopleListIterator(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret.listIterator(); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonMap(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, rs.getLong(3)); + _colret.put(rs.getString(1), ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map> getPersonMapList(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.Map> _colret = new java.util.HashMap>(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, rs.getLong(3)); + final java.lang.String _colkey = rs.getString(1); + java.util.List _collist = _colret.get(_colkey); + if(_collist == null) { + _collist = new java.util.ArrayList(); + _colret.put(_colkey, _collist); + } + _collist.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.lang.String getFirstName(final long personNo, final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ? and last_name = ?"); + ps.setObject(1, personNo); + ps.setObject(2, lastName); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.String ret = rs.getString(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Calendar getBirthDateCalendar(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Calendar ret = com.moparisthebest.jdbc.util.ResultSetUtil.getCalendar(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Calendar getBirthDateCalendar(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Calendar ret = com.moparisthebest.jdbc.util.ResultSetUtil.getCalendar(rs, 1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Timestamp getBirthDateTimestamp(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Timestamp ret = rs.getTimestamp(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Timestamp getBirthDateTimestamp(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Timestamp ret = rs.getTimestamp(1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Time getBirthDateTime(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Time ret = rs.getTime(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Time getBirthDateTime(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Time ret = rs.getTime(1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Date getBirthDateSqlDate(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Date ret = rs.getDate(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Date getBirthDateSqlDate(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Date ret = rs.getDate(1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Date getBirthDateUtilDate(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Date ret = com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Date getBirthDateUtilDate(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Date ret = com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPersonCleanFieldPerson(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + return clean == null ? ret : clean.clean(ret); + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPersonCleanPerson(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + return clean == null ? ret : clean.clean(ret); + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPersonCleanObject(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + return clean == null ? ret : clean.clean(ret); + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPersonCleanPersonList(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.add(clean == null ? ret : clean.clean(ret)); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonCleanPersonMap(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.put(rs.getString(1), clean == null ? ret : clean.clean(ret)); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map> getPersonCleanPersonMapList(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + final java.util.Map> _colret = new java.util.HashMap>(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + final java.lang.String _colkey = rs.getString(1); + java.util.List _collist = _colret.get(_colkey); + if(_collist == null) { + _collist = new java.util.ArrayList(); + _colret.put(_colkey, _collist); + } + _collist.add(clean == null ? ret : clean.clean(ret)); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonDynamicLimit(final long personNo, final byte maxRows) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + byte _rowCount = 0; + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.put(rs.getString(1), ret); + if(maxRows > 0 && ++_rowCount == maxRows) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonDynamicLimit(final long personNo, final short arrayMaxLength) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + short _rowCount = 0; + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.put(rs.getString(1), ret); + if(arrayMaxLength > 0 && ++_rowCount == arrayMaxLength) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPersonDynamicLimit(final long personNo, final int maxRows) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + int _rowCount = 0; + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.add(ret); + if(maxRows > 0 && ++_rowCount == maxRows) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map> getPersonDynamicLimit(final long personNo, final long rowLimit) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + long _rowCount = 0; + final java.util.Map> _colret = new java.util.HashMap>(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + final java.lang.String _colkey = rs.getString(1); + java.util.List _collist = _colret.get(_colkey); + if(_collist == null) { + _collist = new java.util.ArrayList(); + _colret.put(_colkey, _collist); + } + _collist.add(ret); + if(rowLimit > 0 && ++_rowCount == rowLimit) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPersonStaticLimitListByte(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + byte _rowCount = 0; + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.add(ret); + if(++_rowCount == 127) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPersonStaticLimitList(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + short _rowCount = 0; + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.add(ret); + if(++_rowCount == 32767) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonStaticLimitMap(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + int _rowCount = 0; + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.put(rs.getString(1), ret); + if(++_rowCount == 2147483647) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map> getPersonStaticLimitMapList(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + long _rowCount = 0; + final java.util.Map> _colret = new java.util.HashMap>(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + final java.lang.String _colkey = rs.getString(1); + java.util.List _collist = _colret.get(_colkey); + if(_collist == null) { + _collist = new java.util.ArrayList(); + _colret.put(_colkey, _collist); + } + _collist.add(ret); + if(++_rowCount == 9223372036854775807L) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeopleList(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no, birth_date, last_name, first_name from person WHERE person_no IN (?,?,?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 2), +rs.getString(4), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.util.ResultSetIterable getPeopleResultSetIterable(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no, birth_date, last_name, first_name from person WHERE person_no IN (?,?,?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + return com.moparisthebest.jdbc.util.ResultSetIterable.getResultSetIterable(rs, + rs.next() ? new com.moparisthebest.jdbc.util.ResultSetToObject() { + public com.moparisthebest.jdbc.dto.FieldPerson toObject(final ResultSet _rs, final java.util.Calendar _cal) throws SQLException { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 2), +_rs.getString(4), +_rs.getString(3)); + return ret; + } + } + : null, null).setPreparedStatementToClose(ps); + } catch(Throwable e) { + tryClose(rs); + tryClose(ps); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public com.moparisthebest.jdbc.util.ResultSetIterable getPeopleResultSetIterableCachedPreparedStatement(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(1, "SELECT person_no, birth_date, last_name, first_name from person WHERE person_no IN (?,?,?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + return com.moparisthebest.jdbc.util.ResultSetIterable.getResultSetIterable(rs, + rs.next() ? new com.moparisthebest.jdbc.util.ResultSetToObject() { + public com.moparisthebest.jdbc.dto.FieldPerson toObject(final ResultSet _rs, final java.util.Calendar _cal) throws SQLException { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 2), +_rs.getString(4), +_rs.getString(3)); + return ret; + } + } + : null, null); + } catch(Throwable e) { + tryClose(rs); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPersonConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson( +com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FirstName getFirstNameEnum(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPersonNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val as first_name, str_val as last_name FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FirstName getEnumNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.CaseSensitivePerson getCaseSensitivePerson(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name AS M_PERSON_FIRST_NAME FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.CaseSensitivePerson ret = new com.moparisthebest.jdbc.dto.CaseSensitivePerson(); +ret.setmPersonFirstName(rs.getString(1)); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson getSameClassPathEnumPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson ret = new com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson getSameClassPathEnumPersonConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson ret = new com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson( +com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName getSameClassPathFirstNameEnum(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson getSameClassPathEnumPersonNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val as first_name, str_val as last_name FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson ret = new com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName getSameClassPathEnumNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeopleInListArray(final java.lang.Long[] personNos) { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("NUMERIC", personNos); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (person_no = ANY(?))"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeopleInListCollection(final java.util.Collection personNos) { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("NUMERIC", personNos.toArray(new java.lang.Long[personNos.size()])); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (person_no = ANY(?))"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + tryClose(ps); + } + } + + @Override + public byte[] getBlob(final long valNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT some_blob FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final byte[] ret = rs.getBytes(1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.lang.String[] getSinglePersonNameArray(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.String[] ret = new java.lang.String[2]; +ret[0] = rs.getString(1); +ret[1] = rs.getString(2); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getSinglePersonNameMap(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Map ret = new java.util.HashMap(); +ret.put("first_name", rs.getString(1)); +ret.put("last_name", rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + private static final java.lang.reflect.Field[] _fields = new java.lang.reflect.Field[] { + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "firstName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "lastName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "birthDate"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "personNo"), + }; + + private final PreparedStatement[] psCache = new PreparedStatement[2]; + + private PreparedStatement prepareStatement(final int index, final String sql) throws SQLException { + final PreparedStatement ps = psCache[index]; + return ps == null ? (psCache[index] = conn.prepareStatement(sql)) : ps; + } + + @Override + public void close() { + for(final PreparedStatement ps : psCache) + tryClose(ps); + if(closeConn) + tryClose(conn); + } + + public PersonDAOBindBean(final Factory connectionFactory) throws SQLException { + this(connectionFactory.create(), true); + } + + public PersonDAOBindBean(final String jndiName) throws SQLException { + this(com.moparisthebest.jdbc.codegen.JdbcMapperFactory.connectionFactory(jndiName)); + } + + @Override + public SqlBuilder sqlBuilder() { + return SqlBuilder.of(conn, com.moparisthebest.jdbc.ArrayInList.instance()); + } +} 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 new file mode 100644 index 0000000..90072cd --- /dev/null +++ b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/PersonDAOOracleBean.java @@ -0,0 +1,1652 @@ +package com.moparisthebest.jdbc.codegen; + +import com.moparisthebest.jdbc.util.SqlBuilder; +import com.moparisthebest.jdbc.Factory; + +import java.sql.*; + +import static com.moparisthebest.jdbc.util.ResultSetUtil.*; +import static com.moparisthebest.jdbc.TryClose.tryClose; + +public class PersonDAOOracleBean implements PersonDAO { + + private final Connection conn; + private final boolean closeConn; + + private static final Factory _conFactory = com.moparisthebest.jdbc.codegen.JdbcMapperFactory.connectionFactory("bob"); + + public PersonDAOOracleBean() throws SQLException { + this(_conFactory); + } + + private PersonDAOOracleBean(final Connection conn, final boolean closeConn) { + this.conn = conn; + this.closeConn = closeConn; + if (this.conn == null) + throw new NullPointerException("Connection needs to be non-null for JdbcMapper..."); + } + + public PersonDAOOracleBean(Connection conn) { + this(conn, false); + } + + public Connection getConnection() { + return this.conn; + } + + @Override + public void createTablePerson() { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("CREATE TABLE person (person_no NUMERIC, first_name VARCHAR(40), last_name VARCHAR(40), birth_date TIMESTAMP)"); + ps.executeUpdate(); + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public int insertPerson(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)"); + ps.setObject(1, personNo); + ps.setObject(2, birthDate == null ? null : new java.sql.Timestamp(birthDate.getTime())); + ps.setObject(3, firstName); + ps.setObject(4, lastName); + return ps.executeUpdate(); + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public long insertPersonGeneratedKey(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)", java.sql.Statement.RETURN_GENERATED_KEYS); + ps.setObject(1, personNo); + ps.setObject(2, birthDate == null ? null : new java.sql.Timestamp(birthDate.getTime())); + ps.setObject(3, firstName); + ps.setObject(4, lastName); + ps.executeUpdate(); + ResultSet rs = null; + try { + rs = ps.getGeneratedKeys(); + return rs.next() ? rs.getLong(1) : 0; + } finally { + tryClose(rs); + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public java.lang.Long insertPersonGeneratedKeyLong(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)", java.sql.Statement.RETURN_GENERATED_KEYS); + ps.setObject(1, personNo); + ps.setObject(2, birthDate == null ? null : new java.sql.Timestamp(birthDate.getTime())); + ps.setObject(3, firstName); + ps.setObject(4, lastName); + ps.executeUpdate(); + ResultSet rs = null; + try { + rs = ps.getGeneratedKeys(); + return rs.next() ? com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1) : null; + } finally { + tryClose(rs); + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public int setFirstName(final java.lang.String firstName, final java.lang.String lastName) { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE last_name = ?"); + ps.setObject(1, firstName); + ps.setObject(2, lastName); + return ps.executeUpdate(); + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public void setFirstName(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.setObject(1, firstName); + ps.setObject(2, personNo); + ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + @Override + public void setFirstNameBlob(final byte[] firstName, final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE person_no = ?"); + ps.setBlob(1, firstName == null ? null : new java.io.ByteArrayInputStream(firstName)); + ps.setObject(2, personNo); + ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + @Override + public void setFirstNameBlob(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-8"))); + } catch (java.io.UnsupportedEncodingException e) { + throw new SQLException("String to Blob UnsupportedEncodingException", e); + } + 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; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + if(rs.next()) { +final long ret = rs.getLong(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public long getPersonNoUnusedParam(final java.lang.String lastName, final java.lang.String _bla) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + if(rs.next()) { +final long ret = rs.getLong(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.ResultSet getPeopleResultSet(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + return new com.moparisthebest.jdbc.StatementClosingResultSet(rs, ps); + } catch(Throwable e) { + tryClose(rs); + tryClose(ps); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public java.sql.ResultSet getPeopleResultSetCached(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(0, "SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + return rs; + } catch(Throwable e) { + tryClose(rs); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public java.lang.String getFirstNameColumnNames(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.String ret = rs.getString(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.lang.String getFirstName(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.String ret = rs.getString(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public int getFirstNameUpdate(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + return ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPersonColumnNames(final long personNo) 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPerson(final long personNo) 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.BuilderPerson getBuilderPerson(final long personNo) 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.BuilderPerson ret = new com.moparisthebest.jdbc.dto.BuilderPerson(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPerson(final long personNo, final java.util.Calendar cal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3, 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; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeople(final java.lang.String[] lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("TEXT", lastName); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (NOT(last_name = ANY(?)))"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeople(final java.util.List lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("TEXT", lastName.toArray(new java.lang.String[lastName.size()])); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (last_name = ANY(?))"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson[] getPeopleArray(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret.toArray(new com.moparisthebest.jdbc.dto.FieldPerson[_colret.size()]); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Iterator getPeopleIterator(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret.iterator(); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.ListIterator getPeopleListIterator(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret.listIterator(); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonMap(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, rs.getLong(3)); + _colret.put(rs.getString(1), ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map> getPersonMapList(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.Map> _colret = new java.util.HashMap>(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, rs.getLong(3)); + final java.lang.String _colkey = rs.getString(1); + java.util.List _collist = _colret.get(_colkey); + if(_collist == null) { + _collist = new java.util.ArrayList(); + _colret.put(_colkey, _collist); + } + _collist.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.lang.String getFirstName(final long personNo, final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ? and last_name = ?"); + ps.setObject(1, personNo); + ps.setObject(2, lastName); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.String ret = rs.getString(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Calendar getBirthDateCalendar(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Calendar ret = com.moparisthebest.jdbc.util.ResultSetUtil.getCalendar(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Calendar getBirthDateCalendar(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Calendar ret = com.moparisthebest.jdbc.util.ResultSetUtil.getCalendar(rs, 1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Timestamp getBirthDateTimestamp(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Timestamp ret = rs.getTimestamp(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Timestamp getBirthDateTimestamp(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Timestamp ret = rs.getTimestamp(1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Time getBirthDateTime(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Time ret = rs.getTime(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Time getBirthDateTime(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Time ret = rs.getTime(1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Date getBirthDateSqlDate(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Date ret = rs.getDate(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Date getBirthDateSqlDate(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Date ret = rs.getDate(1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Date getBirthDateUtilDate(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Date ret = com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Date getBirthDateUtilDate(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Date ret = com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPersonCleanFieldPerson(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + return clean == null ? ret : clean.clean(ret); + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPersonCleanPerson(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + return clean == null ? ret : clean.clean(ret); + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPersonCleanObject(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + return clean == null ? ret : clean.clean(ret); + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPersonCleanPersonList(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.add(clean == null ? ret : clean.clean(ret)); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonCleanPersonMap(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.put(rs.getString(1), clean == null ? ret : clean.clean(ret)); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map> getPersonCleanPersonMapList(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + final java.util.Map> _colret = new java.util.HashMap>(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + final java.lang.String _colkey = rs.getString(1); + java.util.List _collist = _colret.get(_colkey); + if(_collist == null) { + _collist = new java.util.ArrayList(); + _colret.put(_colkey, _collist); + } + _collist.add(clean == null ? ret : clean.clean(ret)); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonDynamicLimit(final long personNo, final byte maxRows) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + byte _rowCount = 0; + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.put(rs.getString(1), ret); + if(maxRows > 0 && ++_rowCount == maxRows) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonDynamicLimit(final long personNo, final short arrayMaxLength) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + short _rowCount = 0; + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.put(rs.getString(1), ret); + if(arrayMaxLength > 0 && ++_rowCount == arrayMaxLength) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPersonDynamicLimit(final long personNo, final int maxRows) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + int _rowCount = 0; + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.add(ret); + if(maxRows > 0 && ++_rowCount == maxRows) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map> getPersonDynamicLimit(final long personNo, final long rowLimit) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + long _rowCount = 0; + final java.util.Map> _colret = new java.util.HashMap>(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + final java.lang.String _colkey = rs.getString(1); + java.util.List _collist = _colret.get(_colkey); + if(_collist == null) { + _collist = new java.util.ArrayList(); + _colret.put(_colkey, _collist); + } + _collist.add(ret); + if(rowLimit > 0 && ++_rowCount == rowLimit) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPersonStaticLimitListByte(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + byte _rowCount = 0; + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.add(ret); + if(++_rowCount == 127) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPersonStaticLimitList(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + short _rowCount = 0; + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.add(ret); + if(++_rowCount == 32767) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonStaticLimitMap(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + int _rowCount = 0; + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.put(rs.getString(1), ret); + if(++_rowCount == 2147483647) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map> getPersonStaticLimitMapList(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + long _rowCount = 0; + final java.util.Map> _colret = new java.util.HashMap>(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + final java.lang.String _colkey = rs.getString(1); + java.util.List _collist = _colret.get(_colkey); + if(_collist == null) { + _collist = new java.util.ArrayList(); + _colret.put(_colkey, _collist); + } + _collist.add(ret); + if(++_rowCount == 9223372036854775807L) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeopleList(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no, birth_date, last_name, first_name from person WHERE person_no IN (?,?,?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 2), +rs.getString(4), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.util.ResultSetIterable getPeopleResultSetIterable(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no, birth_date, last_name, first_name from person WHERE person_no IN (?,?,?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + return com.moparisthebest.jdbc.util.ResultSetIterable.getResultSetIterable(rs, + rs.next() ? new com.moparisthebest.jdbc.util.ResultSetToObject() { + public com.moparisthebest.jdbc.dto.FieldPerson toObject(final ResultSet _rs, final java.util.Calendar _cal) throws SQLException { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 2), +_rs.getString(4), +_rs.getString(3)); + return ret; + } + } + : null, null).setPreparedStatementToClose(ps); + } catch(Throwable e) { + tryClose(rs); + tryClose(ps); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public com.moparisthebest.jdbc.util.ResultSetIterable getPeopleResultSetIterableCachedPreparedStatement(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(1, "SELECT person_no, birth_date, last_name, first_name from person WHERE person_no IN (?,?,?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + return com.moparisthebest.jdbc.util.ResultSetIterable.getResultSetIterable(rs, + rs.next() ? new com.moparisthebest.jdbc.util.ResultSetToObject() { + public com.moparisthebest.jdbc.dto.FieldPerson toObject(final ResultSet _rs, final java.util.Calendar _cal) throws SQLException { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 2), +_rs.getString(4), +_rs.getString(3)); + return ret; + } + } + : null, null); + } catch(Throwable e) { + tryClose(rs); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPersonConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson( +com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FirstName getFirstNameEnum(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPersonNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val as first_name, str_val as last_name FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FirstName getEnumNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.CaseSensitivePerson getCaseSensitivePerson(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name AS M_PERSON_FIRST_NAME FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.CaseSensitivePerson ret = new com.moparisthebest.jdbc.dto.CaseSensitivePerson(); +ret.setmPersonFirstName(rs.getString(1)); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson getSameClassPathEnumPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson ret = new com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson getSameClassPathEnumPersonConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson ret = new com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson( +com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName getSameClassPathFirstNameEnum(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson getSameClassPathEnumPersonNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val as first_name, str_val as last_name FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson ret = new com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName getSameClassPathEnumNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeopleInListArray(final java.lang.Long[] personNos) { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("NUMERIC", personNos); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (person_no = ANY(?))"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeopleInListCollection(final java.util.Collection personNos) { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("NUMERIC", personNos.toArray(new java.lang.Long[personNos.size()])); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (person_no = ANY(?))"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + tryClose(ps); + } + } + + @Override + public byte[] getBlob(final long valNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT some_blob FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final byte[] ret = rs.getBytes(1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.lang.String[] getSinglePersonNameArray(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.String[] ret = new java.lang.String[2]; +ret[0] = rs.getString(1); +ret[1] = rs.getString(2); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getSinglePersonNameMap(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Map ret = new java.util.HashMap(); +ret.put("first_name", rs.getString(1)); +ret.put("last_name", rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + private static final java.lang.reflect.Field[] _fields = new java.lang.reflect.Field[] { + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "firstName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "lastName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "birthDate"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "personNo"), + }; + + private final PreparedStatement[] psCache = new PreparedStatement[2]; + + private PreparedStatement prepareStatement(final int index, final String sql) throws SQLException { + final PreparedStatement ps = psCache[index]; + return ps == null ? (psCache[index] = conn.prepareStatement(sql)) : ps; + } + + @Override + public void close() { + for(final PreparedStatement ps : psCache) + tryClose(ps); + if(closeConn) + tryClose(conn); + } + + public PersonDAOOracleBean(final Factory connectionFactory) throws SQLException { + this(connectionFactory.create(), true); + } + + public PersonDAOOracleBean(final String jndiName) throws SQLException { + this(com.moparisthebest.jdbc.codegen.JdbcMapperFactory.connectionFactory(jndiName)); + } + + @Override + public SqlBuilder sqlBuilder() { + return SqlBuilder.of(conn, com.moparisthebest.jdbc.ArrayInList.instance()); + } +} 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 new file mode 100644 index 0000000..3149846 --- /dev/null +++ b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/PersonDAOUnNestBean.java @@ -0,0 +1,1652 @@ +package com.moparisthebest.jdbc.codegen; + +import com.moparisthebest.jdbc.util.SqlBuilder; +import com.moparisthebest.jdbc.Factory; + +import java.sql.*; + +import static com.moparisthebest.jdbc.util.ResultSetUtil.*; +import static com.moparisthebest.jdbc.TryClose.tryClose; + +public class PersonDAOUnNestBean implements PersonDAO { + + private final Connection conn; + private final boolean closeConn; + + private static final Factory _conFactory = com.moparisthebest.jdbc.codegen.JdbcMapperFactory.connectionFactory("bob"); + + public PersonDAOUnNestBean() throws SQLException { + this(_conFactory); + } + + private PersonDAOUnNestBean(final Connection conn, final boolean closeConn) { + this.conn = conn; + this.closeConn = closeConn; + if (this.conn == null) + throw new NullPointerException("Connection needs to be non-null for JdbcMapper..."); + } + + public PersonDAOUnNestBean(Connection conn) { + this(conn, false); + } + + public Connection getConnection() { + return this.conn; + } + + @Override + public void createTablePerson() { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("CREATE TABLE person (person_no NUMERIC, first_name VARCHAR(40), last_name VARCHAR(40), birth_date TIMESTAMP)"); + ps.executeUpdate(); + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public int insertPerson(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)"); + ps.setObject(1, personNo); + ps.setObject(2, birthDate == null ? null : new java.sql.Timestamp(birthDate.getTime())); + ps.setObject(3, firstName); + ps.setObject(4, lastName); + return ps.executeUpdate(); + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public long insertPersonGeneratedKey(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)", java.sql.Statement.RETURN_GENERATED_KEYS); + ps.setObject(1, personNo); + ps.setObject(2, birthDate == null ? null : new java.sql.Timestamp(birthDate.getTime())); + ps.setObject(3, firstName); + ps.setObject(4, lastName); + ps.executeUpdate(); + ResultSet rs = null; + try { + rs = ps.getGeneratedKeys(); + return rs.next() ? rs.getLong(1) : 0; + } finally { + tryClose(rs); + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public java.lang.Long insertPersonGeneratedKeyLong(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)", java.sql.Statement.RETURN_GENERATED_KEYS); + ps.setObject(1, personNo); + ps.setObject(2, birthDate == null ? null : new java.sql.Timestamp(birthDate.getTime())); + ps.setObject(3, firstName); + ps.setObject(4, lastName); + ps.executeUpdate(); + ResultSet rs = null; + try { + rs = ps.getGeneratedKeys(); + return rs.next() ? com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1) : null; + } finally { + tryClose(rs); + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public int setFirstName(final java.lang.String firstName, final java.lang.String lastName) { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE last_name = ?"); + ps.setObject(1, firstName); + ps.setObject(2, lastName); + return ps.executeUpdate(); + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(ps); + } + } + + @Override + public void setFirstName(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.setObject(1, firstName); + ps.setObject(2, personNo); + ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + @Override + public void setFirstNameBlob(final byte[] firstName, final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("UPDATE person SET first_name = ? WHERE person_no = ?"); + ps.setBlob(1, firstName == null ? null : new java.io.ByteArrayInputStream(firstName)); + ps.setObject(2, personNo); + ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + @Override + public void setFirstNameBlob(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-8"))); + } catch (java.io.UnsupportedEncodingException e) { + throw new SQLException("String to Blob UnsupportedEncodingException", e); + } + 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; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + if(rs.next()) { +final long ret = rs.getLong(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public long getPersonNoUnusedParam(final java.lang.String lastName, final java.lang.String _bla) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + if(rs.next()) { +final long ret = rs.getLong(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.ResultSet getPeopleResultSet(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + return new com.moparisthebest.jdbc.StatementClosingResultSet(rs, ps); + } catch(Throwable e) { + tryClose(rs); + tryClose(ps); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public java.sql.ResultSet getPeopleResultSetCached(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(0, "SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + return rs; + } catch(Throwable e) { + tryClose(rs); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public java.lang.String getFirstNameColumnNames(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.String ret = rs.getString(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.lang.String getFirstName(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.String ret = rs.getString(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public int getFirstNameUpdate(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + return ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPersonColumnNames(final long personNo) 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPerson(final long personNo) 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.BuilderPerson getBuilderPerson(final long personNo) 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.BuilderPerson ret = new com.moparisthebest.jdbc.dto.BuilderPerson(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPerson(final long personNo, final java.util.Calendar cal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3, 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; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeople(final java.lang.String[] lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("TEXT", lastName); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (NOT(last_name = ANY(?)))"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeople(final java.util.List lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("TEXT", lastName.toArray(new java.lang.String[lastName.size()])); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (last_name = ANY(?))"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson[] getPeopleArray(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret.toArray(new com.moparisthebest.jdbc.dto.FieldPerson[_colret.size()]); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Iterator getPeopleIterator(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret.iterator(); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.ListIterator getPeopleListIterator(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret.listIterator(); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonMap(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, rs.getLong(3)); + _colret.put(rs.getString(1), ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map> getPersonMapList(final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, person_no FROM person WHERE last_name = ?"); + ps.setObject(1, lastName); + rs = ps.executeQuery(); + final java.util.Map> _colret = new java.util.HashMap>(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, rs.getLong(3)); + final java.lang.String _colkey = rs.getString(1); + java.util.List _collist = _colret.get(_colkey); + if(_collist == null) { + _collist = new java.util.ArrayList(); + _colret.put(_colkey, _collist); + } + _collist.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.lang.String getFirstName(final long personNo, final java.lang.String lastName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ? and last_name = ?"); + ps.setObject(1, personNo); + ps.setObject(2, lastName); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.String ret = rs.getString(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Calendar getBirthDateCalendar(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Calendar ret = com.moparisthebest.jdbc.util.ResultSetUtil.getCalendar(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Calendar getBirthDateCalendar(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Calendar ret = com.moparisthebest.jdbc.util.ResultSetUtil.getCalendar(rs, 1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Timestamp getBirthDateTimestamp(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Timestamp ret = rs.getTimestamp(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Timestamp getBirthDateTimestamp(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Timestamp ret = rs.getTimestamp(1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Time getBirthDateTime(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Time ret = rs.getTime(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Time getBirthDateTime(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Time ret = rs.getTime(1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Date getBirthDateSqlDate(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Date ret = rs.getDate(1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.sql.Date getBirthDateSqlDate(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.sql.Date ret = rs.getDate(1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Date getBirthDateUtilDate(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Date ret = com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Date getBirthDateUtilDate(final long personNo, final java.util.Calendar mycal) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Date ret = com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 1, mycal); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPersonCleanFieldPerson(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + return clean == null ? ret : clean.clean(ret); + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPersonCleanPerson(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + return clean == null ? ret : clean.clean(ret); + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getPersonCleanObject(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT 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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + return clean == null ? ret : clean.clean(ret); + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPersonCleanPersonList(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.add(clean == null ? ret : clean.clean(ret)); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonCleanPersonMap(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.put(rs.getString(1), clean == null ? ret : clean.clean(ret)); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map> getPersonCleanPersonMapList(final long personNo, final com.moparisthebest.jdbc.Cleaner clean) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + final java.util.Map> _colret = new java.util.HashMap>(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + final java.lang.String _colkey = rs.getString(1); + java.util.List _collist = _colret.get(_colkey); + if(_collist == null) { + _collist = new java.util.ArrayList(); + _colret.put(_colkey, _collist); + } + _collist.add(clean == null ? ret : clean.clean(ret)); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonDynamicLimit(final long personNo, final byte maxRows) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + byte _rowCount = 0; + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.put(rs.getString(1), ret); + if(maxRows > 0 && ++_rowCount == maxRows) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonDynamicLimit(final long personNo, final short arrayMaxLength) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + short _rowCount = 0; + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.put(rs.getString(1), ret); + if(arrayMaxLength > 0 && ++_rowCount == arrayMaxLength) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPersonDynamicLimit(final long personNo, final int maxRows) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + int _rowCount = 0; + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.add(ret); + if(maxRows > 0 && ++_rowCount == maxRows) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map> getPersonDynamicLimit(final long personNo, final long rowLimit) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + long _rowCount = 0; + final java.util.Map> _colret = new java.util.HashMap>(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + final java.lang.String _colkey = rs.getString(1); + java.util.List _collist = _colret.get(_colkey); + if(_collist == null) { + _collist = new java.util.ArrayList(); + _colret.put(_colkey, _collist); + } + _collist.add(ret); + if(rowLimit > 0 && ++_rowCount == rowLimit) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPersonStaticLimitListByte(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + byte _rowCount = 0; + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.add(ret); + if(++_rowCount == 127) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPersonStaticLimitList(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + short _rowCount = 0; + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.add(ret); + if(++_rowCount == 32767) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getPersonStaticLimitMap(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + int _rowCount = 0; + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + _colret.put(rs.getString(1), ret); + if(++_rowCount == 2147483647) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map> getPersonStaticLimitMapList(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name, birth_date FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + long _rowCount = 0; + final java.util.Map> _colret = new java.util.HashMap>(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 3)); + final java.lang.String _colkey = rs.getString(1); + java.util.List _collist = _colret.get(_colkey); + if(_collist == null) { + _collist = new java.util.ArrayList(); + _colret.put(_colkey, _collist); + } + _collist.add(ret); + if(++_rowCount == 9223372036854775807L) + break; + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeopleList(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no, birth_date, last_name, first_name from person WHERE person_no IN (?,?,?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 2), +rs.getString(4), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.util.ResultSetIterable getPeopleResultSetIterable(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no, birth_date, last_name, first_name from person WHERE person_no IN (?,?,?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + return com.moparisthebest.jdbc.util.ResultSetIterable.getResultSetIterable(rs, + rs.next() ? new com.moparisthebest.jdbc.util.ResultSetToObject() { + public com.moparisthebest.jdbc.dto.FieldPerson toObject(final ResultSet _rs, final java.util.Calendar _cal) throws SQLException { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 2), +_rs.getString(4), +_rs.getString(3)); + return ret; + } + } + : null, null).setPreparedStatementToClose(ps); + } catch(Throwable e) { + tryClose(rs); + tryClose(ps); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public com.moparisthebest.jdbc.util.ResultSetIterable getPeopleResultSetIterableCachedPreparedStatement(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(1, "SELECT person_no, birth_date, last_name, first_name from person WHERE person_no IN (?,?,?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + return com.moparisthebest.jdbc.util.ResultSetIterable.getResultSetIterable(rs, + rs.next() ? new com.moparisthebest.jdbc.util.ResultSetToObject() { + public com.moparisthebest.jdbc.dto.FieldPerson toObject(final ResultSet _rs, final java.util.Calendar _cal) throws SQLException { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 2), +_rs.getString(4), +_rs.getString(3)); + return ret; + } + } + : null, null); + } catch(Throwable e) { + tryClose(rs); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPersonConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson( +com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FirstName getFirstNameEnum(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPersonNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val as first_name, str_val as last_name FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FirstName getEnumNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.dto.CaseSensitivePerson getCaseSensitivePerson(final long personNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name AS M_PERSON_FIRST_NAME FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.CaseSensitivePerson ret = new com.moparisthebest.jdbc.dto.CaseSensitivePerson(); +ret.setmPersonFirstName(rs.getString(1)); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson getSameClassPathEnumPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson ret = new com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson getSameClassPathEnumPersonConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson ret = new com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson( +com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName getSameClassPathFirstNameEnum(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson getSameClassPathEnumPersonNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val as first_name, str_val as last_name FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson ret = new com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName getSameClassPathEnumNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT str_val FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.codegen.SameClassPathEnumPerson.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeopleInListArray(final java.lang.Long[] personNos) { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("NUMERIC", personNos); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (person_no = ANY(?))"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getPeopleInListCollection(final java.util.Collection personNos) { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("NUMERIC", personNos.toArray(new java.lang.Long[personNos.size()])); + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE (person_no = ANY(?))"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getString(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); + _colret.add(ret); + } + return _colret; + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + tryClose(ps); + } + } + + @Override + public byte[] getBlob(final long valNo) { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT some_blob FROM val WHERE val_no = ?"); + ps.setObject(1, valNo); + rs = ps.executeQuery(); + if(rs.next()) { +final byte[] ret = rs.getBytes(1); + return ret; + } else { + return null; + } + } catch(SQLException e) { + throw new RuntimeException(e); + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.lang.String[] getSinglePersonNameArray(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.String[] ret = new java.lang.String[2]; +ret[0] = rs.getString(1); +ret[1] = rs.getString(2); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.Map getSinglePersonNameMap(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.util.Map ret = new java.util.HashMap(); +ret.put("first_name", rs.getString(1)); +ret.put("last_name", rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + tryClose(ps); + } + } + + private static final java.lang.reflect.Field[] _fields = new java.lang.reflect.Field[] { + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "firstName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "lastName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "birthDate"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "personNo"), + }; + + private final PreparedStatement[] psCache = new PreparedStatement[2]; + + private PreparedStatement prepareStatement(final int index, final String sql) throws SQLException { + final PreparedStatement ps = psCache[index]; + return ps == null ? (psCache[index] = conn.prepareStatement(sql)) : ps; + } + + @Override + public void close() { + for(final PreparedStatement ps : psCache) + tryClose(ps); + if(closeConn) + tryClose(conn); + } + + public PersonDAOUnNestBean(final Factory connectionFactory) throws SQLException { + this(connectionFactory.create(), true); + } + + public PersonDAOUnNestBean(final String jndiName) throws SQLException { + this(com.moparisthebest.jdbc.codegen.JdbcMapperFactory.connectionFactory(jndiName)); + } + + @Override + public SqlBuilder sqlBuilder() { + return SqlBuilder.of(conn, com.moparisthebest.jdbc.ArrayInList.instance()); + } +} diff --git a/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/QmDaoAnyBean.java b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/QmDaoAnyBean.java new file mode 100644 index 0000000..7f0f3eb --- /dev/null +++ b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/QmDaoAnyBean.java @@ -0,0 +1,1321 @@ +package com.moparisthebest.jdbc.codegen; + +import com.moparisthebest.jdbc.util.SqlBuilder; +import com.moparisthebest.jdbc.Factory; + +import java.sql.*; + +import static com.moparisthebest.jdbc.util.ResultSetUtil.*; +import static com.moparisthebest.jdbc.TryClose.tryClose; + +public class QmDaoAnyBean implements QmDao { + + private final Connection conn; + private final boolean closeConn; + + + private QmDaoAnyBean(final Connection conn, final boolean closeConn) { + this.conn = conn; + this.closeConn = closeConn; + if (this.conn == null) + throw new NullPointerException("Connection needs to be non-null for JdbcMapper..."); + } + + public QmDaoAnyBean(Connection conn) { + this(conn, false); + } + + public Connection getConnection() { + return this.conn; + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getFieldRegularPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(0, "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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.BuilderPerson getBuilderPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(1, "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.BuilderPerson ret = new com.moparisthebest.jdbc.dto.BuilderPerson(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegularAndUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(2, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(6)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegularAndUnderscoreReverse(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(3, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegularAndUnderscoreNoConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(4, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name, p.first_name AS dummy FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[5], ret, rs.getString(6)); +ret.setDummy(rs.getString(7)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegularAndUnderscoreReverseNoConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(5, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName, p.first_name AS dummy FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[5], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(6)); +ret.setDummy(rs.getString(7)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegular(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(6, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(7, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[5], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetPerson getSetRegularPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(8, "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.SetPerson ret = new com.moparisthebest.jdbc.dto.SetPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetPerson getSetRegularPersonNoConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(9, "SELECT person_no, first_name, last_name, birth_date, first_name AS dummy FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetPerson ret = new com.moparisthebest.jdbc.dto.SetPerson(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDummy(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetBoss getSetRegularAndUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(10, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetBoss ret = new com.moparisthebest.jdbc.dto.SetBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(6)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetBoss getSetRegularAndUnderscoreReverse(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(11, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetBoss ret = new com.moparisthebest.jdbc.dto.SetBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetBoss getSetRegular(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(12, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetBoss ret = new com.moparisthebest.jdbc.dto.SetBoss(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDepartment(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetBoss getSetUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(13, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetBoss ret = new com.moparisthebest.jdbc.dto.SetBoss(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirst_name(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDepartment(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldPerson getReverseFieldRegularPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(14, "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.ReverseFieldPerson ret = new com.moparisthebest.jdbc.dto.ReverseFieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldBoss getReverseFieldRegularAndUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(15, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseFieldBoss ret = new com.moparisthebest.jdbc.dto.ReverseFieldBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(6)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldBoss getReverseFieldRegularAndUnderscoreReverse(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(16, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseFieldBoss ret = new com.moparisthebest.jdbc.dto.ReverseFieldBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldBoss getReverseFieldRegular(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(17, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseFieldBoss ret = new com.moparisthebest.jdbc.dto.ReverseFieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[6], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[7], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[8], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[9], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[10], ret, rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldBoss getReverseFieldUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(18, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseFieldBoss ret = new com.moparisthebest.jdbc.dto.ReverseFieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[6], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[11], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[8], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[9], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[10], ret, rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetPerson getReverseSetRegularPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(19, "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.ReverseSetPerson ret = new com.moparisthebest.jdbc.dto.ReverseSetPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetBoss getReverseSetRegularAndUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(20, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseSetBoss ret = new com.moparisthebest.jdbc.dto.ReverseSetBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(6)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetBoss getReverseSetRegularAndUnderscoreReverse(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(21, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseSetBoss ret = new com.moparisthebest.jdbc.dto.ReverseSetBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetBoss getReverseSetRegular(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(22, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseSetBoss ret = new com.moparisthebest.jdbc.dto.ReverseSetBoss(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDepartment(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetBoss getReverseSetUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(23, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseSetBoss ret = new com.moparisthebest.jdbc.dto.ReverseSetBoss(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirst_name(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDepartment(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.lang.Long getPersonNo(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(24, "SELECT person_no FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public long getPersonNoPrimitive(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(25, "SELECT person_no FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final long ret = rs.getLong(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + } + } + + @Override + public int getPersonNoPrimitiveInt(final int personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(26, "SELECT person_no FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final int ret = rs.getInt(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.lang.Long[] getPersonNoObjectArray(final java.lang.Long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(27, "SELECT person_no FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret.toArray(new java.lang.Long[_colret.size()]); + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List> getAllNames() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(28, "SELECT first_name, last_name FROM person WHERE person_no < 4"); + rs = ps.executeQuery(); + final java.util.List> _colret = new java.util.ArrayList>(); + while(rs.next()) { +final java.util.Map ret = new java.util.HashMap(); +ret.put("first_name", rs.getString(1)); +ret.put("last_name", rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.Map[] getAllNamesArray() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(29, "SELECT first_name, last_name FROM person WHERE person_no < 4"); + rs = ps.executeQuery(); + final java.util.List> _colret = new java.util.ArrayList>(); + while(rs.next()) { +final java.util.Map ret = new java.util.HashMap(); +ret.put("first_name", rs.getString(1)); +ret.put("last_name", rs.getString(2)); + _colret.add(ret); + } + @SuppressWarnings("unchecked") + final java.util.Map[] _warnret = _colret.toArray(new java.util.Map[_colret.size()]); + return _warnret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.Map getAllNameMap() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(30, "SELECT first_name, last_name FROM person WHERE person_no < 4"); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final java.lang.String ret = rs.getString(2); + _colret.put(rs.getString(1), ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.Map getMapLongPerson() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(31, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no in (2,3,4)"); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); + _colret.put(com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1), ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.Map getMapLongLong() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(32, "SELECT person_no AS first_no, person_no AS last_no FROM person WHERE person_no < 4"); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 2); + _colret.put(com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1), ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.lang.Long[] getLongObjectArray() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(33, "SELECT 1, 2, 3 FROM person WHERE person_no = 1"); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.Long[] ret = new java.lang.Long[3]; +ret[0] = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); +ret[1] = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 2); +ret[2] = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 3); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public long[] getLongPrimitiveArray() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(34, "SELECT 1, 2, 3 FROM person WHERE person_no = 1"); + rs = ps.executeQuery(); + if(rs.next()) { +final long[] ret = new long[3]; +ret[0] = rs.getLong(1); +ret[1] = rs.getLong(2); +ret[2] = rs.getLong(3); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List> getBobTomMap() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(35, "SELECT 'bob' as bob, 'tom' as tom FROM person WHERE person_no = 1"); + rs = ps.executeQuery(); + final java.util.List> _colret = new java.util.ArrayList>(); + while(rs.next()) { +final java.util.Map ret = new java.util.HashMap(); +ret.put("bob", rs.getString(1)); +ret.put("tom", rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List> getBobTomMapCaseInsensitive() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(36, "SELECT 'bob' as bob, 'tom' as tom FROM person WHERE person_no = 1"); + rs = ps.executeQuery(); + final java.util.List> _colret = new java.util.ArrayList>(); + while(rs.next()) { +final com.moparisthebest.jdbc.util.CaseInsensitiveHashMap ret = new com.moparisthebest.jdbc.util.CaseInsensitiveHashMap(); +ret.put("bob", rs.getString(1)); +ret.put("tom", rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List getThreePeople(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(37, "SELECT person_no, first_name, last_name, birth_date from person WHERE person_no IN (?, ?, ?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.util.ResultSetIterable getThreePeopleResultSetIterable(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(38, "SELECT person_no, first_name, last_name, birth_date from person WHERE person_no IN (?, ?, ?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + return com.moparisthebest.jdbc.util.ResultSetIterable.getResultSetIterable(rs, + rs.next() ? new com.moparisthebest.jdbc.util.ResultSetToObject() { + public com.moparisthebest.jdbc.dto.FieldPerson toObject(final ResultSet _rs, final java.util.Calendar _cal) throws SQLException { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 4), +_rs.getString(2), +_rs.getString(3)); + return ret; + } + } + : null, null); + } catch(Throwable e) { + tryClose(rs); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(39, "SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPersonConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(40, "SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson( +com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FirstName getFirstName(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(41, "SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPersonNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(42, "SELECT str_val as first_name, str_val as last_name FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FirstName getFirstNameNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(43, "SELECT str_val FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.CaseSensitivePerson getCaseSensitivePerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(44, "SELECT first_name AS M_PERSON_FIRST_NAME FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.CaseSensitivePerson ret = new com.moparisthebest.jdbc.dto.CaseSensitivePerson(); +ret.setmPersonFirstName(rs.getString(1)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List getFieldPeople(final java.util.List personNos) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("NUMERIC", personNos.toArray(new java.lang.Long[personNos.size()])); + ps = this.prepareStatement(45, "SELECT person_no, first_name, last_name, birth_date from person WHERE (person_no = ANY(?)) ORDER BY person_no"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + } + } + + @Override + public java.util.List getFieldPeopleByName(final java.util.List personNos, final java.util.List names) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[2]; + try { + _bindArrays[0] = conn.createArrayOf("NUMERIC", personNos.toArray(new java.lang.Long[personNos.size()])); + _bindArrays[1] = conn.createArrayOf("TEXT", names.toArray(new java.lang.String[names.size()])); + ps = this.prepareStatement(46, "SELECT person_no, first_name, last_name, birth_date from person WHERE (person_no = ANY(?)) AND ((first_name = ANY(?)) OR (last_name = ANY(?))) ORDER BY person_no"); + ps.setArray(1, _bindArrays[0]); + ps.setArray(2, _bindArrays[1]); + ps.setArray(3, _bindArrays[1]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + } + } + + @Override + public java.util.List getFieldPeopleNotIn(final java.util.List personNos) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("NUMERIC", personNos.toArray(new java.lang.Long[personNos.size()])); + ps = this.prepareStatement(47, "SELECT person_no, first_name, last_name, birth_date from person WHERE (NOT(person_no = ANY(?))) ORDER BY person_no"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + } + } + + @Override + public long insertGetGeneratedKeyOracle(final long value) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO a_thaoeu_table (a_thaoeu_table_no, a_thaoeu_table_val) VALUES (a_thaoeu_table_seq.nextval, ?)", java.sql.Statement.RETURN_GENERATED_KEYS); + ps.setObject(1, value); + ps.executeUpdate(); + ResultSet rs = null; + try { + rs = ps.getGeneratedKeys(); + return rs.next() ? rs.getLong(1) : 0; + } finally { + tryClose(rs); + } + } finally { + tryClose(ps); + } + } + + @Override + public long insertGetGeneratedKey(final long value) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO a_thaoeu_table (a_thaoeu_table_val) VALUES (?)", java.sql.Statement.RETURN_GENERATED_KEYS); + ps.setObject(1, value); + ps.executeUpdate(); + ResultSet rs = null; + try { + rs = ps.getGeneratedKeys(); + return rs.next() ? rs.getLong(1) : 0; + } finally { + tryClose(rs); + } + } finally { + tryClose(ps); + } + } + + @Override + public java.util.List selectRandomSql(final java.lang.String sql) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE " + sql + ""); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List selectRandomSqlBuilder(final com.moparisthebest.jdbc.util.SqlBuilder sql) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE " + sql + ""); + int psParamCount = 0; + psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, sql); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List selectRandomSql(final long personNo1, final java.lang.String sql, final java.lang.String firstName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE person_no = ? " + sql + " OR first_name = ?"); + ps.setObject(1, personNo1); + ps.setObject(2, firstName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List selectRandomSqlBuilder(final long personNo1, final com.moparisthebest.jdbc.util.Bindable sql, final java.lang.String firstName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE person_no = ? " + sql + " OR first_name = ?"); + int psParamCount = 0; + ps.setObject(++psParamCount, personNo1); + psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, sql.getBindObject()); + ps.setObject(++psParamCount, firstName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public void insertRandomSqlCollection(final java.util.Collection sql) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT " + sql + ""); + int psParamCount = 0; + psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, sql); + ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + @Override + public void insertRandomSqlIterable(final java.lang.Iterable sql) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT " + sql + ""); + int psParamCount = 0; + psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, sql); + ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + private static final java.lang.reflect.Field[] _fields = new java.lang.reflect.Field[] { + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "personNo"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "firstName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "lastName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "birthDate"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldBoss.class, "department"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldBoss.class, "first_name"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldPerson.class, "personNo"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldBoss.class, "firstName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldPerson.class, "lastName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldPerson.class, "birthDate"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldBoss.class, "department"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldPerson.class, "first_name"), + }; + + private final PreparedStatement[] psCache = new PreparedStatement[48]; + + private PreparedStatement prepareStatement(final int index, final String sql) throws SQLException { + final PreparedStatement ps = psCache[index]; + return ps == null ? (psCache[index] = conn.prepareStatement(sql)) : ps; + } + + @Override + public void close() { + for(final PreparedStatement ps : psCache) + tryClose(ps); + } + + public QmDaoAnyBean(final Factory connectionFactory) throws SQLException { + this(connectionFactory.create(), true); + } + + public QmDaoAnyBean(final String jndiName) throws SQLException { + this(com.moparisthebest.jdbc.codegen.JdbcMapperFactory.connectionFactory(jndiName)); + } + + @Override + public SqlBuilder sqlBuilder() { + return SqlBuilder.of(conn, com.moparisthebest.jdbc.ArrayInList.instance()); + } +} diff --git a/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/QmDaoBean.java b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/QmDaoBean.java new file mode 100644 index 0000000..4c48ed9 --- /dev/null +++ b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/QmDaoBean.java @@ -0,0 +1,1319 @@ +package com.moparisthebest.jdbc.codegen; + +import com.moparisthebest.jdbc.util.SqlBuilder; +import com.moparisthebest.jdbc.Factory; + +import java.sql.*; + +import static com.moparisthebest.jdbc.util.ResultSetUtil.*; +import static com.moparisthebest.jdbc.TryClose.tryClose; + +public class QmDaoBean implements QmDao { + + private final Connection conn; + private final boolean closeConn; + + + private QmDaoBean(final Connection conn, final boolean closeConn) { + this.conn = conn; + this.closeConn = closeConn; + if (this.conn == null) + throw new NullPointerException("Connection needs to be non-null for JdbcMapper..."); + } + + public QmDaoBean(Connection conn) { + this(conn, false); + } + + public Connection getConnection() { + return this.conn; + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getFieldRegularPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(0, "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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.BuilderPerson getBuilderPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(1, "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.BuilderPerson ret = new com.moparisthebest.jdbc.dto.BuilderPerson(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegularAndUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(2, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(6)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegularAndUnderscoreReverse(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(3, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegularAndUnderscoreNoConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(4, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name, p.first_name AS dummy FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[5], ret, rs.getString(6)); +ret.setDummy(rs.getString(7)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegularAndUnderscoreReverseNoConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(5, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName, p.first_name AS dummy FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[5], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(6)); +ret.setDummy(rs.getString(7)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegular(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(6, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(7, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[5], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetPerson getSetRegularPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(8, "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.SetPerson ret = new com.moparisthebest.jdbc.dto.SetPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetPerson getSetRegularPersonNoConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(9, "SELECT person_no, first_name, last_name, birth_date, first_name AS dummy FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetPerson ret = new com.moparisthebest.jdbc.dto.SetPerson(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDummy(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetBoss getSetRegularAndUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(10, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetBoss ret = new com.moparisthebest.jdbc.dto.SetBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(6)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetBoss getSetRegularAndUnderscoreReverse(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(11, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetBoss ret = new com.moparisthebest.jdbc.dto.SetBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetBoss getSetRegular(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(12, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetBoss ret = new com.moparisthebest.jdbc.dto.SetBoss(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDepartment(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetBoss getSetUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(13, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetBoss ret = new com.moparisthebest.jdbc.dto.SetBoss(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirst_name(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDepartment(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldPerson getReverseFieldRegularPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(14, "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.ReverseFieldPerson ret = new com.moparisthebest.jdbc.dto.ReverseFieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldBoss getReverseFieldRegularAndUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(15, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseFieldBoss ret = new com.moparisthebest.jdbc.dto.ReverseFieldBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(6)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldBoss getReverseFieldRegularAndUnderscoreReverse(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(16, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseFieldBoss ret = new com.moparisthebest.jdbc.dto.ReverseFieldBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldBoss getReverseFieldRegular(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(17, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseFieldBoss ret = new com.moparisthebest.jdbc.dto.ReverseFieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[6], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[7], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[8], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[9], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[10], ret, rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldBoss getReverseFieldUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(18, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseFieldBoss ret = new com.moparisthebest.jdbc.dto.ReverseFieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[6], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[11], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[8], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[9], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[10], ret, rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetPerson getReverseSetRegularPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(19, "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.ReverseSetPerson ret = new com.moparisthebest.jdbc.dto.ReverseSetPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetBoss getReverseSetRegularAndUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(20, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseSetBoss ret = new com.moparisthebest.jdbc.dto.ReverseSetBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(6)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetBoss getReverseSetRegularAndUnderscoreReverse(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(21, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseSetBoss ret = new com.moparisthebest.jdbc.dto.ReverseSetBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetBoss getReverseSetRegular(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(22, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseSetBoss ret = new com.moparisthebest.jdbc.dto.ReverseSetBoss(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDepartment(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetBoss getReverseSetUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(23, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseSetBoss ret = new com.moparisthebest.jdbc.dto.ReverseSetBoss(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirst_name(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDepartment(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.lang.Long getPersonNo(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(24, "SELECT person_no FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public long getPersonNoPrimitive(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(25, "SELECT person_no FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final long ret = rs.getLong(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + } + } + + @Override + public int getPersonNoPrimitiveInt(final int personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(26, "SELECT person_no FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final int ret = rs.getInt(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.lang.Long[] getPersonNoObjectArray(final java.lang.Long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(27, "SELECT person_no FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret.toArray(new java.lang.Long[_colret.size()]); + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List> getAllNames() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(28, "SELECT first_name, last_name FROM person WHERE person_no < 4"); + rs = ps.executeQuery(); + final java.util.List> _colret = new java.util.ArrayList>(); + while(rs.next()) { +final java.util.Map ret = new java.util.HashMap(); +ret.put("first_name", rs.getString(1)); +ret.put("last_name", rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.Map[] getAllNamesArray() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(29, "SELECT first_name, last_name FROM person WHERE person_no < 4"); + rs = ps.executeQuery(); + final java.util.List> _colret = new java.util.ArrayList>(); + while(rs.next()) { +final java.util.Map ret = new java.util.HashMap(); +ret.put("first_name", rs.getString(1)); +ret.put("last_name", rs.getString(2)); + _colret.add(ret); + } + @SuppressWarnings("unchecked") + final java.util.Map[] _warnret = _colret.toArray(new java.util.Map[_colret.size()]); + return _warnret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.Map getAllNameMap() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(30, "SELECT first_name, last_name FROM person WHERE person_no < 4"); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final java.lang.String ret = rs.getString(2); + _colret.put(rs.getString(1), ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.Map getMapLongPerson() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(31, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no in (2,3,4)"); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); + _colret.put(com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1), ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.Map getMapLongLong() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(32, "SELECT person_no AS first_no, person_no AS last_no FROM person WHERE person_no < 4"); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 2); + _colret.put(com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1), ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.lang.Long[] getLongObjectArray() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(33, "SELECT 1, 2, 3 FROM person WHERE person_no = 1"); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.Long[] ret = new java.lang.Long[3]; +ret[0] = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); +ret[1] = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 2); +ret[2] = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 3); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public long[] getLongPrimitiveArray() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(34, "SELECT 1, 2, 3 FROM person WHERE person_no = 1"); + rs = ps.executeQuery(); + if(rs.next()) { +final long[] ret = new long[3]; +ret[0] = rs.getLong(1); +ret[1] = rs.getLong(2); +ret[2] = rs.getLong(3); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List> getBobTomMap() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(35, "SELECT 'bob' as bob, 'tom' as tom FROM person WHERE person_no = 1"); + rs = ps.executeQuery(); + final java.util.List> _colret = new java.util.ArrayList>(); + while(rs.next()) { +final java.util.Map ret = new java.util.HashMap(); +ret.put("bob", rs.getString(1)); +ret.put("tom", rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List> getBobTomMapCaseInsensitive() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(36, "SELECT 'bob' as bob, 'tom' as tom FROM person WHERE person_no = 1"); + rs = ps.executeQuery(); + final java.util.List> _colret = new java.util.ArrayList>(); + while(rs.next()) { +final com.moparisthebest.jdbc.util.CaseInsensitiveHashMap ret = new com.moparisthebest.jdbc.util.CaseInsensitiveHashMap(); +ret.put("bob", rs.getString(1)); +ret.put("tom", rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List getThreePeople(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(37, "SELECT person_no, first_name, last_name, birth_date from person WHERE person_no IN (?, ?, ?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.util.ResultSetIterable getThreePeopleResultSetIterable(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(38, "SELECT person_no, first_name, last_name, birth_date from person WHERE person_no IN (?, ?, ?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + return com.moparisthebest.jdbc.util.ResultSetIterable.getResultSetIterable(rs, + rs.next() ? new com.moparisthebest.jdbc.util.ResultSetToObject() { + public com.moparisthebest.jdbc.dto.FieldPerson toObject(final ResultSet _rs, final java.util.Calendar _cal) throws SQLException { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 4), +_rs.getString(2), +_rs.getString(3)); + return ret; + } + } + : null, null); + } catch(Throwable e) { + tryClose(rs); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(39, "SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPersonConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(40, "SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson( +com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FirstName getFirstName(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(41, "SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPersonNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(42, "SELECT str_val as first_name, str_val as last_name FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FirstName getFirstNameNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(43, "SELECT str_val FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.CaseSensitivePerson getCaseSensitivePerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(44, "SELECT first_name AS M_PERSON_FIRST_NAME FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.CaseSensitivePerson ret = new com.moparisthebest.jdbc.dto.CaseSensitivePerson(); +ret.setmPersonFirstName(rs.getString(1)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List getFieldPeople(final java.util.List personNos) 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 " + com.moparisthebest.jdbc.util.InListUtil.toInList("person_no", personNos) + " ORDER BY person_no"); + int psParamCount = 0; + for(final java.lang.Long _bindInListParam : personNos) + ps.setObject(++psParamCount, _bindInListParam); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getFieldPeopleByName(final java.util.List personNos, final java.util.List names) 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 " + com.moparisthebest.jdbc.util.InListUtil.toInList("person_no", personNos) + " AND (" + com.moparisthebest.jdbc.util.InListUtil.toInList("first_name", names) + " OR " + com.moparisthebest.jdbc.util.InListUtil.toInList("last_name", names) + ") ORDER BY person_no"); + int psParamCount = 0; + for(final java.lang.Long _bindInListParam : personNos) + ps.setObject(++psParamCount, _bindInListParam); + for(final java.lang.String _bindInListParam : names) + ps.setObject(++psParamCount, _bindInListParam); + for(final java.lang.String _bindInListParam : names) + ps.setObject(++psParamCount, _bindInListParam); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getFieldPeopleNotIn(final java.util.List personNos) 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 " + com.moparisthebest.jdbc.util.InListUtil.toNotInList("person_no", personNos) + " ORDER BY person_no"); + int psParamCount = 0; + for(final java.lang.Long _bindInListParam : personNos) + ps.setObject(++psParamCount, _bindInListParam); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public long insertGetGeneratedKeyOracle(final long value) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO a_thaoeu_table (a_thaoeu_table_no, a_thaoeu_table_val) VALUES (a_thaoeu_table_seq.nextval, ?)", java.sql.Statement.RETURN_GENERATED_KEYS); + ps.setObject(1, value); + ps.executeUpdate(); + ResultSet rs = null; + try { + rs = ps.getGeneratedKeys(); + return rs.next() ? rs.getLong(1) : 0; + } finally { + tryClose(rs); + } + } finally { + tryClose(ps); + } + } + + @Override + public long insertGetGeneratedKey(final long value) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO a_thaoeu_table (a_thaoeu_table_val) VALUES (?)", java.sql.Statement.RETURN_GENERATED_KEYS); + ps.setObject(1, value); + ps.executeUpdate(); + ResultSet rs = null; + try { + rs = ps.getGeneratedKeys(); + return rs.next() ? rs.getLong(1) : 0; + } finally { + tryClose(rs); + } + } finally { + tryClose(ps); + } + } + + @Override + public java.util.List selectRandomSql(final java.lang.String sql) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE " + sql + ""); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List selectRandomSqlBuilder(final com.moparisthebest.jdbc.util.SqlBuilder sql) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE " + sql + ""); + int psParamCount = 0; + psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, sql); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List selectRandomSql(final long personNo1, final java.lang.String sql, final java.lang.String firstName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE person_no = ? " + sql + " OR first_name = ?"); + ps.setObject(1, personNo1); + ps.setObject(2, firstName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List selectRandomSqlBuilder(final long personNo1, final com.moparisthebest.jdbc.util.Bindable sql, final java.lang.String firstName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE person_no = ? " + sql + " OR first_name = ?"); + int psParamCount = 0; + ps.setObject(++psParamCount, personNo1); + psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, sql.getBindObject()); + ps.setObject(++psParamCount, firstName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public void insertRandomSqlCollection(final java.util.Collection sql) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT " + sql + ""); + int psParamCount = 0; + psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, sql); + ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + @Override + public void insertRandomSqlIterable(final java.lang.Iterable sql) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT " + sql + ""); + int psParamCount = 0; + psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, sql); + ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + private static final java.lang.reflect.Field[] _fields = new java.lang.reflect.Field[] { + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "personNo"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "firstName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "lastName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "birthDate"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldBoss.class, "department"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldBoss.class, "first_name"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldPerson.class, "personNo"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldBoss.class, "firstName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldPerson.class, "lastName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldPerson.class, "birthDate"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldBoss.class, "department"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldPerson.class, "first_name"), + }; + + private final PreparedStatement[] psCache = new PreparedStatement[45]; + + private PreparedStatement prepareStatement(final int index, final String sql) throws SQLException { + final PreparedStatement ps = psCache[index]; + return ps == null ? (psCache[index] = conn.prepareStatement(sql)) : ps; + } + + @Override + public void close() { + for(final PreparedStatement ps : psCache) + tryClose(ps); + } + + public QmDaoBean(final Factory connectionFactory) throws SQLException { + this(connectionFactory.create(), true); + } + + public QmDaoBean(final String jndiName) throws SQLException { + this(com.moparisthebest.jdbc.codegen.JdbcMapperFactory.connectionFactory(jndiName)); + } + + @Override + public SqlBuilder sqlBuilder() { + return SqlBuilder.of(conn, com.moparisthebest.jdbc.BindInList.instance()); + } +} diff --git a/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/QmDaoBindBean.java b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/QmDaoBindBean.java new file mode 100644 index 0000000..017fda4 --- /dev/null +++ b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/QmDaoBindBean.java @@ -0,0 +1,1319 @@ +package com.moparisthebest.jdbc.codegen; + +import com.moparisthebest.jdbc.util.SqlBuilder; +import com.moparisthebest.jdbc.Factory; + +import java.sql.*; + +import static com.moparisthebest.jdbc.util.ResultSetUtil.*; +import static com.moparisthebest.jdbc.TryClose.tryClose; + +public class QmDaoBindBean implements QmDao { + + private final Connection conn; + private final boolean closeConn; + + + private QmDaoBindBean(final Connection conn, final boolean closeConn) { + this.conn = conn; + this.closeConn = closeConn; + if (this.conn == null) + throw new NullPointerException("Connection needs to be non-null for JdbcMapper..."); + } + + public QmDaoBindBean(Connection conn) { + this(conn, false); + } + + public Connection getConnection() { + return this.conn; + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getFieldRegularPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(0, "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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.BuilderPerson getBuilderPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(1, "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.BuilderPerson ret = new com.moparisthebest.jdbc.dto.BuilderPerson(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegularAndUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(2, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(6)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegularAndUnderscoreReverse(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(3, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegularAndUnderscoreNoConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(4, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name, p.first_name AS dummy FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[5], ret, rs.getString(6)); +ret.setDummy(rs.getString(7)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegularAndUnderscoreReverseNoConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(5, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName, p.first_name AS dummy FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[5], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(6)); +ret.setDummy(rs.getString(7)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegular(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(6, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(7, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[5], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetPerson getSetRegularPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(8, "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.SetPerson ret = new com.moparisthebest.jdbc.dto.SetPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetPerson getSetRegularPersonNoConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(9, "SELECT person_no, first_name, last_name, birth_date, first_name AS dummy FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetPerson ret = new com.moparisthebest.jdbc.dto.SetPerson(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDummy(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetBoss getSetRegularAndUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(10, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetBoss ret = new com.moparisthebest.jdbc.dto.SetBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(6)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetBoss getSetRegularAndUnderscoreReverse(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(11, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetBoss ret = new com.moparisthebest.jdbc.dto.SetBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetBoss getSetRegular(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(12, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetBoss ret = new com.moparisthebest.jdbc.dto.SetBoss(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDepartment(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetBoss getSetUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(13, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetBoss ret = new com.moparisthebest.jdbc.dto.SetBoss(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirst_name(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDepartment(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldPerson getReverseFieldRegularPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(14, "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.ReverseFieldPerson ret = new com.moparisthebest.jdbc.dto.ReverseFieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldBoss getReverseFieldRegularAndUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(15, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseFieldBoss ret = new com.moparisthebest.jdbc.dto.ReverseFieldBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(6)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldBoss getReverseFieldRegularAndUnderscoreReverse(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(16, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseFieldBoss ret = new com.moparisthebest.jdbc.dto.ReverseFieldBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldBoss getReverseFieldRegular(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(17, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseFieldBoss ret = new com.moparisthebest.jdbc.dto.ReverseFieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[6], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[7], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[8], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[9], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[10], ret, rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldBoss getReverseFieldUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(18, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseFieldBoss ret = new com.moparisthebest.jdbc.dto.ReverseFieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[6], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[11], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[8], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[9], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[10], ret, rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetPerson getReverseSetRegularPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(19, "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.ReverseSetPerson ret = new com.moparisthebest.jdbc.dto.ReverseSetPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetBoss getReverseSetRegularAndUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(20, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseSetBoss ret = new com.moparisthebest.jdbc.dto.ReverseSetBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(6)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetBoss getReverseSetRegularAndUnderscoreReverse(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(21, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseSetBoss ret = new com.moparisthebest.jdbc.dto.ReverseSetBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetBoss getReverseSetRegular(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(22, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseSetBoss ret = new com.moparisthebest.jdbc.dto.ReverseSetBoss(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDepartment(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetBoss getReverseSetUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(23, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseSetBoss ret = new com.moparisthebest.jdbc.dto.ReverseSetBoss(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirst_name(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDepartment(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.lang.Long getPersonNo(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(24, "SELECT person_no FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public long getPersonNoPrimitive(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(25, "SELECT person_no FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final long ret = rs.getLong(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + } + } + + @Override + public int getPersonNoPrimitiveInt(final int personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(26, "SELECT person_no FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final int ret = rs.getInt(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.lang.Long[] getPersonNoObjectArray(final java.lang.Long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(27, "SELECT person_no FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret.toArray(new java.lang.Long[_colret.size()]); + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List> getAllNames() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(28, "SELECT first_name, last_name FROM person WHERE person_no < 4"); + rs = ps.executeQuery(); + final java.util.List> _colret = new java.util.ArrayList>(); + while(rs.next()) { +final java.util.Map ret = new java.util.HashMap(); +ret.put("first_name", rs.getString(1)); +ret.put("last_name", rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.Map[] getAllNamesArray() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(29, "SELECT first_name, last_name FROM person WHERE person_no < 4"); + rs = ps.executeQuery(); + final java.util.List> _colret = new java.util.ArrayList>(); + while(rs.next()) { +final java.util.Map ret = new java.util.HashMap(); +ret.put("first_name", rs.getString(1)); +ret.put("last_name", rs.getString(2)); + _colret.add(ret); + } + @SuppressWarnings("unchecked") + final java.util.Map[] _warnret = _colret.toArray(new java.util.Map[_colret.size()]); + return _warnret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.Map getAllNameMap() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(30, "SELECT first_name, last_name FROM person WHERE person_no < 4"); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final java.lang.String ret = rs.getString(2); + _colret.put(rs.getString(1), ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.Map getMapLongPerson() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(31, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no in (2,3,4)"); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); + _colret.put(com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1), ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.Map getMapLongLong() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(32, "SELECT person_no AS first_no, person_no AS last_no FROM person WHERE person_no < 4"); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 2); + _colret.put(com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1), ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.lang.Long[] getLongObjectArray() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(33, "SELECT 1, 2, 3 FROM person WHERE person_no = 1"); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.Long[] ret = new java.lang.Long[3]; +ret[0] = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); +ret[1] = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 2); +ret[2] = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 3); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public long[] getLongPrimitiveArray() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(34, "SELECT 1, 2, 3 FROM person WHERE person_no = 1"); + rs = ps.executeQuery(); + if(rs.next()) { +final long[] ret = new long[3]; +ret[0] = rs.getLong(1); +ret[1] = rs.getLong(2); +ret[2] = rs.getLong(3); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List> getBobTomMap() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(35, "SELECT 'bob' as bob, 'tom' as tom FROM person WHERE person_no = 1"); + rs = ps.executeQuery(); + final java.util.List> _colret = new java.util.ArrayList>(); + while(rs.next()) { +final java.util.Map ret = new java.util.HashMap(); +ret.put("bob", rs.getString(1)); +ret.put("tom", rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List> getBobTomMapCaseInsensitive() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(36, "SELECT 'bob' as bob, 'tom' as tom FROM person WHERE person_no = 1"); + rs = ps.executeQuery(); + final java.util.List> _colret = new java.util.ArrayList>(); + while(rs.next()) { +final com.moparisthebest.jdbc.util.CaseInsensitiveHashMap ret = new com.moparisthebest.jdbc.util.CaseInsensitiveHashMap(); +ret.put("bob", rs.getString(1)); +ret.put("tom", rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List getThreePeople(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(37, "SELECT person_no, first_name, last_name, birth_date from person WHERE person_no IN (?, ?, ?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.util.ResultSetIterable getThreePeopleResultSetIterable(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(38, "SELECT person_no, first_name, last_name, birth_date from person WHERE person_no IN (?, ?, ?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + return com.moparisthebest.jdbc.util.ResultSetIterable.getResultSetIterable(rs, + rs.next() ? new com.moparisthebest.jdbc.util.ResultSetToObject() { + public com.moparisthebest.jdbc.dto.FieldPerson toObject(final ResultSet _rs, final java.util.Calendar _cal) throws SQLException { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 4), +_rs.getString(2), +_rs.getString(3)); + return ret; + } + } + : null, null); + } catch(Throwable e) { + tryClose(rs); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(39, "SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPersonConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(40, "SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson( +com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FirstName getFirstName(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(41, "SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPersonNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(42, "SELECT str_val as first_name, str_val as last_name FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FirstName getFirstNameNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(43, "SELECT str_val FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.CaseSensitivePerson getCaseSensitivePerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(44, "SELECT first_name AS M_PERSON_FIRST_NAME FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.CaseSensitivePerson ret = new com.moparisthebest.jdbc.dto.CaseSensitivePerson(); +ret.setmPersonFirstName(rs.getString(1)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List getFieldPeople(final java.util.List personNos) 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 " + com.moparisthebest.jdbc.util.InListUtil.toInList("person_no", personNos) + " ORDER BY person_no"); + int psParamCount = 0; + for(final java.lang.Long _bindInListParam : personNos) + ps.setObject(++psParamCount, _bindInListParam); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getFieldPeopleByName(final java.util.List personNos, final java.util.List names) 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 " + com.moparisthebest.jdbc.util.InListUtil.toInList("person_no", personNos) + " AND (" + com.moparisthebest.jdbc.util.InListUtil.toInList("first_name", names) + " OR " + com.moparisthebest.jdbc.util.InListUtil.toInList("last_name", names) + ") ORDER BY person_no"); + int psParamCount = 0; + for(final java.lang.Long _bindInListParam : personNos) + ps.setObject(++psParamCount, _bindInListParam); + for(final java.lang.String _bindInListParam : names) + ps.setObject(++psParamCount, _bindInListParam); + for(final java.lang.String _bindInListParam : names) + ps.setObject(++psParamCount, _bindInListParam); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List getFieldPeopleNotIn(final java.util.List personNos) 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 " + com.moparisthebest.jdbc.util.InListUtil.toNotInList("person_no", personNos) + " ORDER BY person_no"); + int psParamCount = 0; + for(final java.lang.Long _bindInListParam : personNos) + ps.setObject(++psParamCount, _bindInListParam); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public long insertGetGeneratedKeyOracle(final long value) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO a_thaoeu_table (a_thaoeu_table_no, a_thaoeu_table_val) VALUES (a_thaoeu_table_seq.nextval, ?)", java.sql.Statement.RETURN_GENERATED_KEYS); + ps.setObject(1, value); + ps.executeUpdate(); + ResultSet rs = null; + try { + rs = ps.getGeneratedKeys(); + return rs.next() ? rs.getLong(1) : 0; + } finally { + tryClose(rs); + } + } finally { + tryClose(ps); + } + } + + @Override + public long insertGetGeneratedKey(final long value) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO a_thaoeu_table (a_thaoeu_table_val) VALUES (?)", java.sql.Statement.RETURN_GENERATED_KEYS); + ps.setObject(1, value); + ps.executeUpdate(); + ResultSet rs = null; + try { + rs = ps.getGeneratedKeys(); + return rs.next() ? rs.getLong(1) : 0; + } finally { + tryClose(rs); + } + } finally { + tryClose(ps); + } + } + + @Override + public java.util.List selectRandomSql(final java.lang.String sql) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE " + sql + ""); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List selectRandomSqlBuilder(final com.moparisthebest.jdbc.util.SqlBuilder sql) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE " + sql + ""); + int psParamCount = 0; + psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, sql); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List selectRandomSql(final long personNo1, final java.lang.String sql, final java.lang.String firstName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE person_no = ? " + sql + " OR first_name = ?"); + ps.setObject(1, personNo1); + ps.setObject(2, firstName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List selectRandomSqlBuilder(final long personNo1, final com.moparisthebest.jdbc.util.Bindable sql, final java.lang.String firstName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE person_no = ? " + sql + " OR first_name = ?"); + int psParamCount = 0; + ps.setObject(++psParamCount, personNo1); + psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, sql.getBindObject()); + ps.setObject(++psParamCount, firstName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public void insertRandomSqlCollection(final java.util.Collection sql) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT " + sql + ""); + int psParamCount = 0; + psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, sql); + ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + @Override + public void insertRandomSqlIterable(final java.lang.Iterable sql) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT " + sql + ""); + int psParamCount = 0; + psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, sql); + ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + private static final java.lang.reflect.Field[] _fields = new java.lang.reflect.Field[] { + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "personNo"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "firstName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "lastName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "birthDate"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldBoss.class, "department"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldBoss.class, "first_name"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldPerson.class, "personNo"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldBoss.class, "firstName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldPerson.class, "lastName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldPerson.class, "birthDate"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldBoss.class, "department"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldPerson.class, "first_name"), + }; + + private final PreparedStatement[] psCache = new PreparedStatement[45]; + + private PreparedStatement prepareStatement(final int index, final String sql) throws SQLException { + final PreparedStatement ps = psCache[index]; + return ps == null ? (psCache[index] = conn.prepareStatement(sql)) : ps; + } + + @Override + public void close() { + for(final PreparedStatement ps : psCache) + tryClose(ps); + } + + public QmDaoBindBean(final Factory connectionFactory) throws SQLException { + this(connectionFactory.create(), true); + } + + public QmDaoBindBean(final String jndiName) throws SQLException { + this(com.moparisthebest.jdbc.codegen.JdbcMapperFactory.connectionFactory(jndiName)); + } + + @Override + public SqlBuilder sqlBuilder() { + return SqlBuilder.of(conn, com.moparisthebest.jdbc.BindInList.instance()); + } +} diff --git a/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/QmDaoOracleBean.java b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/QmDaoOracleBean.java new file mode 100644 index 0000000..8b51637 --- /dev/null +++ b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/QmDaoOracleBean.java @@ -0,0 +1,1321 @@ +package com.moparisthebest.jdbc.codegen; + +import com.moparisthebest.jdbc.util.SqlBuilder; +import com.moparisthebest.jdbc.Factory; + +import java.sql.*; + +import static com.moparisthebest.jdbc.util.ResultSetUtil.*; +import static com.moparisthebest.jdbc.TryClose.tryClose; + +public class QmDaoOracleBean implements QmDao { + + private final Connection conn; + private final boolean closeConn; + + + private QmDaoOracleBean(final Connection conn, final boolean closeConn) { + this.conn = conn; + this.closeConn = closeConn; + if (this.conn == null) + throw new NullPointerException("Connection needs to be non-null for JdbcMapper..."); + } + + public QmDaoOracleBean(Connection conn) { + this(conn, false); + } + + public Connection getConnection() { + return this.conn; + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getFieldRegularPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(0, "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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.BuilderPerson getBuilderPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(1, "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.BuilderPerson ret = new com.moparisthebest.jdbc.dto.BuilderPerson(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegularAndUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(2, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(6)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegularAndUnderscoreReverse(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(3, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegularAndUnderscoreNoConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(4, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name, p.first_name AS dummy FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[5], ret, rs.getString(6)); +ret.setDummy(rs.getString(7)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegularAndUnderscoreReverseNoConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(5, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName, p.first_name AS dummy FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[5], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(6)); +ret.setDummy(rs.getString(7)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegular(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(6, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(7, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[5], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetPerson getSetRegularPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(8, "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.SetPerson ret = new com.moparisthebest.jdbc.dto.SetPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetPerson getSetRegularPersonNoConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(9, "SELECT person_no, first_name, last_name, birth_date, first_name AS dummy FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetPerson ret = new com.moparisthebest.jdbc.dto.SetPerson(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDummy(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetBoss getSetRegularAndUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(10, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetBoss ret = new com.moparisthebest.jdbc.dto.SetBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(6)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetBoss getSetRegularAndUnderscoreReverse(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(11, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetBoss ret = new com.moparisthebest.jdbc.dto.SetBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetBoss getSetRegular(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(12, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetBoss ret = new com.moparisthebest.jdbc.dto.SetBoss(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDepartment(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetBoss getSetUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(13, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetBoss ret = new com.moparisthebest.jdbc.dto.SetBoss(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirst_name(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDepartment(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldPerson getReverseFieldRegularPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(14, "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.ReverseFieldPerson ret = new com.moparisthebest.jdbc.dto.ReverseFieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldBoss getReverseFieldRegularAndUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(15, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseFieldBoss ret = new com.moparisthebest.jdbc.dto.ReverseFieldBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(6)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldBoss getReverseFieldRegularAndUnderscoreReverse(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(16, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseFieldBoss ret = new com.moparisthebest.jdbc.dto.ReverseFieldBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldBoss getReverseFieldRegular(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(17, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseFieldBoss ret = new com.moparisthebest.jdbc.dto.ReverseFieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[6], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[7], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[8], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[9], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[10], ret, rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldBoss getReverseFieldUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(18, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseFieldBoss ret = new com.moparisthebest.jdbc.dto.ReverseFieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[6], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[11], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[8], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[9], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[10], ret, rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetPerson getReverseSetRegularPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(19, "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.ReverseSetPerson ret = new com.moparisthebest.jdbc.dto.ReverseSetPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetBoss getReverseSetRegularAndUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(20, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseSetBoss ret = new com.moparisthebest.jdbc.dto.ReverseSetBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(6)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetBoss getReverseSetRegularAndUnderscoreReverse(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(21, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseSetBoss ret = new com.moparisthebest.jdbc.dto.ReverseSetBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetBoss getReverseSetRegular(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(22, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseSetBoss ret = new com.moparisthebest.jdbc.dto.ReverseSetBoss(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDepartment(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetBoss getReverseSetUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(23, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseSetBoss ret = new com.moparisthebest.jdbc.dto.ReverseSetBoss(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirst_name(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDepartment(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.lang.Long getPersonNo(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(24, "SELECT person_no FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public long getPersonNoPrimitive(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(25, "SELECT person_no FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final long ret = rs.getLong(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + } + } + + @Override + public int getPersonNoPrimitiveInt(final int personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(26, "SELECT person_no FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final int ret = rs.getInt(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.lang.Long[] getPersonNoObjectArray(final java.lang.Long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(27, "SELECT person_no FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret.toArray(new java.lang.Long[_colret.size()]); + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List> getAllNames() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(28, "SELECT first_name, last_name FROM person WHERE person_no < 4"); + rs = ps.executeQuery(); + final java.util.List> _colret = new java.util.ArrayList>(); + while(rs.next()) { +final java.util.Map ret = new java.util.HashMap(); +ret.put("first_name", rs.getString(1)); +ret.put("last_name", rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.Map[] getAllNamesArray() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(29, "SELECT first_name, last_name FROM person WHERE person_no < 4"); + rs = ps.executeQuery(); + final java.util.List> _colret = new java.util.ArrayList>(); + while(rs.next()) { +final java.util.Map ret = new java.util.HashMap(); +ret.put("first_name", rs.getString(1)); +ret.put("last_name", rs.getString(2)); + _colret.add(ret); + } + @SuppressWarnings("unchecked") + final java.util.Map[] _warnret = _colret.toArray(new java.util.Map[_colret.size()]); + return _warnret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.Map getAllNameMap() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(30, "SELECT first_name, last_name FROM person WHERE person_no < 4"); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final java.lang.String ret = rs.getString(2); + _colret.put(rs.getString(1), ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.Map getMapLongPerson() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(31, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no in (2,3,4)"); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); + _colret.put(com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1), ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.Map getMapLongLong() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(32, "SELECT person_no AS first_no, person_no AS last_no FROM person WHERE person_no < 4"); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 2); + _colret.put(com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1), ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.lang.Long[] getLongObjectArray() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(33, "SELECT 1, 2, 3 FROM person WHERE person_no = 1"); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.Long[] ret = new java.lang.Long[3]; +ret[0] = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); +ret[1] = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 2); +ret[2] = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 3); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public long[] getLongPrimitiveArray() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(34, "SELECT 1, 2, 3 FROM person WHERE person_no = 1"); + rs = ps.executeQuery(); + if(rs.next()) { +final long[] ret = new long[3]; +ret[0] = rs.getLong(1); +ret[1] = rs.getLong(2); +ret[2] = rs.getLong(3); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List> getBobTomMap() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(35, "SELECT 'bob' as bob, 'tom' as tom FROM person WHERE person_no = 1"); + rs = ps.executeQuery(); + final java.util.List> _colret = new java.util.ArrayList>(); + while(rs.next()) { +final java.util.Map ret = new java.util.HashMap(); +ret.put("bob", rs.getString(1)); +ret.put("tom", rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List> getBobTomMapCaseInsensitive() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(36, "SELECT 'bob' as bob, 'tom' as tom FROM person WHERE person_no = 1"); + rs = ps.executeQuery(); + final java.util.List> _colret = new java.util.ArrayList>(); + while(rs.next()) { +final com.moparisthebest.jdbc.util.CaseInsensitiveHashMap ret = new com.moparisthebest.jdbc.util.CaseInsensitiveHashMap(); +ret.put("bob", rs.getString(1)); +ret.put("tom", rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List getThreePeople(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(37, "SELECT person_no, first_name, last_name, birth_date from person WHERE person_no IN (?, ?, ?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.util.ResultSetIterable getThreePeopleResultSetIterable(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(38, "SELECT person_no, first_name, last_name, birth_date from person WHERE person_no IN (?, ?, ?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + return com.moparisthebest.jdbc.util.ResultSetIterable.getResultSetIterable(rs, + rs.next() ? new com.moparisthebest.jdbc.util.ResultSetToObject() { + public com.moparisthebest.jdbc.dto.FieldPerson toObject(final ResultSet _rs, final java.util.Calendar _cal) throws SQLException { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 4), +_rs.getString(2), +_rs.getString(3)); + return ret; + } + } + : null, null); + } catch(Throwable e) { + tryClose(rs); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(39, "SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPersonConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(40, "SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson( +com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FirstName getFirstName(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(41, "SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPersonNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(42, "SELECT str_val as first_name, str_val as last_name FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FirstName getFirstNameNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(43, "SELECT str_val FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.CaseSensitivePerson getCaseSensitivePerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(44, "SELECT first_name AS M_PERSON_FIRST_NAME FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.CaseSensitivePerson ret = new com.moparisthebest.jdbc.dto.CaseSensitivePerson(); +ret.setmPersonFirstName(rs.getString(1)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List getFieldPeople(final java.util.List personNos) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.unwrap(oracle.jdbc.OracleConnection.class).createOracleArray("ARRAY_NUM_TYPE", personNos.toArray(new java.lang.Long[personNos.size()])); + ps = this.prepareStatement(45, "SELECT person_no, first_name, last_name, birth_date from person WHERE (person_no IN(select column_value from table(?))) ORDER BY person_no"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + } + } + + @Override + public java.util.List getFieldPeopleByName(final java.util.List personNos, final java.util.List names) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[2]; + try { + _bindArrays[0] = conn.unwrap(oracle.jdbc.OracleConnection.class).createOracleArray("ARRAY_NUM_TYPE", personNos.toArray(new java.lang.Long[personNos.size()])); + _bindArrays[1] = conn.unwrap(oracle.jdbc.OracleConnection.class).createOracleArray("ARRAY_STR_TYPE", names.toArray(new java.lang.String[names.size()])); + ps = this.prepareStatement(46, "SELECT person_no, first_name, last_name, birth_date from person WHERE (person_no IN(select column_value from table(?))) AND ((first_name IN(select column_value from table(?))) OR (last_name IN(select column_value from table(?)))) ORDER BY person_no"); + ps.setArray(1, _bindArrays[0]); + ps.setArray(2, _bindArrays[1]); + ps.setArray(3, _bindArrays[1]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + } + } + + @Override + public java.util.List getFieldPeopleNotIn(final java.util.List personNos) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.unwrap(oracle.jdbc.OracleConnection.class).createOracleArray("ARRAY_NUM_TYPE", personNos.toArray(new java.lang.Long[personNos.size()])); + ps = this.prepareStatement(47, "SELECT person_no, first_name, last_name, birth_date from person WHERE (person_no NOT IN(select column_value from table(?))) ORDER BY person_no"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + } + } + + @Override + public long insertGetGeneratedKeyOracle(final long value) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO a_thaoeu_table (a_thaoeu_table_no, a_thaoeu_table_val) VALUES (a_thaoeu_table_seq.nextval, ?)", new int[]{1}); + ps.setObject(1, value); + ps.executeUpdate(); + ResultSet rs = null; + try { + rs = ps.getGeneratedKeys(); + return rs.next() ? rs.getLong(1) : 0; + } finally { + tryClose(rs); + } + } finally { + tryClose(ps); + } + } + + @Override + public long insertGetGeneratedKey(final long value) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO a_thaoeu_table (a_thaoeu_table_val) VALUES (?)", new int[]{1}); + ps.setObject(1, value); + ps.executeUpdate(); + ResultSet rs = null; + try { + rs = ps.getGeneratedKeys(); + return rs.next() ? rs.getLong(1) : 0; + } finally { + tryClose(rs); + } + } finally { + tryClose(ps); + } + } + + @Override + public java.util.List selectRandomSql(final java.lang.String sql) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE " + sql + ""); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List selectRandomSqlBuilder(final com.moparisthebest.jdbc.util.SqlBuilder sql) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE " + sql + ""); + int psParamCount = 0; + psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, sql); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List selectRandomSql(final long personNo1, final java.lang.String sql, final java.lang.String firstName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE person_no = ? " + sql + " OR first_name = ?"); + ps.setObject(1, personNo1); + ps.setObject(2, firstName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List selectRandomSqlBuilder(final long personNo1, final com.moparisthebest.jdbc.util.Bindable sql, final java.lang.String firstName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE person_no = ? " + sql + " OR first_name = ?"); + int psParamCount = 0; + ps.setObject(++psParamCount, personNo1); + psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, sql.getBindObject()); + ps.setObject(++psParamCount, firstName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public void insertRandomSqlCollection(final java.util.Collection sql) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT " + sql + ""); + int psParamCount = 0; + psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, sql); + ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + @Override + public void insertRandomSqlIterable(final java.lang.Iterable sql) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT " + sql + ""); + int psParamCount = 0; + psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, sql); + ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + private static final java.lang.reflect.Field[] _fields = new java.lang.reflect.Field[] { + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "personNo"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "firstName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "lastName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "birthDate"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldBoss.class, "department"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldBoss.class, "first_name"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldPerson.class, "personNo"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldBoss.class, "firstName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldPerson.class, "lastName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldPerson.class, "birthDate"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldBoss.class, "department"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldPerson.class, "first_name"), + }; + + private final PreparedStatement[] psCache = new PreparedStatement[48]; + + private PreparedStatement prepareStatement(final int index, final String sql) throws SQLException { + final PreparedStatement ps = psCache[index]; + return ps == null ? (psCache[index] = conn.prepareStatement(sql)) : ps; + } + + @Override + public void close() { + for(final PreparedStatement ps : psCache) + tryClose(ps); + } + + public QmDaoOracleBean(final Factory connectionFactory) throws SQLException { + this(connectionFactory.create(), true); + } + + public QmDaoOracleBean(final String jndiName) throws SQLException { + this(com.moparisthebest.jdbc.codegen.JdbcMapperFactory.connectionFactory(jndiName)); + } + + @Override + public SqlBuilder sqlBuilder() { + return SqlBuilder.of(conn, com.moparisthebest.jdbc.OracleArrayInList.instance()); + } +} diff --git a/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/QmDaoUnNestBean.java b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/QmDaoUnNestBean.java new file mode 100644 index 0000000..98de6b9 --- /dev/null +++ b/test/src/test/snapshot/jdk6/com/moparisthebest/jdbc/codegen/QmDaoUnNestBean.java @@ -0,0 +1,1321 @@ +package com.moparisthebest.jdbc.codegen; + +import com.moparisthebest.jdbc.util.SqlBuilder; +import com.moparisthebest.jdbc.Factory; + +import java.sql.*; + +import static com.moparisthebest.jdbc.util.ResultSetUtil.*; +import static com.moparisthebest.jdbc.TryClose.tryClose; + +public class QmDaoUnNestBean implements QmDao { + + private final Connection conn; + private final boolean closeConn; + + + private QmDaoUnNestBean(final Connection conn, final boolean closeConn) { + this.conn = conn; + this.closeConn = closeConn; + if (this.conn == null) + throw new NullPointerException("Connection needs to be non-null for JdbcMapper..."); + } + + public QmDaoUnNestBean(Connection conn) { + this(conn, false); + } + + public Connection getConnection() { + return this.conn; + } + + @Override + public com.moparisthebest.jdbc.dto.FieldPerson getFieldRegularPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(0, "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.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.BuilderPerson getBuilderPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(1, "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.BuilderPerson ret = new com.moparisthebest.jdbc.dto.BuilderPerson(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegularAndUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(2, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(6)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegularAndUnderscoreReverse(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(3, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegularAndUnderscoreNoConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(4, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name, p.first_name AS dummy FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[5], ret, rs.getString(6)); +ret.setDummy(rs.getString(7)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegularAndUnderscoreReverseNoConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(5, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName, p.first_name AS dummy FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[5], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(6)); +ret.setDummy(rs.getString(7)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldRegular(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(6, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FieldBoss getFieldUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(7, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[5], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetPerson getSetRegularPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(8, "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.SetPerson ret = new com.moparisthebest.jdbc.dto.SetPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetPerson getSetRegularPersonNoConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(9, "SELECT person_no, first_name, last_name, birth_date, first_name AS dummy FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetPerson ret = new com.moparisthebest.jdbc.dto.SetPerson(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDummy(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetBoss getSetRegularAndUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(10, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetBoss ret = new com.moparisthebest.jdbc.dto.SetBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(6)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetBoss getSetRegularAndUnderscoreReverse(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(11, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetBoss ret = new com.moparisthebest.jdbc.dto.SetBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetBoss getSetRegular(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(12, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetBoss ret = new com.moparisthebest.jdbc.dto.SetBoss(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDepartment(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.SetBoss getSetUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(13, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.SetBoss ret = new com.moparisthebest.jdbc.dto.SetBoss(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirst_name(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDepartment(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldPerson getReverseFieldRegularPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(14, "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.ReverseFieldPerson ret = new com.moparisthebest.jdbc.dto.ReverseFieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldBoss getReverseFieldRegularAndUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(15, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseFieldBoss ret = new com.moparisthebest.jdbc.dto.ReverseFieldBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(6)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldBoss getReverseFieldRegularAndUnderscoreReverse(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(16, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseFieldBoss ret = new com.moparisthebest.jdbc.dto.ReverseFieldBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldBoss getReverseFieldRegular(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(17, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseFieldBoss ret = new com.moparisthebest.jdbc.dto.ReverseFieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[6], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[7], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[8], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[9], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[10], ret, rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseFieldBoss getReverseFieldUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(18, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseFieldBoss ret = new com.moparisthebest.jdbc.dto.ReverseFieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[6], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[11], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[8], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[9], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[10], ret, rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetPerson getReverseSetRegularPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(19, "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.ReverseSetPerson ret = new com.moparisthebest.jdbc.dto.ReverseSetPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetBoss getReverseSetRegularAndUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(20, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department, p.first_name FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseSetBoss ret = new com.moparisthebest.jdbc.dto.ReverseSetBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(6)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetBoss getReverseSetRegularAndUnderscoreReverse(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(21, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department, p.first_name AS firstName FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseSetBoss ret = new com.moparisthebest.jdbc.dto.ReverseSetBoss( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(6), +rs.getString(3), +rs.getString(5), +rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetBoss getReverseSetRegular(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(22, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseSetBoss ret = new com.moparisthebest.jdbc.dto.ReverseSetBoss(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirstName(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDepartment(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.ReverseSetBoss getReverseSetUnderscore(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(23, "SELECT p.person_no, p.first_name, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.ReverseSetBoss ret = new com.moparisthebest.jdbc.dto.ReverseSetBoss(); +ret.setPersonNo(rs.getLong(1)); +ret.setFirst_name(rs.getString(2)); +ret.setLastName(rs.getString(3)); +ret.setBirthDate(com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +ret.setDepartment(rs.getString(5)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.lang.Long getPersonNo(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(24, "SELECT person_no FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public long getPersonNoPrimitive(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(25, "SELECT person_no FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final long ret = rs.getLong(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + } + } + + @Override + public int getPersonNoPrimitiveInt(final int personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(26, "SELECT person_no FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final int ret = rs.getInt(1); + return ret; + } else { + return 0; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.lang.Long[] getPersonNoObjectArray(final java.lang.Long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(27, "SELECT person_no FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret.toArray(new java.lang.Long[_colret.size()]); + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List> getAllNames() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(28, "SELECT first_name, last_name FROM person WHERE person_no < 4"); + rs = ps.executeQuery(); + final java.util.List> _colret = new java.util.ArrayList>(); + while(rs.next()) { +final java.util.Map ret = new java.util.HashMap(); +ret.put("first_name", rs.getString(1)); +ret.put("last_name", rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.Map[] getAllNamesArray() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(29, "SELECT first_name, last_name FROM person WHERE person_no < 4"); + rs = ps.executeQuery(); + final java.util.List> _colret = new java.util.ArrayList>(); + while(rs.next()) { +final java.util.Map ret = new java.util.HashMap(); +ret.put("first_name", rs.getString(1)); +ret.put("last_name", rs.getString(2)); + _colret.add(ret); + } + @SuppressWarnings("unchecked") + final java.util.Map[] _warnret = _colret.toArray(new java.util.Map[_colret.size()]); + return _warnret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.Map getAllNameMap() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(30, "SELECT first_name, last_name FROM person WHERE person_no < 4"); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final java.lang.String ret = rs.getString(2); + _colret.put(rs.getString(1), ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.Map getMapLongPerson() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(31, "SELECT p.person_no, p.first_name AS firstName, p.last_name, p.birth_date, b.department FROM person p JOIN boss b ON p.person_no = b.person_no WHERE p.person_no in (2,3,4)"); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldBoss ret = new com.moparisthebest.jdbc.dto.FieldBoss(); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[0], ret, rs.getLong(1)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[1], ret, rs.getString(2)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[2], ret, rs.getString(3)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[3], ret, com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4)); +com.moparisthebest.jdbc.util.ReflectionUtil.setValue(_fields[4], ret, rs.getString(5)); + _colret.put(com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1), ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.Map getMapLongLong() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(32, "SELECT person_no AS first_no, person_no AS last_no FROM person WHERE person_no < 4"); + rs = ps.executeQuery(); + final java.util.Map _colret = new java.util.HashMap(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 2); + _colret.put(com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1), ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.lang.Long[] getLongObjectArray() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(33, "SELECT 1, 2, 3 FROM person WHERE person_no = 1"); + rs = ps.executeQuery(); + if(rs.next()) { +final java.lang.Long[] ret = new java.lang.Long[3]; +ret[0] = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); +ret[1] = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 2); +ret[2] = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 3); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public long[] getLongPrimitiveArray() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(34, "SELECT 1, 2, 3 FROM person WHERE person_no = 1"); + rs = ps.executeQuery(); + if(rs.next()) { +final long[] ret = new long[3]; +ret[0] = rs.getLong(1); +ret[1] = rs.getLong(2); +ret[2] = rs.getLong(3); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List> getBobTomMap() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(35, "SELECT 'bob' as bob, 'tom' as tom FROM person WHERE person_no = 1"); + rs = ps.executeQuery(); + final java.util.List> _colret = new java.util.ArrayList>(); + while(rs.next()) { +final java.util.Map ret = new java.util.HashMap(); +ret.put("bob", rs.getString(1)); +ret.put("tom", rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List> getBobTomMapCaseInsensitive() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(36, "SELECT 'bob' as bob, 'tom' as tom FROM person WHERE person_no = 1"); + rs = ps.executeQuery(); + final java.util.List> _colret = new java.util.ArrayList>(); + while(rs.next()) { +final com.moparisthebest.jdbc.util.CaseInsensitiveHashMap ret = new com.moparisthebest.jdbc.util.CaseInsensitiveHashMap(); +ret.put("bob", rs.getString(1)); +ret.put("tom", rs.getString(2)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List getThreePeople(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(37, "SELECT person_no, first_name, last_name, birth_date from person WHERE person_no IN (?, ?, ?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.util.ResultSetIterable getThreePeopleResultSetIterable(final long personNo1, final long personNo2, final long personNo3) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(38, "SELECT person_no, first_name, last_name, birth_date from person WHERE person_no IN (?, ?, ?) ORDER BY person_no"); + ps.setObject(1, personNo1); + ps.setObject(2, personNo2); + ps.setObject(3, personNo3); + rs = ps.executeQuery(); + return com.moparisthebest.jdbc.util.ResultSetIterable.getResultSetIterable(rs, + rs.next() ? new com.moparisthebest.jdbc.util.ResultSetToObject() { + public com.moparisthebest.jdbc.dto.FieldPerson toObject(final ResultSet _rs, final java.util.Calendar _cal) throws SQLException { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +_rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(_rs, 4), +_rs.getString(2), +_rs.getString(3)); + return ret; + } + } + : null, null); + } catch(Throwable e) { + tryClose(rs); + if(e instanceof SQLException) + throw (SQLException)e; + if(e instanceof RuntimeException) + throw (RuntimeException)e; + throw new RuntimeException(e); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(39, "SELECT first_name, last_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPersonConstructor(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(40, "SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson( +com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FirstName getFirstName(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(41, "SELECT first_name FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.EnumPerson getEnumPersonNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(42, "SELECT str_val as first_name, str_val as last_name FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.EnumPerson ret = new com.moparisthebest.jdbc.dto.EnumPerson(); +ret.setFirstName(com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class)); +ret.setLastName(rs.getString(2)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.FirstName getFirstNameNull() throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(43, "SELECT str_val FROM val WHERE val_no = 4"); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.FirstName ret = com.moparisthebest.jdbc.util.ResultSetUtil.getEnum(rs, 1, com.moparisthebest.jdbc.dto.FirstName.class); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public com.moparisthebest.jdbc.dto.CaseSensitivePerson getCaseSensitivePerson(final long personNo) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = this.prepareStatement(44, "SELECT first_name AS M_PERSON_FIRST_NAME FROM person WHERE person_no = ?"); + ps.setObject(1, personNo); + rs = ps.executeQuery(); + if(rs.next()) { +final com.moparisthebest.jdbc.dto.CaseSensitivePerson ret = new com.moparisthebest.jdbc.dto.CaseSensitivePerson(); +ret.setmPersonFirstName(rs.getString(1)); + return ret; + } else { + return null; + } + } finally { + tryClose(rs); + } + } + + @Override + public java.util.List getFieldPeople(final java.util.List personNos) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("NUMERIC", personNos.toArray(new java.lang.Long[personNos.size()])); + ps = this.prepareStatement(45, "SELECT person_no, first_name, last_name, birth_date from person WHERE (person_no IN(UNNEST(?))) ORDER BY person_no"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + } + } + + @Override + public java.util.List getFieldPeopleByName(final java.util.List personNos, final java.util.List names) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[2]; + try { + _bindArrays[0] = conn.createArrayOf("NUMERIC", personNos.toArray(new java.lang.Long[personNos.size()])); + _bindArrays[1] = conn.createArrayOf("VARCHAR", names.toArray(new java.lang.String[names.size()])); + ps = this.prepareStatement(46, "SELECT person_no, first_name, last_name, birth_date from person WHERE (person_no IN(UNNEST(?))) AND ((first_name IN(UNNEST(?))) OR (last_name IN(UNNEST(?)))) ORDER BY person_no"); + ps.setArray(1, _bindArrays[0]); + ps.setArray(2, _bindArrays[1]); + ps.setArray(3, _bindArrays[1]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + } + } + + @Override + public java.util.List getFieldPeopleNotIn(final java.util.List personNos) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + final Array[] _bindArrays = new Array[1]; + try { + _bindArrays[0] = conn.createArrayOf("NUMERIC", personNos.toArray(new java.lang.Long[personNos.size()])); + ps = this.prepareStatement(47, "SELECT person_no, first_name, last_name, birth_date from person WHERE (person_no NOT IN(UNNEST(?))) ORDER BY person_no"); + ps.setArray(1, _bindArrays[0]); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final com.moparisthebest.jdbc.dto.FieldPerson ret = new com.moparisthebest.jdbc.dto.FieldPerson( +rs.getLong(1), +com.moparisthebest.jdbc.util.ResultSetUtil.getUtilDate(rs, 4), +rs.getString(2), +rs.getString(3)); + _colret.add(ret); + } + return _colret; + } finally { + for(final Array _bindArray : _bindArrays) + tryClose(_bindArray); + tryClose(rs); + } + } + + @Override + public long insertGetGeneratedKeyOracle(final long value) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO a_thaoeu_table (a_thaoeu_table_no, a_thaoeu_table_val) VALUES (a_thaoeu_table_seq.nextval, ?)", java.sql.Statement.RETURN_GENERATED_KEYS); + ps.setObject(1, value); + ps.executeUpdate(); + ResultSet rs = null; + try { + rs = ps.getGeneratedKeys(); + return rs.next() ? rs.getLong(1) : 0; + } finally { + tryClose(rs); + } + } finally { + tryClose(ps); + } + } + + @Override + public long insertGetGeneratedKey(final long value) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT INTO a_thaoeu_table (a_thaoeu_table_val) VALUES (?)", java.sql.Statement.RETURN_GENERATED_KEYS); + ps.setObject(1, value); + ps.executeUpdate(); + ResultSet rs = null; + try { + rs = ps.getGeneratedKeys(); + return rs.next() ? rs.getLong(1) : 0; + } finally { + tryClose(rs); + } + } finally { + tryClose(ps); + } + } + + @Override + public java.util.List selectRandomSql(final java.lang.String sql) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE " + sql + ""); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List selectRandomSqlBuilder(final com.moparisthebest.jdbc.util.SqlBuilder sql) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE " + sql + ""); + int psParamCount = 0; + psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, sql); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List selectRandomSql(final long personNo1, final java.lang.String sql, final java.lang.String firstName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE person_no = ? " + sql + " OR first_name = ?"); + ps.setObject(1, personNo1); + ps.setObject(2, firstName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public java.util.List selectRandomSqlBuilder(final long personNo1, final com.moparisthebest.jdbc.util.Bindable sql, final java.lang.String firstName) throws java.sql.SQLException { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = conn.prepareStatement("SELECT person_no FROM person WHERE person_no = ? " + sql + " OR first_name = ?"); + int psParamCount = 0; + ps.setObject(++psParamCount, personNo1); + psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, sql.getBindObject()); + ps.setObject(++psParamCount, firstName); + rs = ps.executeQuery(); + final java.util.List _colret = new java.util.ArrayList(); + while(rs.next()) { +final java.lang.Long ret = com.moparisthebest.jdbc.util.ResultSetUtil.getObjectLong(rs, 1); + _colret.add(ret); + } + return _colret; + } finally { + tryClose(rs); + tryClose(ps); + } + } + + @Override + public void insertRandomSqlCollection(final java.util.Collection sql) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT " + sql + ""); + int psParamCount = 0; + psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, sql); + ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + @Override + public void insertRandomSqlIterable(final java.lang.Iterable sql) throws java.sql.SQLException { + PreparedStatement ps = null; + try { + ps = conn.prepareStatement("INSERT " + sql + ""); + int psParamCount = 0; + psParamCount = com.moparisthebest.jdbc.util.PreparedStatementUtil.recursiveBindIndex(ps, psParamCount, sql); + ps.executeUpdate(); + } finally { + tryClose(ps); + } + } + + private static final java.lang.reflect.Field[] _fields = new java.lang.reflect.Field[] { + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "personNo"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "firstName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "lastName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldPerson.class, "birthDate"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldBoss.class, "department"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.FieldBoss.class, "first_name"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldPerson.class, "personNo"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldBoss.class, "firstName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldPerson.class, "lastName"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldPerson.class, "birthDate"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldBoss.class, "department"), + com.moparisthebest.jdbc.util.ReflectionUtil.getAccessibleField(com.moparisthebest.jdbc.dto.ReverseFieldPerson.class, "first_name"), + }; + + private final PreparedStatement[] psCache = new PreparedStatement[48]; + + private PreparedStatement prepareStatement(final int index, final String sql) throws SQLException { + final PreparedStatement ps = psCache[index]; + return ps == null ? (psCache[index] = conn.prepareStatement(sql)) : ps; + } + + @Override + public void close() { + for(final PreparedStatement ps : psCache) + tryClose(ps); + } + + public QmDaoUnNestBean(final Factory connectionFactory) throws SQLException { + this(connectionFactory.create(), true); + } + + public QmDaoUnNestBean(final String jndiName) throws SQLException { + this(com.moparisthebest.jdbc.codegen.JdbcMapperFactory.connectionFactory(jndiName)); + } + + @Override + public SqlBuilder sqlBuilder() { + return SqlBuilder.of(conn, com.moparisthebest.jdbc.UnNestArrayInList.instance()); + } +}