2 * This file is part of yosql. It is subject to the license terms in the LICENSE file found in the top-level
3 * directory of this distribution and at https://creativecommons.org/publicdomain/zero/1.0/. No part of yosql,
4 * including this file, may be copied, modified, propagated, or distributed except according to the terms contained
8 package wtf
.metio
.yosql
.codegen
.dao
;
10 import org
.junit
.jupiter
.api
.DisplayName
;
11 import org
.junit
.jupiter
.api
.Nested
;
12 import wtf
.metio
.yosql
.internals
.testing
.configs
.JavaConfigurations
;
14 @DisplayName("DefaultReadMethodGenerator")
15 class DefaultReadMethodGeneratorTest
{
18 @DisplayName("using default configuration")
19 class Defaults
extends ReadMethodGeneratorTCK
{
22 ReadMethodGenerator
generator() {
23 return DaoObjectMother
.readMethodGenerator(JavaConfigurations
.defaults());
27 String
readSingleMethodExpectation() {
30 * <p>Executes the following statement:</p>
32 * SELECT raw FROM table WHERE test = ? AND id = ?;</pre>
34 * <p>Generated based on the following file(s):</p>
36 * <li>data/queryData.sql</li>
38 * <p>Disable generating this method by setting <strong>generateStandardApi</strong> to <strong>false</strong></p>
40 @javax.annotation.processing.Generated(
42 comments = "DO NOT MODIFY
- automatically generated by YoSQL
"
44 public final java.util.Optional<java.util.Map<java.lang.String, java.lang.Object>> queryData(
45 final java.lang.Object test, final int id) {
46 LOG.entering("com
.example
.persistence
.DataRepository
", "queryData
");
47 try (final var connection = dataSource.getConnection()) {
48 final var query = QUERY_DATA;
49 LOG.finer(() -> java.lang.String.format("Picked query
[%s
]", "QUERY_DATA
"));
50 final var rawQuery = QUERY_DATA_RAW;
51 final var index = QUERY_DATA_INDEX;
52 LOG.finer(() -> java.lang.String.format("Picked index
[%s
]", "QUERY_DATA_INDEX
"));
53 try (final var statement = connection.prepareStatement(query)) {
54 for (final int jdbcIndex : index.get("test
")) {
55 statement.setObject(jdbcIndex, test);
57 for (final int jdbcIndex : index.get("id
")) {
58 statement.setObject(jdbcIndex, id);
60 if (LOG.isLoggable(java.util.logging.Level.FINE)) {
61 final var executedQuery = rawQuery
62 .replace(":test
", test == null ? "null" : test.toString())
63 .replace(":id
", java.lang.String.valueOf(id));
64 LOG.fine(() -> java.lang.String.format("Executing query
[%s
]", executedQuery));
66 try (final var resultSet = statement.executeQuery()) {
67 final var list = new java.util.ArrayList<java.util.Map<java.lang.String, java.lang.Object>>();
68 while (resultSet.next()) {
69 list.add(toMap.apply(resultSet));
71 return list.size() > 0 ? java.util.Optional.of(list.get(0)) : java.util.Optional.empty();
75 catch (final java.sql.SQLException exception) {
76 throw new java.lang.RuntimeException(exception);
83 String
readMultipleMethodExpectation() {
86 * <p>Executes the following statement:</p>
88 * SELECT raw FROM table WHERE test = ? AND id = ?;</pre>
90 * <p>Generated based on the following file(s):</p>
92 * <li>data/queryData.sql</li>
94 * <p>Disable generating this method by setting <strong>generateStandardApi</strong> to <strong>false</strong></p>
96 @javax.annotation.processing.Generated(
98 comments = "DO NOT MODIFY
- automatically generated by YoSQL
"
100 public final java.util.List<java.util.Map<java.lang.String, java.lang.Object>> queryData(
101 final java.lang.Object test, final int id) {
102 LOG.entering("com
.example
.persistence
.DataRepository
", "queryData
");
103 try (final var connection = dataSource.getConnection()) {
104 final var query = QUERY_DATA;
105 LOG.finer(() -> java.lang.String.format("Picked query
[%s
]", "QUERY_DATA
"));
106 final var rawQuery = QUERY_DATA_RAW;
107 final var index = QUERY_DATA_INDEX;
108 LOG.finer(() -> java.lang.String.format("Picked index
[%s
]", "QUERY_DATA_INDEX
"));
109 try (final var statement = connection.prepareStatement(query)) {
110 for (final int jdbcIndex : index.get("test
")) {
111 statement.setObject(jdbcIndex, test);
113 for (final int jdbcIndex : index.get("id
")) {
114 statement.setObject(jdbcIndex, id);
116 if (LOG.isLoggable(java.util.logging.Level.FINE)) {
117 final var executedQuery = rawQuery
118 .replace(":test
", test == null ? "null" : test.toString())
119 .replace(":id
", java.lang.String.valueOf(id));
120 LOG.fine(() -> java.lang.String.format("Executing query
[%s
]", executedQuery));
122 try (final var resultSet = statement.executeQuery()) {
123 final var list = new java.util.ArrayList<java.util.Map<java.lang.String, java.lang.Object>>();
124 while (resultSet.next()) {
125 list.add(toMap.apply(resultSet));
131 catch (final java.sql.SQLException exception) {
132 throw new java.lang.RuntimeException(exception);
139 String
readCursorMethodExpectation() {
142 * <p>Executes the following statement:</p>
144 * SELECT raw FROM table WHERE test = ? AND id = ?;</pre>
146 * <p>Generated based on the following file(s):</p>
148 * <li>data/queryData.sql</li>
150 * <p>Disable generating this method by setting <strong>generateStandardApi</strong> to <strong>false</strong></p>
152 @javax.annotation.processing.Generated(
154 comments = "DO NOT MODIFY
- automatically generated by YoSQL
"
156 public final java.util.stream.Stream<java.util.Map<java.lang.String, java.lang.Object>> queryData(
157 final java.lang.Object test, final int id) {
158 LOG.entering("com
.example
.persistence
.DataRepository
", "queryData
");
160 final var connection = dataSource.getConnection();
161 final var query = QUERY_DATA;
162 LOG.finer(() -> java.lang.String.format("Picked query
[%s
]", "QUERY_DATA
"));
163 final var rawQuery = QUERY_DATA_RAW;
164 final var index = QUERY_DATA_INDEX;
165 LOG.finer(() -> java.lang.String.format("Picked index
[%s
]", "QUERY_DATA_INDEX
"));
166 final var statement = connection.prepareStatement(query);
167 for (final int jdbcIndex : index.get("test
")) {
168 statement.setObject(jdbcIndex, test);
170 for (final int jdbcIndex : index.get("id
")) {
171 statement.setObject(jdbcIndex, id);
173 if (LOG.isLoggable(java.util.logging.Level.FINE)) {
174 final var executedQuery = rawQuery
175 .replace(":test
", test == null ? "null" : test.toString())
176 .replace(":id
", java.lang.String.valueOf(id));
177 LOG.fine(() -> java.lang.String.format("Executing query
[%s
]", executedQuery));
179 final var resultSet = statement.executeQuery();
180 return java.util.stream.StreamSupport.stream(new java.util.Spliterators.AbstractSpliterator<java.util.Map<java.lang.String, java.lang.Object>>(java.lang.Long.MAX_VALUE, java.util.Spliterator.ORDERED) {
182 @javax.annotation.processing.Generated(
184 comments = "DO NOT MODIFY
- automatically generated by YoSQL
"
186 public final boolean tryAdvance(
187 final java.util.function.Consumer<? super java.util.Map<java.lang.String, java.lang.Object>> action) {
189 if (resultSet.next()) {
190 action.accept(toMap.apply(resultSet));
195 catch (final java.sql.SQLException exception) {
196 throw new java.lang.RuntimeException(exception);
199 }, false).onClose(new java.lang.Runnable() {
201 @javax.annotation.processing.Generated(
203 comments = "DO NOT MODIFY
- automatically generated by YoSQL
"
205 public final void run() {
211 catch (final java.sql.SQLException exception) {
212 throw new java.lang.RuntimeException(exception);
217 catch (final java.sql.SQLException exception) {
218 throw new java.lang.RuntimeException(exception);
225 String
readNoneMethodExpectation() {
228 * <p>Executes the following statement:</p>
230 * SELECT raw FROM table WHERE test = ? AND id = ?;</pre>
232 * <p>Generated based on the following file(s):</p>
234 * <li>data/queryData.sql</li>
236 * <p>Disable generating this method by setting <strong>generateStandardApi</strong> to <strong>false</strong></p>
238 @javax.annotation.processing.Generated(
240 comments = "DO NOT MODIFY
- automatically generated by YoSQL
"
242 public final void queryData(final java.lang.Object test, final int id) {
243 LOG.entering("com
.example
.persistence
.DataRepository
", "queryData
");
245 final var connection = dataSource.getConnection();
246 final var query = QUERY_DATA;
247 LOG.finer(() -> java.lang.String.format("Picked query
[%s
]", "QUERY_DATA
"));
248 final var rawQuery = QUERY_DATA_RAW;
249 final var index = QUERY_DATA_INDEX;
250 LOG.finer(() -> java.lang.String.format("Picked index
[%s
]", "QUERY_DATA_INDEX
"));
251 final var statement = connection.prepareStatement(query);
252 for (final int jdbcIndex : index.get("test
")) {
253 statement.setObject(jdbcIndex, test);
255 for (final int jdbcIndex : index.get("id
")) {
256 statement.setObject(jdbcIndex, id);
258 if (LOG.isLoggable(java.util.logging.Level.FINE)) {
259 final var executedQuery = rawQuery
260 .replace(":test
", test == null ? "null" : test.toString())
261 .replace(":id
", java.lang.String.valueOf(id));
262 LOG.fine(() -> java.lang.String.format("Executing query
[%s
]", executedQuery));
264 try (final var resultSet = statement.executeQuery()) {
266 catch (final java.sql.SQLException exception) {
267 throw new java.lang.RuntimeException(exception);
276 @DisplayName("using Java 11 configuration")
277 class Java11
extends ReadMethodGeneratorTCK
{
280 ReadMethodGenerator
generator() {
281 return DaoObjectMother
.readMethodGenerator(JavaConfigurations
.java11());
285 String
readSingleMethodExpectation() {
288 * <p>Executes the following statement:</p>
290 * SELECT raw FROM table WHERE test = ? AND id = ?;</pre>
292 * <p>Generated based on the following file(s):</p>
294 * <li>data/queryData.sql</li>
296 * <p>Disable generating this method by setting <strong>generateStandardApi</strong> to <strong>false</strong></p>
298 @javax.annotation.processing.Generated(
300 comments = "DO NOT MODIFY
- automatically generated by YoSQL
"
302 public final java.util.Optional<java.util.Map<java.lang.String, java.lang.Object>> queryData(
303 final java.lang.Object test, final int id) {
304 LOG.entering("com
.example
.persistence
.DataRepository
", "queryData
");
305 try (final var connection = dataSource.getConnection()) {
306 final var query = QUERY_DATA;
307 LOG.finer(() -> java.lang.String.format("Picked query
[%s
]", "QUERY_DATA
"));
308 final var rawQuery = QUERY_DATA_RAW;
309 final var index = QUERY_DATA_INDEX;
310 LOG.finer(() -> java.lang.String.format("Picked index
[%s
]", "QUERY_DATA_INDEX
"));
311 try (final var statement = connection.prepareStatement(query)) {
312 for (final int jdbcIndex : index.get("test
")) {
313 statement.setObject(jdbcIndex, test);
315 for (final int jdbcIndex : index.get("id
")) {
316 statement.setObject(jdbcIndex, id);
318 if (LOG.isLoggable(java.util.logging.Level.FINE)) {
319 final var executedQuery = rawQuery
320 .replace(":test
", test == null ? "null" : test.toString())
321 .replace(":id
", java.lang.String.valueOf(id));
322 LOG.fine(() -> java.lang.String.format("Executing query
[%s
]", executedQuery));
324 try (final var resultSet = statement.executeQuery()) {
325 final var list = new java.util.ArrayList<java.util.Map<java.lang.String, java.lang.Object>>();
326 while (resultSet.next()) {
327 list.add(toMap.apply(resultSet));
329 return list.size() > 0 ? java.util.Optional.of(list.get(0)) : java.util.Optional.empty();
333 catch (final java.sql.SQLException exception) {
334 throw new java.lang.RuntimeException(exception);
341 String
readMultipleMethodExpectation() {
344 * <p>Executes the following statement:</p>
346 * SELECT raw FROM table WHERE test = ? AND id = ?;</pre>
348 * <p>Generated based on the following file(s):</p>
350 * <li>data/queryData.sql</li>
352 * <p>Disable generating this method by setting <strong>generateStandardApi</strong> to <strong>false</strong></p>
354 @javax.annotation.processing.Generated(
356 comments = "DO NOT MODIFY
- automatically generated by YoSQL
"
358 public final java.util.List<java.util.Map<java.lang.String, java.lang.Object>> queryData(
359 final java.lang.Object test, final int id) {
360 LOG.entering("com
.example
.persistence
.DataRepository
", "queryData
");
361 try (final var connection = dataSource.getConnection()) {
362 final var query = QUERY_DATA;
363 LOG.finer(() -> java.lang.String.format("Picked query
[%s
]", "QUERY_DATA
"));
364 final var rawQuery = QUERY_DATA_RAW;
365 final var index = QUERY_DATA_INDEX;
366 LOG.finer(() -> java.lang.String.format("Picked index
[%s
]", "QUERY_DATA_INDEX
"));
367 try (final var statement = connection.prepareStatement(query)) {
368 for (final int jdbcIndex : index.get("test
")) {
369 statement.setObject(jdbcIndex, test);
371 for (final int jdbcIndex : index.get("id
")) {
372 statement.setObject(jdbcIndex, id);
374 if (LOG.isLoggable(java.util.logging.Level.FINE)) {
375 final var executedQuery = rawQuery
376 .replace(":test
", test == null ? "null" : test.toString())
377 .replace(":id
", java.lang.String.valueOf(id));
378 LOG.fine(() -> java.lang.String.format("Executing query
[%s
]", executedQuery));
380 try (final var resultSet = statement.executeQuery()) {
381 final var list = new java.util.ArrayList<java.util.Map<java.lang.String, java.lang.Object>>();
382 while (resultSet.next()) {
383 list.add(toMap.apply(resultSet));
389 catch (final java.sql.SQLException exception) {
390 throw new java.lang.RuntimeException(exception);
397 String
readCursorMethodExpectation() {
400 * <p>Executes the following statement:</p>
402 * SELECT raw FROM table WHERE test = ? AND id = ?;</pre>
404 * <p>Generated based on the following file(s):</p>
406 * <li>data/queryData.sql</li>
408 * <p>Disable generating this method by setting <strong>generateStandardApi</strong> to <strong>false</strong></p>
410 @javax.annotation.processing.Generated(
412 comments = "DO NOT MODIFY
- automatically generated by YoSQL
"
414 public final java.util.stream.Stream<java.util.Map<java.lang.String, java.lang.Object>> queryData(
415 final java.lang.Object test, final int id) {
416 LOG.entering("com
.example
.persistence
.DataRepository
", "queryData
");
418 final var connection = dataSource.getConnection();
419 final var query = QUERY_DATA;
420 LOG.finer(() -> java.lang.String.format("Picked query
[%s
]", "QUERY_DATA
"));
421 final var rawQuery = QUERY_DATA_RAW;
422 final var index = QUERY_DATA_INDEX;
423 LOG.finer(() -> java.lang.String.format("Picked index
[%s
]", "QUERY_DATA_INDEX
"));
424 final var statement = connection.prepareStatement(query);
425 for (final int jdbcIndex : index.get("test
")) {
426 statement.setObject(jdbcIndex, test);
428 for (final int jdbcIndex : index.get("id
")) {
429 statement.setObject(jdbcIndex, id);
431 if (LOG.isLoggable(java.util.logging.Level.FINE)) {
432 final var executedQuery = rawQuery
433 .replace(":test
", test == null ? "null" : test.toString())
434 .replace(":id
", java.lang.String.valueOf(id));
435 LOG.fine(() -> java.lang.String.format("Executing query
[%s
]", executedQuery));
437 final var resultSet = statement.executeQuery();
438 return java.util.stream.StreamSupport.stream(new java.util.Spliterators.AbstractSpliterator<java.util.Map<java.lang.String, java.lang.Object>>(java.lang.Long.MAX_VALUE, java.util.Spliterator.ORDERED) {
440 @javax.annotation.processing.Generated(
442 comments = "DO NOT MODIFY
- automatically generated by YoSQL
"
444 public final boolean tryAdvance(
445 final java.util.function.Consumer<? super java.util.Map<java.lang.String, java.lang.Object>> action) {
447 if (resultSet.next()) {
448 action.accept(toMap.apply(resultSet));
453 catch (final java.sql.SQLException exception) {
454 throw new java.lang.RuntimeException(exception);
457 }, false).onClose(new java.lang.Runnable() {
459 @javax.annotation.processing.Generated(
461 comments = "DO NOT MODIFY
- automatically generated by YoSQL
"
463 public final void run() {
469 catch (final java.sql.SQLException exception) {
470 throw new java.lang.RuntimeException(exception);
475 catch (final java.sql.SQLException exception) {
476 throw new java.lang.RuntimeException(exception);
483 String
readNoneMethodExpectation() {
486 * <p>Executes the following statement:</p>
488 * SELECT raw FROM table WHERE test = ? AND id = ?;</pre>
490 * <p>Generated based on the following file(s):</p>
492 * <li>data/queryData.sql</li>
494 * <p>Disable generating this method by setting <strong>generateStandardApi</strong> to <strong>false</strong></p>
496 @javax.annotation.processing.Generated(
498 comments = "DO NOT MODIFY
- automatically generated by YoSQL
"
500 public final void queryData(final java.lang.Object test, final int id) {
501 LOG.entering("com
.example
.persistence
.DataRepository
", "queryData
");
503 final var connection = dataSource.getConnection();
504 final var query = QUERY_DATA;
505 LOG.finer(() -> java.lang.String.format("Picked query
[%s
]", "QUERY_DATA
"));
506 final var rawQuery = QUERY_DATA_RAW;
507 final var index = QUERY_DATA_INDEX;
508 LOG.finer(() -> java.lang.String.format("Picked index
[%s
]", "QUERY_DATA_INDEX
"));
509 final var statement = connection.prepareStatement(query);
510 for (final int jdbcIndex : index.get("test
")) {
511 statement.setObject(jdbcIndex, test);
513 for (final int jdbcIndex : index.get("id
")) {
514 statement.setObject(jdbcIndex, id);
516 if (LOG.isLoggable(java.util.logging.Level.FINE)) {
517 final var executedQuery = rawQuery
518 .replace(":test
", test == null ? "null" : test.toString())
519 .replace(":id
", java.lang.String.valueOf(id));
520 LOG.fine(() -> java.lang.String.format("Executing query
[%s
]", executedQuery));
522 try (final var resultSet = statement.executeQuery()) {
524 catch (final java.sql.SQLException exception) {
525 throw new java.lang.RuntimeException(exception);
534 @DisplayName("using Java 14 configuration")
535 class Java14
extends ReadMethodGeneratorTCK
{
538 ReadMethodGenerator
generator() {
539 return DaoObjectMother
.readMethodGenerator(JavaConfigurations
.java14());
543 String
readSingleMethodExpectation() {
546 * <p>Executes the following statement:</p>
548 * SELECT raw FROM table WHERE test = ? AND id = ?;</pre>
550 * <p>Generated based on the following file(s):</p>
552 * <li>data/queryData.sql</li>
554 * <p>Disable generating this method by setting <strong>generateStandardApi</strong> to <strong>false</strong></p>
556 @javax.annotation.processing.Generated(
558 comments = "DO NOT MODIFY
- automatically generated by YoSQL
"
560 public final java.util.Optional<java.util.Map<java.lang.String, java.lang.Object>> queryData(
561 final java.lang.Object test, final int id) {
562 LOG.entering("com
.example
.persistence
.DataRepository
", "queryData
");
563 try (final var connection = dataSource.getConnection()) {
564 final var query = QUERY_DATA;
565 LOG.finer(() -> java.lang.String.format("Picked query
[%s
]", "QUERY_DATA
"));
566 final var rawQuery = QUERY_DATA_RAW;
567 final var index = QUERY_DATA_INDEX;
568 LOG.finer(() -> java.lang.String.format("Picked index
[%s
]", "QUERY_DATA_INDEX
"));
569 try (final var statement = connection.prepareStatement(query)) {
570 for (final int jdbcIndex : index.get("test
")) {
571 statement.setObject(jdbcIndex, test);
573 for (final int jdbcIndex : index.get("id
")) {
574 statement.setObject(jdbcIndex, id);
576 if (LOG.isLoggable(java.util.logging.Level.FINE)) {
577 final var executedQuery = rawQuery
578 .replace(":test
", test == null ? "null" : test.toString())
579 .replace(":id
", java.lang.String.valueOf(id));
580 LOG.fine(() -> java.lang.String.format("Executing query
[%s
]", executedQuery));
582 try (final var resultSet = statement.executeQuery()) {
583 final var list = new java.util.ArrayList<java.util.Map<java.lang.String, java.lang.Object>>();
584 while (resultSet.next()) {
585 list.add(toMap.apply(resultSet));
587 return list.size() > 0 ? java.util.Optional.of(list.get(0)) : java.util.Optional.empty();
591 catch (final java.sql.SQLException exception) {
592 throw new java.lang.RuntimeException(exception);
599 String
readMultipleMethodExpectation() {
602 * <p>Executes the following statement:</p>
604 * SELECT raw FROM table WHERE test = ? AND id = ?;</pre>
606 * <p>Generated based on the following file(s):</p>
608 * <li>data/queryData.sql</li>
610 * <p>Disable generating this method by setting <strong>generateStandardApi</strong> to <strong>false</strong></p>
612 @javax.annotation.processing.Generated(
614 comments = "DO NOT MODIFY
- automatically generated by YoSQL
"
616 public final java.util.List<java.util.Map<java.lang.String, java.lang.Object>> queryData(
617 final java.lang.Object test, final int id) {
618 LOG.entering("com
.example
.persistence
.DataRepository
", "queryData
");
619 try (final var connection = dataSource.getConnection()) {
620 final var query = QUERY_DATA;
621 LOG.finer(() -> java.lang.String.format("Picked query
[%s
]", "QUERY_DATA
"));
622 final var rawQuery = QUERY_DATA_RAW;
623 final var index = QUERY_DATA_INDEX;
624 LOG.finer(() -> java.lang.String.format("Picked index
[%s
]", "QUERY_DATA_INDEX
"));
625 try (final var statement = connection.prepareStatement(query)) {
626 for (final int jdbcIndex : index.get("test
")) {
627 statement.setObject(jdbcIndex, test);
629 for (final int jdbcIndex : index.get("id
")) {
630 statement.setObject(jdbcIndex, id);
632 if (LOG.isLoggable(java.util.logging.Level.FINE)) {
633 final var executedQuery = rawQuery
634 .replace(":test
", test == null ? "null" : test.toString())
635 .replace(":id
", java.lang.String.valueOf(id));
636 LOG.fine(() -> java.lang.String.format("Executing query
[%s
]", executedQuery));
638 try (final var resultSet = statement.executeQuery()) {
639 final var list = new java.util.ArrayList<java.util.Map<java.lang.String, java.lang.Object>>();
640 while (resultSet.next()) {
641 list.add(toMap.apply(resultSet));
647 catch (final java.sql.SQLException exception) {
648 throw new java.lang.RuntimeException(exception);
655 String
readCursorMethodExpectation() {
658 * <p>Executes the following statement:</p>
660 * SELECT raw FROM table WHERE test = ? AND id = ?;</pre>
662 * <p>Generated based on the following file(s):</p>
664 * <li>data/queryData.sql</li>
666 * <p>Disable generating this method by setting <strong>generateStandardApi</strong> to <strong>false</strong></p>
668 @javax.annotation.processing.Generated(
670 comments = "DO NOT MODIFY
- automatically generated by YoSQL
"
672 public final java.util.stream.Stream<java.util.Map<java.lang.String, java.lang.Object>> queryData(
673 final java.lang.Object test, final int id) {
674 LOG.entering("com
.example
.persistence
.DataRepository
", "queryData
");
676 final var connection = dataSource.getConnection();
677 final var query = QUERY_DATA;
678 LOG.finer(() -> java.lang.String.format("Picked query
[%s
]", "QUERY_DATA
"));
679 final var rawQuery = QUERY_DATA_RAW;
680 final var index = QUERY_DATA_INDEX;
681 LOG.finer(() -> java.lang.String.format("Picked index
[%s
]", "QUERY_DATA_INDEX
"));
682 final var statement = connection.prepareStatement(query);
683 for (final int jdbcIndex : index.get("test
")) {
684 statement.setObject(jdbcIndex, test);
686 for (final int jdbcIndex : index.get("id
")) {
687 statement.setObject(jdbcIndex, id);
689 if (LOG.isLoggable(java.util.logging.Level.FINE)) {
690 final var executedQuery = rawQuery
691 .replace(":test
", test == null ? "null" : test.toString())
692 .replace(":id
", java.lang.String.valueOf(id));
693 LOG.fine(() -> java.lang.String.format("Executing query
[%s
]", executedQuery));
695 final var resultSet = statement.executeQuery();
696 return java.util.stream.StreamSupport.stream(new java.util.Spliterators.AbstractSpliterator<java.util.Map<java.lang.String, java.lang.Object>>(java.lang.Long.MAX_VALUE, java.util.Spliterator.ORDERED) {
698 @javax.annotation.processing.Generated(
700 comments = "DO NOT MODIFY
- automatically generated by YoSQL
"
702 public final boolean tryAdvance(
703 final java.util.function.Consumer<? super java.util.Map<java.lang.String, java.lang.Object>> action) {
705 if (resultSet.next()) {
706 action.accept(toMap.apply(resultSet));
711 catch (final java.sql.SQLException exception) {
712 throw new java.lang.RuntimeException(exception);
715 }, false).onClose(new java.lang.Runnable() {
717 @javax.annotation.processing.Generated(
719 comments = "DO NOT MODIFY
- automatically generated by YoSQL
"
721 public final void run() {
727 catch (final java.sql.SQLException exception) {
728 throw new java.lang.RuntimeException(exception);
733 catch (final java.sql.SQLException exception) {
734 throw new java.lang.RuntimeException(exception);
741 String
readNoneMethodExpectation() {
744 * <p>Executes the following statement:</p>
746 * SELECT raw FROM table WHERE test = ? AND id = ?;</pre>
748 * <p>Generated based on the following file(s):</p>
750 * <li>data/queryData.sql</li>
752 * <p>Disable generating this method by setting <strong>generateStandardApi</strong> to <strong>false</strong></p>
754 @javax.annotation.processing.Generated(
756 comments = "DO NOT MODIFY
- automatically generated by YoSQL
"
758 public final void queryData(final java.lang.Object test, final int id) {
759 LOG.entering("com
.example
.persistence
.DataRepository
", "queryData
");
761 final var connection = dataSource.getConnection();
762 final var query = QUERY_DATA;
763 LOG.finer(() -> java.lang.String.format("Picked query
[%s
]", "QUERY_DATA
"));
764 final var rawQuery = QUERY_DATA_RAW;
765 final var index = QUERY_DATA_INDEX;
766 LOG.finer(() -> java.lang.String.format("Picked index
[%s
]", "QUERY_DATA_INDEX
"));
767 final var statement = connection.prepareStatement(query);
768 for (final int jdbcIndex : index.get("test
")) {
769 statement.setObject(jdbcIndex, test);
771 for (final int jdbcIndex : index.get("id
")) {
772 statement.setObject(jdbcIndex, id);
774 if (LOG.isLoggable(java.util.logging.Level.FINE)) {
775 final var executedQuery = rawQuery
776 .replace(":test
", test == null ? "null" : test.toString())
777 .replace(":id
", java.lang.String.valueOf(id));
778 LOG.fine(() -> java.lang.String.format("Executing query
[%s
]", executedQuery));
780 try (final var resultSet = statement.executeQuery()) {
782 catch (final java.sql.SQLException exception) {
783 throw new java.lang.RuntimeException(exception);
792 @DisplayName("using Java 16 configuration")
793 class Java16
extends ReadMethodGeneratorTCK
{
796 ReadMethodGenerator
generator() {
797 return DaoObjectMother
.readMethodGenerator(JavaConfigurations
.java16());
801 String
readSingleMethodExpectation() {
804 * <p>Executes the following statement:</p>
806 * SELECT raw FROM table WHERE test = ? AND id = ?;</pre>
808 * <p>Generated based on the following file(s):</p>
810 * <li>data/queryData.sql</li>
812 * <p>Disable generating this method by setting <strong>generateStandardApi</strong> to <strong>false</strong></p>
814 @javax.annotation.processing.Generated(
816 comments = "DO NOT MODIFY
- automatically generated by YoSQL
"
818 public final java.util.Optional<java.util.Map<java.lang.String, java.lang.Object>> queryData(
819 final java.lang.Object test, final int id) {
820 LOG.entering("com
.example
.persistence
.DataRepository
", "queryData
");
821 try (final var connection = dataSource.getConnection()) {
822 final var query = QUERY_DATA;
823 LOG.finer(() -> java.lang.String.format("Picked query
[%s
]", "QUERY_DATA
"));
824 final var rawQuery = QUERY_DATA_RAW;
825 final var index = QUERY_DATA_INDEX;
826 LOG.finer(() -> java.lang.String.format("Picked index
[%s
]", "QUERY_DATA_INDEX
"));
827 try (final var statement = connection.prepareStatement(query)) {
828 for (final int jdbcIndex : index.get("test
")) {
829 statement.setObject(jdbcIndex, test);
831 for (final int jdbcIndex : index.get("id
")) {
832 statement.setObject(jdbcIndex, id);
834 if (LOG.isLoggable(java.util.logging.Level.FINE)) {
835 final var executedQuery = rawQuery
836 .replace(":test
", test == null ? "null" : test.toString())
837 .replace(":id
", java.lang.String.valueOf(id));
838 LOG.fine(() -> java.lang.String.format("Executing query
[%s
]", executedQuery));
840 try (final var resultSet = statement.executeQuery()) {
841 final var list = new java.util.ArrayList<java.util.Map<java.lang.String, java.lang.Object>>();
842 while (resultSet.next()) {
843 list.add(toMap.apply(resultSet));
845 return list.size() > 0 ? java.util.Optional.of(list.get(0)) : java.util.Optional.empty();
849 catch (final java.sql.SQLException exception) {
850 throw new java.lang.RuntimeException(exception);
857 String
readMultipleMethodExpectation() {
860 * <p>Executes the following statement:</p>
862 * SELECT raw FROM table WHERE test = ? AND id = ?;</pre>
864 * <p>Generated based on the following file(s):</p>
866 * <li>data/queryData.sql</li>
868 * <p>Disable generating this method by setting <strong>generateStandardApi</strong> to <strong>false</strong></p>
870 @javax.annotation.processing.Generated(
872 comments = "DO NOT MODIFY
- automatically generated by YoSQL
"
874 public final java.util.List<java.util.Map<java.lang.String, java.lang.Object>> queryData(
875 final java.lang.Object test, final int id) {
876 LOG.entering("com
.example
.persistence
.DataRepository
", "queryData
");
877 try (final var connection = dataSource.getConnection()) {
878 final var query = QUERY_DATA;
879 LOG.finer(() -> java.lang.String.format("Picked query
[%s
]", "QUERY_DATA
"));
880 final var rawQuery = QUERY_DATA_RAW;
881 final var index = QUERY_DATA_INDEX;
882 LOG.finer(() -> java.lang.String.format("Picked index
[%s
]", "QUERY_DATA_INDEX
"));
883 try (final var statement = connection.prepareStatement(query)) {
884 for (final int jdbcIndex : index.get("test
")) {
885 statement.setObject(jdbcIndex, test);
887 for (final int jdbcIndex : index.get("id
")) {
888 statement.setObject(jdbcIndex, id);
890 if (LOG.isLoggable(java.util.logging.Level.FINE)) {
891 final var executedQuery = rawQuery
892 .replace(":test
", test == null ? "null" : test.toString())
893 .replace(":id
", java.lang.String.valueOf(id));
894 LOG.fine(() -> java.lang.String.format("Executing query
[%s
]", executedQuery));
896 try (final var resultSet = statement.executeQuery()) {
897 final var list = new java.util.ArrayList<java.util.Map<java.lang.String, java.lang.Object>>();
898 while (resultSet.next()) {
899 list.add(toMap.apply(resultSet));
905 catch (final java.sql.SQLException exception) {
906 throw new java.lang.RuntimeException(exception);
913 String
readCursorMethodExpectation() {
916 * <p>Executes the following statement:</p>
918 * SELECT raw FROM table WHERE test = ? AND id = ?;</pre>
920 * <p>Generated based on the following file(s):</p>
922 * <li>data/queryData.sql</li>
924 * <p>Disable generating this method by setting <strong>generateStandardApi</strong> to <strong>false</strong></p>
926 @javax.annotation.processing.Generated(
928 comments = "DO NOT MODIFY
- automatically generated by YoSQL
"
930 public final java.util.stream.Stream<java.util.Map<java.lang.String, java.lang.Object>> queryData(
931 final java.lang.Object test, final int id) {
932 LOG.entering("com
.example
.persistence
.DataRepository
", "queryData
");
934 final var connection = dataSource.getConnection();
935 final var query = QUERY_DATA;
936 LOG.finer(() -> java.lang.String.format("Picked query
[%s
]", "QUERY_DATA
"));
937 final var rawQuery = QUERY_DATA_RAW;
938 final var index = QUERY_DATA_INDEX;
939 LOG.finer(() -> java.lang.String.format("Picked index
[%s
]", "QUERY_DATA_INDEX
"));
940 final var statement = connection.prepareStatement(query);
941 for (final int jdbcIndex : index.get("test
")) {
942 statement.setObject(jdbcIndex, test);
944 for (final int jdbcIndex : index.get("id
")) {
945 statement.setObject(jdbcIndex, id);
947 if (LOG.isLoggable(java.util.logging.Level.FINE)) {
948 final var executedQuery = rawQuery
949 .replace(":test
", test == null ? "null" : test.toString())
950 .replace(":id
", java.lang.String.valueOf(id));
951 LOG.fine(() -> java.lang.String.format("Executing query
[%s
]", executedQuery));
953 final var resultSet = statement.executeQuery();
954 return java.util.stream.StreamSupport.stream(new java.util.Spliterators.AbstractSpliterator<java.util.Map<java.lang.String, java.lang.Object>>(java.lang.Long.MAX_VALUE, java.util.Spliterator.ORDERED) {
956 @javax.annotation.processing.Generated(
958 comments = "DO NOT MODIFY
- automatically generated by YoSQL
"
960 public final boolean tryAdvance(
961 final java.util.function.Consumer<? super java.util.Map<java.lang.String, java.lang.Object>> action) {
963 if (resultSet.next()) {
964 action.accept(toMap.apply(resultSet));
969 catch (final java.sql.SQLException exception) {
970 throw new java.lang.RuntimeException(exception);
973 }, false).onClose(new java.lang.Runnable() {
975 @javax.annotation.processing.Generated(
977 comments = "DO NOT MODIFY
- automatically generated by YoSQL
"
979 public final void run() {
985 catch (final java.sql.SQLException exception) {
986 throw new java.lang.RuntimeException(exception);
991 catch (final java.sql.SQLException exception) {
992 throw new java.lang.RuntimeException(exception);
999 String
readNoneMethodExpectation() {
1002 * <p>Executes the following statement:</p>
1004 * SELECT raw FROM table WHERE test = ? AND id = ?;</pre>
1006 * <p>Generated based on the following file(s):</p>
1008 * <li>data/queryData.sql</li>
1010 * <p>Disable generating this method by setting <strong>generateStandardApi</strong> to <strong>false</strong></p>
1012 @javax.annotation.processing.Generated(
1014 comments = "DO NOT MODIFY
- automatically generated by YoSQL
"
1016 public final void queryData(final java.lang.Object test, final int id) {
1017 LOG.entering("com
.example
.persistence
.DataRepository
", "queryData
");
1019 final var connection = dataSource.getConnection();
1020 final var query = QUERY_DATA;
1021 LOG.finer(() -> java.lang.String.format("Picked query
[%s
]", "QUERY_DATA
"));
1022 final var rawQuery = QUERY_DATA_RAW;
1023 final var index = QUERY_DATA_INDEX;
1024 LOG.finer(() -> java.lang.String.format("Picked index
[%s
]", "QUERY_DATA_INDEX
"));
1025 final var statement = connection.prepareStatement(query);
1026 for (final int jdbcIndex : index.get("test
")) {
1027 statement.setObject(jdbcIndex, test);
1029 for (final int jdbcIndex : index.get("id
")) {
1030 statement.setObject(jdbcIndex, id);
1032 if (LOG.isLoggable(java.util.logging.Level.FINE)) {
1033 final var executedQuery = rawQuery
1034 .replace(":test
", test == null ? "null" : test.toString())
1035 .replace(":id
", java.lang.String.valueOf(id));
1036 LOG.fine(() -> java.lang.String.format("Executing query
[%s
]", executedQuery));
1038 try (final var resultSet = statement.executeQuery()) {
1040 catch (final java.sql.SQLException exception) {
1041 throw new java.lang.RuntimeException(exception);