|
36 | 36 | public abstract class RenderingStrategy {
|
37 | 37 | public static final String DEFAULT_PARAMETER_PREFIX = "parameters"; //$NON-NLS-1$
|
38 | 38 |
|
| 39 | + /** |
| 40 | + * Return a unique key that can be used to place a parameter value in the parameter map |
| 41 | + * |
| 42 | + * @param sequence a sequence for calculating a unique value |
| 43 | + * @return a key used to place the parameter value in the parameter map |
| 44 | + */ |
39 | 45 | public String formatParameterMapKey(AtomicInteger sequence) {
|
40 | 46 | return "p" + sequence.getAndIncrement(); //$NON-NLS-1$
|
41 | 47 | }
|
42 | 48 |
|
| 49 | + /** |
| 50 | + * Return a parameter map key intended as a parameter for a limit or fetch first query. |
| 51 | + * |
| 52 | + * <p>By default, this parameter is treated the same as any other. This method is a hook to support |
| 53 | + * MyBatis Spring Batch. |
| 54 | + * |
| 55 | + * @param sequence a sequence for calculating a unique value |
| 56 | + * @return a key used to place the parameter value in the parameter map |
| 57 | + */ |
43 | 58 | public String formatParameterMapKeyForLimit(AtomicInteger sequence) {
|
44 | 59 | return formatParameterMapKey(sequence);
|
45 | 60 | }
|
46 | 61 |
|
| 62 | + /** |
| 63 | + * Return a parameter map key intended as a parameter for a query offset. |
| 64 | + * |
| 65 | + * <p>By default, this parameter is treated the same as any other. This method is a hook to support |
| 66 | + * MyBatis Spring Batch. |
| 67 | + * |
| 68 | + * @param sequence a sequence for calculating a unique value |
| 69 | + * @return a key used to place the parameter value in the parameter map |
| 70 | + */ |
47 | 71 | public String formatParameterMapKeyForOffset(AtomicInteger sequence) {
|
48 | 72 | return formatParameterMapKey(sequence);
|
49 | 73 | }
|
@@ -86,6 +110,19 @@ public String formatParameterMapKeyForOffset(AtomicInteger sequence) {
|
86 | 110 | */
|
87 | 111 | public abstract String getFormattedJdbcPlaceholder(String prefix, String parameterName);
|
88 | 112 |
|
| 113 | + /** |
| 114 | + * This method generates a binding for a parameter to a placeholder in a generated SQL statement. |
| 115 | + * |
| 116 | + * <p>This method is used to generate bindings for limit, offset, and fetch first parameters. By default, these |
| 117 | + * parameters are treated the same as any other. This method supports MyBatis Spring Batch integration where the |
| 118 | + * parameter keys have predefined values and need special handling. |
| 119 | + * |
| 120 | + * @param prefix parameter prefix used for locating the parameters in a SQL provider object. Typically, will be |
| 121 | + * {@link RenderingStrategy#DEFAULT_PARAMETER_PREFIX}. This is ignored for Spring. |
| 122 | + * @param parameterName name of the parameter. Typically generated by calling |
| 123 | + * {@link RenderingStrategy#formatParameterMapKey(AtomicInteger)} |
| 124 | + * @return the generated binding |
| 125 | + */ |
89 | 126 | public String getFormattedJdbcPlaceholderForLimitOrOffset(String prefix, String parameterName) {
|
90 | 127 | return getFormattedJdbcPlaceholder(prefix, parameterName);
|
91 | 128 | }
|
|
0 commit comments