1
1
/*
2
- * Copyright 2002-2024 the original author or authors.
2
+ * Copyright 2002-2025 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -513,14 +513,50 @@ private static class ExpandedQuery implements PreparedOperation<String> {
513
513
514
514
private final BindParameterSource parameterSource ;
515
515
516
+
516
517
ExpandedQuery (String expandedSql , NamedParameters parameters , BindParameterSource parameterSource ) {
517
518
this .expandedSql = expandedSql ;
518
519
this .parameters = parameters ;
519
520
this .parameterSource = parameterSource ;
520
521
}
521
522
523
+
524
+ @ Override
525
+ public String toQuery () {
526
+ return this .expandedSql ;
527
+ }
528
+
529
+ @ Override
530
+ public String getSource () {
531
+ return this .expandedSql ;
532
+ }
533
+
534
+ @ Override
535
+ public void bindTo (BindTarget target ) {
536
+ for (String namedParameter : this .parameterSource .getParameterNames ()) {
537
+ Parameter parameter = this .parameterSource .getValue (namedParameter );
538
+ if (parameter .getValue () == null ) {
539
+ bindNull (target , namedParameter , parameter );
540
+ }
541
+ else {
542
+ bind (target , namedParameter , parameter );
543
+ }
544
+ }
545
+ }
546
+
547
+ private void bindNull (BindTarget target , String identifier , Parameter parameter ) {
548
+ List <BindMarker > bindMarkers = getBindMarkers (identifier );
549
+ if (bindMarkers == null ) {
550
+ target .bind (identifier , parameter );
551
+ return ;
552
+ }
553
+ for (BindMarker bindMarker : bindMarkers ) {
554
+ bindMarker .bind (target , parameter );
555
+ }
556
+ }
557
+
522
558
@ SuppressWarnings ({"rawtypes" , "unchecked" })
523
- public void bind (BindTarget target , String identifier , Parameter parameter ) {
559
+ private void bind (BindTarget target , String identifier , Parameter parameter ) {
524
560
List <BindMarker > bindMarkers = getBindMarkers (identifier );
525
561
if (bindMarkers == null ) {
526
562
target .bind (identifier , parameter );
@@ -555,19 +591,8 @@ private void bind(BindTarget target, Iterator<BindMarker> markers, Object valueT
555
591
markers .next ().bind (target , valueToBind );
556
592
}
557
593
558
- public void bindNull (BindTarget target , String identifier , Parameter parameter ) {
559
- List <BindMarker > bindMarkers = getBindMarkers (identifier );
560
- if (bindMarkers == null ) {
561
- target .bind (identifier , parameter );
562
- return ;
563
- }
564
- for (BindMarker bindMarker : bindMarkers ) {
565
- bindMarker .bind (target , parameter );
566
- }
567
- }
568
-
569
594
@ Nullable
570
- List <BindMarker > getBindMarkers (String identifier ) {
595
+ private List <BindMarker > getBindMarkers (String identifier ) {
571
596
List <NamedParameters .NamedParameter > parameters = this .parameters .getMarker (identifier );
572
597
if (parameters == null ) {
573
598
return null ;
@@ -579,28 +604,6 @@ List<BindMarker> getBindMarkers(String identifier) {
579
604
return markers ;
580
605
}
581
606
582
- @ Override
583
- public String getSource () {
584
- return this .expandedSql ;
585
- }
586
-
587
- @ Override
588
- public void bindTo (BindTarget target ) {
589
- for (String namedParameter : this .parameterSource .getParameterNames ()) {
590
- Parameter parameter = this .parameterSource .getValue (namedParameter );
591
- if (parameter .getValue () == null ) {
592
- bindNull (target , namedParameter , parameter );
593
- }
594
- else {
595
- bind (target , namedParameter , parameter );
596
- }
597
- }
598
- }
599
-
600
- @ Override
601
- public String toQuery () {
602
- return this .expandedSql ;
603
- }
604
607
}
605
608
606
609
}
0 commit comments