mirror of
https://github.com/moparisthebest/JdbcMapper
synced 2024-11-21 08:35:00 -05:00
Delete ListQueryMapper
This commit is contained in:
parent
3a562ad88a
commit
3f4d3121b4
@ -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<Connection> 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<Connection> factory, final QueryMapper d, ResultSetMapper cm, InList inList) {
|
||||
this(conn, jndiName, factory, d, cm, inList, false);
|
||||
}
|
||||
|
||||
protected ListQueryMapper(Connection conn, String jndiName, Factory<Connection> 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<Connection> factory, InList inList) {
|
||||
this(null, null, factory, null, null, inList);
|
||||
}
|
||||
|
||||
public ListQueryMapper(Factory<Connection> factory, ResultSetMapper cm, InList inList) {
|
||||
this(null, null, factory, null, cm, inList);
|
||||
}
|
||||
|
||||
public ListQueryMapper(Factory<Connection> factory) {
|
||||
this(factory, defaultInList);
|
||||
}
|
||||
|
||||
public ListQueryMapper(Factory<Connection> factory, ResultSetMapper cm) {
|
||||
this(factory, cm, defaultInList);
|
||||
}
|
||||
|
||||
public static ListQueryMapper of(final Factory<QueryMapper> 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<QueryMapper> 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();
|
||||
}
|
||||
}
|
||||
|
@ -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<FieldPerson> getFieldPeopleStream(final Stream<Long> 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<FieldPerson> getFieldPeople(final List<Long> 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<FieldPerson> getFieldPeopleByName(final List<Long> personNos, final List<String> 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<FieldPerson> getFieldPeopleNotIn(final List<Long> 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));
|
||||
}
|
||||
}
|
||||
|
@ -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<FieldPerson> getFieldPeopleStream(final Stream<Long> personNos) throws SQLException {
|
||||
return lqm.toType("SELECT * from person WHERE " + inListReplace + " ORDER BY person_no", new TypeReference<List<FieldPerson>>() {}, lqm.inList("person_no", personNos.collect(Collectors.toList())));
|
||||
return qm.toType("SELECT * from person WHERE " + inListReplace + " ORDER BY person_no", new TypeReference<List<FieldPerson>>() {}, qm.inList("person_no", personNos.collect(Collectors.toList())));
|
||||
}
|
||||
|
||||
//IFJAVA8_END
|
||||
|
||||
@Override
|
||||
public List<FieldPerson> getFieldPeople(final List<Long> personNos) throws SQLException {
|
||||
return lqm.toType("SELECT * from person WHERE " + ListQueryMapper.inListReplace + " ORDER BY person_no", new TypeReference<List<FieldPerson>>() {}, lqm.inList("person_no", personNos));
|
||||
return qm.toType("SELECT * from person WHERE " + inListReplace + " ORDER BY person_no", new TypeReference<List<FieldPerson>>() {}, qm.inList("person_no", personNos));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FieldPerson> getFieldPeopleByName(final List<Long> personNos, final List<String> 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<List<FieldPerson>>() {},
|
||||
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<FieldPerson> getFieldPeopleNotIn(final List<Long> personNos) throws SQLException {
|
||||
return lqm.toType("SELECT * from person WHERE " + ListQueryMapper.inListReplace + " ORDER BY person_no", new TypeReference<List<FieldPerson>>() {}, lqm.notInList("person_no", personNos));
|
||||
return qm.toType("SELECT * from person WHERE " + inListReplace + " ORDER BY person_no", new TypeReference<List<FieldPerson>>() {}, qm.notInList("person_no", personNos));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user