Commit 6cea5cb
authored
* Support multi-row execute() without key return in JPA inserts
Previously addRow() only produced a multi-row INSERT when keys were
returned via executeWithKeys(); a plain execute() ignored the
accumulated rows and inserted only the trailing row.
- execute() now emits a single native INSERT INTO t (...) VALUES
(..),(..),... when rows were accumulated via addRow(), in both
JPAInsertClause and HibernateInsertClause; a trailing un-flushed row
is treated as the last row (loop-friendly, no first-row bookkeeping).
- Add JpaInsertNativeHelper.requireSqlModule(): the native insert paths
depend on the optional querydsl-sql module, so guard them with an
actionable IllegalStateException instead of a bare NoClassDefFoundError
when querydsl-sql is absent from the classpath.
- Clarify addRow() Javadoc: it builds a single multi-row VALUES
statement, not JDBC batching.
* Capture column paths in addRow() for loop-friendly multi-row inserts (#1825)
set()-style + a trailing addRow() at the end of every loop iteration left
both the inserts map and the columns list empty after the loop, so executors
threw "No columns specified for insert". Callers had to keep a "first row"
flag and intentionally leave the last row in the buffer to recover the
column list from inserts.keySet().
addRow() now captures the effective column paths on its first call.
executeMultiRow() and executeWithKeys() fall back to those captured paths
when the current-state inserts/columns are empty.
Combined with the prior change that routes execute() to a native multi-row
INSERT when rows were accumulated, the loop-friendly shape
for (var r : rows) { insert.set(...).set(...).addRow(); }
insert.execute(); // or executeWithKeys(...) when keys are needed
now works for both JPAInsertClause and HibernateInsertClause with no
first-row bookkeeping and no buffer-retention trick.
1 parent 0cb1f12 commit 6cea5cb
5 files changed
Lines changed: 307 additions & 4 deletions
File tree
- querydsl-libraries/querydsl-jpa/src
- main/java/com/querydsl/jpa
- hibernate
- impl
- test/java/com/querydsl/jpa
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
41 | 64 | | |
42 | 65 | | |
43 | 66 | | |
| |||
Lines changed: 74 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
64 | 72 | | |
65 | 73 | | |
66 | 74 | | |
| |||
90 | 98 | | |
91 | 99 | | |
92 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
93 | 107 | | |
94 | 108 | | |
95 | 109 | | |
| |||
116 | 130 | | |
117 | 131 | | |
118 | 132 | | |
| 133 | + | |
119 | 134 | | |
120 | 135 | | |
121 | 136 | | |
| |||
134 | 149 | | |
135 | 150 | | |
136 | 151 | | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
137 | 196 | | |
138 | 197 | | |
139 | 198 | | |
| |||
202 | 261 | | |
203 | 262 | | |
204 | 263 | | |
| 264 | + | |
205 | 265 | | |
206 | 266 | | |
207 | 267 | | |
| |||
222 | 282 | | |
223 | 283 | | |
224 | 284 | | |
225 | | - | |
226 | | - | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
227 | 292 | | |
228 | 293 | | |
229 | 294 | | |
| |||
236 | 301 | | |
237 | 302 | | |
238 | 303 | | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
239 | 307 | | |
240 | 308 | | |
241 | 309 | | |
| |||
275 | 343 | | |
276 | 344 | | |
277 | 345 | | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
278 | 349 | | |
279 | 350 | | |
280 | 351 | | |
| |||
289 | 360 | | |
290 | 361 | | |
291 | 362 | | |
| 363 | + | |
292 | 364 | | |
293 | 365 | | |
294 | 366 | | |
| |||
Lines changed: 71 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
59 | 67 | | |
60 | 68 | | |
61 | 69 | | |
| |||
76 | 84 | | |
77 | 85 | | |
78 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
79 | 93 | | |
80 | 94 | | |
81 | 95 | | |
| |||
101 | 115 | | |
102 | 116 | | |
103 | 117 | | |
| 118 | + | |
104 | 119 | | |
105 | 120 | | |
106 | 121 | | |
| |||
118 | 133 | | |
119 | 134 | | |
120 | 135 | | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
121 | 177 | | |
122 | 178 | | |
123 | 179 | | |
| |||
187 | 243 | | |
188 | 244 | | |
189 | 245 | | |
| 246 | + | |
190 | 247 | | |
191 | 248 | | |
192 | 249 | | |
| |||
208 | 265 | | |
209 | 266 | | |
210 | 267 | | |
211 | | - | |
212 | | - | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
213 | 275 | | |
214 | 276 | | |
215 | 277 | | |
| |||
222 | 284 | | |
223 | 285 | | |
224 | 286 | | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
225 | 290 | | |
226 | 291 | | |
227 | 292 | | |
| |||
261 | 326 | | |
262 | 327 | | |
263 | 328 | | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
264 | 332 | | |
265 | 333 | | |
266 | 334 | | |
| |||
275 | 343 | | |
276 | 344 | | |
277 | 345 | | |
| 346 | + | |
278 | 347 | | |
279 | 348 | | |
280 | 349 | | |
| |||
Lines changed: 69 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
229 | 298 | | |
230 | 299 | | |
231 | 300 | | |
| |||
0 commit comments