|
6 | 6 | import lombok.Getter; |
7 | 7 | import lombok.RequiredArgsConstructor; |
8 | 8 | import me.zort.sqllib.api.Query; |
9 | | -import me.zort.sqllib.api.SQLConnection; |
10 | | -import me.zort.sqllib.api.SQLDatabaseConnection; |
11 | 9 | import me.zort.sqllib.api.StatementFactory; |
12 | 10 | import me.zort.sqllib.api.data.QueryResult; |
13 | 11 | import me.zort.sqllib.api.data.QueryRowsResult; |
@@ -161,7 +159,7 @@ protected Pair<String[], UnknownValueWrapper[]> buildDefsVals(Object obj) { |
161 | 159 | */ |
162 | 160 | @Override |
163 | 161 | public <T> QueryRowsResult<T> query(Query query, Class<T> typeClass) { |
164 | | - QueryRowsResult<Row> resultRows = query(query); |
| 162 | + QueryRowsResult<Row> resultRows = query(query.getAncestor()); |
165 | 163 | QueryRowsResult<T> result = new QueryRowsResult<>(resultRows.isSuccessful()); |
166 | 164 | for(Row row : resultRows) { |
167 | 165 | Optional.ofNullable(assignValues(row, typeClass)) |
@@ -227,6 +225,7 @@ private <T> T assignValues(Row row, Class<T> typeClass) { |
227 | 225 | try { |
228 | 226 | try { |
229 | 227 | Constructor<T> c = typeClass.getConstructor(); |
| 228 | + c.setAccessible(true); |
230 | 229 | instance = c.newInstance(); |
231 | 230 | } catch (NoSuchMethodException e) { |
232 | 231 | for(Constructor<?> c : typeClass.getConstructors()) { |
@@ -277,7 +276,7 @@ private Object buildElementValue(AnnotatedElement element, Row row) { |
277 | 276 | if(element instanceof Field) { |
278 | 277 | name = ((Field) element).getName(); |
279 | 278 | type = ((Field) element).getGenericType(); |
280 | | - } else if(element instanceof Parameter) { |
| 279 | + } else if(element instanceof Parameter) { // TODO: Parameter names are arg[a-zA-Z0-9]+, use different strategy. |
281 | 280 | name = ((Parameter) element).getName(); |
282 | 281 | type = ((Parameter) element).getType(); |
283 | 282 | } else { |
@@ -363,6 +362,11 @@ public boolean isLogSqlErrors() { |
363 | 362 | return options.isLogSqlErrors(); |
364 | 363 | } |
365 | 364 |
|
| 365 | + @Override |
| 366 | + public boolean isDebug() { |
| 367 | + return options.isDebug(); |
| 368 | + } |
| 369 | + |
366 | 370 | @SuppressWarnings("unchecked") |
367 | 371 | private PreparedStatement buildStatement(Query query) throws SQLException { |
368 | 372 | StatementFactory<PreparedStatement> factory = new DefaultStatementFactory(query); |
|
0 commit comments