From 3f4d3121b41422b89880abe8247df8b854eba3f3 Mon Sep 17 00:00:00 2001 From: moparisthebest Date: Tue, 15 Jan 2019 23:48:27 -0500 Subject: [PATCH] Delete ListQueryMapper --- .../moparisthebest/jdbc/ListQueryMapper.java | 119 ------------------ .../jdbc/codegen/QueryMapperQmDao.java | 23 ++-- .../jdbc/codegen/QueryMapperTypeQmDao.java | 17 ++- 3 files changed, 16 insertions(+), 143 deletions(-) delete mode 100644 querymapper/src/main/java/com/moparisthebest/jdbc/ListQueryMapper.java diff --git a/querymapper/src/main/java/com/moparisthebest/jdbc/ListQueryMapper.java b/querymapper/src/main/java/com/moparisthebest/jdbc/ListQueryMapper.java deleted file mode 100644 index 3b5effc..0000000 --- a/querymapper/src/main/java/com/moparisthebest/jdbc/ListQueryMapper.java +++ /dev/null @@ -1,119 +0,0 @@ -package com.moparisthebest.jdbc; - -import com.moparisthebest.jdbc.codegen.JdbcMapper; -import com.moparisthebest.jdbc.util.ResultSetIterable; - -import java.lang.reflect.Method; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.*; -//IFJAVA8_START -import java.util.stream.Stream; -//IFJAVA8_END - -public class ListQueryMapper extends QueryMapper { - - protected final QueryMapper delegate; - protected final boolean closeDelegate; - - public static final String inListReplace = "{inList}"; - - protected ListQueryMapper(Connection conn, String jndiName, Factory factory, final QueryMapper d, ResultSetMapper cm, InList inList, boolean closeDelegate) { - super(d == null ? conn : d.conn, jndiName, factory, d == null ? cm : d.cm, d == null ? inList : d.inList); - this.closeDelegate = closeDelegate; - this.delegate = d; - } - - protected ListQueryMapper(Connection conn, String jndiName, Factory factory, final QueryMapper d, ResultSetMapper cm, InList inList) { - this(conn, jndiName, factory, d, cm, inList, false); - } - - protected ListQueryMapper(Connection conn, String jndiName, Factory factory, QueryMapper delegate, ResultSetMapper cm) { - this(conn, jndiName, factory, delegate, cm, defaultInList); - } - - public ListQueryMapper(InList inList, QueryMapper delegate, boolean closeDelegate) { - this(null, null, null, delegate, null, inList, closeDelegate); - } - - public ListQueryMapper(QueryMapper delegate, InList inList) { - this(null, null, null, delegate, null, inList); - } - - public ListQueryMapper(QueryMapper delegate) { - this(null, null, null, delegate, null, defaultInList); - } - - public ListQueryMapper(Connection conn, InList inList) { - this(conn, null, null, null, null, inList); - } - - public ListQueryMapper(Connection conn, ResultSetMapper cm, InList inList) { - this(conn, null, null, null, cm, inList); - } - - public ListQueryMapper(Connection conn) { - this(conn, defaultInList); - } - - public ListQueryMapper(Connection conn, ResultSetMapper cm) { - this(conn, cm, defaultInList); - } - - public ListQueryMapper(String jndiName, InList inList) { - this(null, jndiName, null, null, null, inList); - } - - public ListQueryMapper(String jndiName, ResultSetMapper cm, InList inList) { - this(null, jndiName, null, null, cm, inList); - } - - public ListQueryMapper(String jndiName) { - this(jndiName, defaultInList); - } - - public ListQueryMapper(String jndiName, ResultSetMapper cm) { - this(jndiName, cm, defaultInList); - } - - public ListQueryMapper(Factory factory, InList inList) { - this(null, null, factory, null, null, inList); - } - - public ListQueryMapper(Factory factory, ResultSetMapper cm, InList inList) { - this(null, null, factory, null, cm, inList); - } - - public ListQueryMapper(Factory factory) { - this(factory, defaultInList); - } - - public ListQueryMapper(Factory factory, ResultSetMapper cm) { - this(factory, cm, defaultInList); - } - - public static ListQueryMapper of(final Factory qmFactory, final InList inList) throws SQLException { - return new ListQueryMapper(inList, qmFactory.create(), true); - } - - public static ListQueryMapper of(final QueryMapper qm, final InList inList) { - return new ListQueryMapper(inList, qm, false); - } - - public static ListQueryMapper of(final Factory qmFactory) throws SQLException { - return of(qmFactory, defaultInList); - } - - public static ListQueryMapper of(final QueryMapper qm) { - return of(qm, defaultInList); - } - - @Override - public void close() { - if(closeDelegate) - delegate.close(); - } -} - diff --git a/test/src/main/java/com/moparisthebest/jdbc/codegen/QueryMapperQmDao.java b/test/src/main/java/com/moparisthebest/jdbc/codegen/QueryMapperQmDao.java index b386a7c..93775b6 100644 --- a/test/src/main/java/com/moparisthebest/jdbc/codegen/QueryMapperQmDao.java +++ b/test/src/main/java/com/moparisthebest/jdbc/codegen/QueryMapperQmDao.java @@ -15,7 +15,7 @@ import java.util.stream.Stream; import java.time.*; //IFJAVA8_END -import static com.moparisthebest.jdbc.ListQueryMapper.inListReplace; +import static com.moparisthebest.jdbc.QueryMapper.inListReplace; import static com.moparisthebest.jdbc.TryClose.tryClose; public class QueryMapperQmDao implements QmDao { @@ -56,11 +56,9 @@ public class QueryMapperQmDao implements QmDao { public static final String selectStrVal = "SELECT str_val FROM val WHERE val_no = ?"; protected final QueryMapper qm; - protected final ListQueryMapper lqm; public QueryMapperQmDao(final Connection conn, final ResultSetMapper rsm) { this.qm = new QueryMapper(conn, rsm); - this.lqm = new ListQueryMapper(qm); } @Override @@ -72,13 +70,8 @@ public class QueryMapperQmDao implements QmDao { return qm; } - public ListQueryMapper getLqm() { - return lqm; - } - @Override public void close() { - tryClose(lqm); tryClose(qm); } @@ -386,28 +379,28 @@ public class QueryMapperQmDao implements QmDao { @Override public List getFieldPeopleStream(final Stream personNos) throws SQLException { - return lqm.toList("SELECT * from person WHERE " + inListReplace + " ORDER BY person_no", FieldPerson.class, lqm.inList("person_no", personNos.collect(Collectors.toList()))); + return qm.toList("SELECT * from person WHERE " + inListReplace + " ORDER BY person_no", FieldPerson.class, qm.inList("person_no", personNos.collect(Collectors.toList()))); } //IFJAVA8_END @Override public List getFieldPeople(final List personNos) throws SQLException { - return lqm.toList("SELECT * from person WHERE " + inListReplace + " ORDER BY person_no", FieldPerson.class, lqm.inList("person_no", personNos)); + return qm.toList("SELECT * from person WHERE " + inListReplace + " ORDER BY person_no", FieldPerson.class, qm.inList("person_no", personNos)); } @Override public List getFieldPeopleByName(final List personNos, final List names) throws SQLException { - return lqm.toList("SELECT * from person WHERE " + inListReplace + " AND (" + inListReplace + " OR " + inListReplace + ") ORDER BY person_no", + return qm.toList("SELECT * from person WHERE " + inListReplace + " AND (" + inListReplace + " OR " + inListReplace + ") ORDER BY person_no", FieldPerson.class, - lqm.inList("person_no", personNos), - lqm.inList("first_name", names), - lqm.inList("last_name", names) + qm.inList("person_no", personNos), + qm.inList("first_name", names), + qm.inList("last_name", names) ); } @Override public List getFieldPeopleNotIn(final List personNos) throws SQLException { - return lqm.toList("SELECT * from person WHERE " + inListReplace + " ORDER BY person_no", FieldPerson.class, lqm.notInList("person_no", personNos)); + return qm.toList("SELECT * from person WHERE " + inListReplace + " ORDER BY person_no", FieldPerson.class, qm.notInList("person_no", personNos)); } } diff --git a/test/src/main/java/com/moparisthebest/jdbc/codegen/QueryMapperTypeQmDao.java b/test/src/main/java/com/moparisthebest/jdbc/codegen/QueryMapperTypeQmDao.java index e222d7c..d1b11b0 100644 --- a/test/src/main/java/com/moparisthebest/jdbc/codegen/QueryMapperTypeQmDao.java +++ b/test/src/main/java/com/moparisthebest/jdbc/codegen/QueryMapperTypeQmDao.java @@ -1,6 +1,5 @@ package com.moparisthebest.jdbc.codegen; -import com.moparisthebest.jdbc.ListQueryMapper; import com.moparisthebest.jdbc.ResultSetMapper; import com.moparisthebest.jdbc.TypeReference; import com.moparisthebest.jdbc.dto.*; @@ -18,7 +17,7 @@ import java.util.stream.Stream; import java.time.*; //IFJAVA8_END -import static com.moparisthebest.jdbc.ListQueryMapper.inListReplace; +import static com.moparisthebest.jdbc.QueryMapper.inListReplace; public class QueryMapperTypeQmDao extends QueryMapperQmDao { @@ -335,28 +334,28 @@ public class QueryMapperTypeQmDao extends QueryMapperQmDao { @Override public List getFieldPeopleStream(final Stream personNos) throws SQLException { - return lqm.toType("SELECT * from person WHERE " + inListReplace + " ORDER BY person_no", new TypeReference>() {}, lqm.inList("person_no", personNos.collect(Collectors.toList()))); + return qm.toType("SELECT * from person WHERE " + inListReplace + " ORDER BY person_no", new TypeReference>() {}, qm.inList("person_no", personNos.collect(Collectors.toList()))); } //IFJAVA8_END @Override public List getFieldPeople(final List personNos) throws SQLException { - return lqm.toType("SELECT * from person WHERE " + ListQueryMapper.inListReplace + " ORDER BY person_no", new TypeReference>() {}, lqm.inList("person_no", personNos)); + return qm.toType("SELECT * from person WHERE " + inListReplace + " ORDER BY person_no", new TypeReference>() {}, qm.inList("person_no", personNos)); } @Override public List getFieldPeopleByName(final List personNos, final List names) throws SQLException { - return lqm.toType("SELECT * from person WHERE " + inListReplace + " AND (" + inListReplace + " OR " + inListReplace + ") ORDER BY person_no", + return qm.toType("SELECT * from person WHERE " + inListReplace + " AND (" + inListReplace + " OR " + inListReplace + ") ORDER BY person_no", new TypeReference>() {}, - lqm.inList("person_no", personNos), - lqm.inList("first_name", names), - lqm.inList("last_name", names) + qm.inList("person_no", personNos), + qm.inList("first_name", names), + qm.inList("last_name", names) ); } @Override public List getFieldPeopleNotIn(final List personNos) throws SQLException { - return lqm.toType("SELECT * from person WHERE " + ListQueryMapper.inListReplace + " ORDER BY person_no", new TypeReference>() {}, lqm.notInList("person_no", personNos)); + return qm.toType("SELECT * from person WHERE " + inListReplace + " ORDER BY person_no", new TypeReference>() {}, qm.notInList("person_no", personNos)); } }