@author Lukas Eder
| 81 | * @author Lukas Eder |
| 82 | */ |
| 83 | final class BatchSingle extends AbstractBatch implements BatchBindStep { |
| 84 | private static final JooqLogger log = JooqLogger.getLogger(BatchSingle.class); |
| 85 | |
| 86 | final Query query; |
| 87 | final Map<String, List<Integer>> nameToIndexMapping; |
| 88 | final List<Object[]> allBindValues; |
| 89 | final int expectedBindValues; |
| 90 | transient List<Object> defaultValues; |
| 91 | |
| 92 | public BatchSingle(Configuration configuration, Query query) { |
| 93 | super(configuration); |
| 94 | |
| 95 | int i = 0; |
| 96 | |
| 97 | ParamCollector collector = new ParamCollector(configuration, false); |
| 98 | collector.visit(query); |
| 99 | |
| 100 | this.query = query; |
| 101 | this.allBindValues = new ArrayList<>(); |
| 102 | this.nameToIndexMapping = new LinkedHashMap<>(); |
| 103 | this.expectedBindValues = collector.resultList.size(); |
| 104 | |
| 105 | for (Entry<String, Param<?>> entry : collector.resultList) |
| 106 | nameToIndexMapping.computeIfAbsent(entry.getKey(), e -> new ArrayList<>()).add(i++); |
| 107 | } |
| 108 | |
| 109 | @Override |
| 110 | public final BatchSingle bind(Object... bindValues) { |
| 111 | allBindValues.add(bindValues); |
| 112 | return this; |
| 113 | } |
| 114 | |
| 115 | @Override |
| 116 | public final BatchSingle bind(Object[]... bindValues) { |
| 117 | for (Object[] v : bindValues) |
| 118 | bind(v); |
| 119 | |
| 120 | return this; |
| 121 | } |
| 122 | |
| 123 | @SuppressWarnings("unchecked") |
| 124 | @Override |
| 125 | public final BatchSingle bind(Map<String, Object> namedBindValues) { |
| 126 | return bind(new Map[] { namedBindValues }); |
| 127 | } |
| 128 | |
| 129 | @Override |
| 130 | @SafeVarargs |
| 131 | public final BatchSingle bind(Map<String, Object>... namedBindValues) { |
| 132 | if (defaultValues == null) { |
| 133 | defaultValues = dsl.extractBindValues(query); |
| 134 | } |
| 135 | |
| 136 | Object[][] bindValues = new Object[namedBindValues.length][]; |
| 137 | for (int i = 0; i < bindValues.length; i++) { |
| 138 | Object[] row = bindValues[i] = defaultValues.toArray(); |
| 139 | |
| 140 | namedBindValues[i].forEach((k, v) -> { |
nothing calls this directly
no test coverage detected
searching dependent graphs…