1414
1515package org .httprpc .sql ;
1616
17- import java .sql .Connection ;
18- import java .sql .PreparedStatement ;
1917import java .sql .ResultSet ;
2018import java .sql .ResultSetMetaData ;
2119import java .sql .SQLException ;
2220import java .util .Iterator ;
2321import java .util .LinkedHashMap ;
24- import java .util .LinkedList ;
2522import java .util .Map ;
2623import java .util .NoSuchElementException ;
2724import java .util .stream .Stream ;
@@ -35,9 +32,6 @@ public class ResultSetAdapter implements Iterable<Map<String, Object>> {
3532 private ResultSet resultSet ;
3633 private ResultSetMetaData resultSetMetaData ;
3734
38- // TODO Remove this when attach() method is dropped
39- private LinkedHashMap <String , Parameters > subqueries = new LinkedHashMap <>();
40-
4135 private Iterator <Map <String , Object >> iterator = new Iterator <Map <String , Object >>() {
4236 private Boolean hasNext = null ;
4337
@@ -92,30 +86,6 @@ public Map<String, Object> next() {
9286 throw new RuntimeException (exception );
9387 }
9488
95- for (Map .Entry <String , Parameters > entry : subqueries .entrySet ()) {
96- LinkedList <Map <String , Object >> results = new LinkedList <>();
97-
98- try {
99- Connection connection = resultSet .getStatement ().getConnection ();
100-
101- Parameters parameters = entry .getValue ();
102-
103- try (PreparedStatement statement = connection .prepareStatement (parameters .getSQL ())) {
104- parameters .apply (statement , row );
105-
106- try (ResultSet resultSet = statement .executeQuery ()) {
107- for (Map <String , Object > result : new ResultSetAdapter (resultSet )) {
108- results .add (result );
109- }
110- }
111- }
112- } catch (SQLException exception ) {
113- throw new RuntimeException (exception );
114- }
115-
116- row .put (entry .getKey (), results );
117- }
118-
11989 hasNext = null ;
12090
12191 return row ;
@@ -142,59 +112,6 @@ public ResultSetAdapter(ResultSet resultSet) {
142112 }
143113 }
144114
145- /**
146- * Attaches a subquery to the result set.
147- *
148- * @param key
149- * The key to associate with the subquery results.
150- *
151- * @param subquery
152- * The subquery to attach.
153- *
154- * @deprecated Use {@link Stream} operations instead.
155- */
156- @ Deprecated
157- public void attach (String key , String subquery ) {
158- attach (key , Parameters .parse (subquery ));
159- }
160-
161- /**
162- * Attaches a subquery to the result set.
163- *
164- * @param key
165- * The key to associate with the subquery results.
166- *
167- * @param subquery
168- * The subquery to attach.
169- *
170- * @deprecated Use {@link Stream} operations instead.
171- */
172- @ Deprecated
173- public void attach (String key , Parameters subquery ) {
174- if (key == null ) {
175- throw new IllegalArgumentException ();
176- }
177-
178- if (subquery == null ) {
179- throw new IllegalArgumentException ();
180- }
181-
182- subqueries .put (key , subquery );
183- }
184-
185- /**
186- * Returns the next result.
187- *
188- * @return
189- * The next result, or <tt>null</tt> if there are no more results.
190- *
191- * @deprecated Use {@link Stream} operations instead.
192- */
193- @ Deprecated
194- public Map <String , Object > next () {
195- return iterator .hasNext () ? iterator .next () : null ;
196- }
197-
198115 @ Override
199116 public Iterator <Map <String , Object >> iterator () {
200117 return iterator ;
0 commit comments