Skip to content

Commit b95cb06

Browse files
author
mhyeon-lee
committed
DATAJDBC-498 Add afterFromTable method to SelectRenderContext for Postgres lock hint
1 parent cbffe9a commit b95cb06

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/render/SelectRenderContext.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
* element without further whitespace processing. Hooks are responsible for adding required surrounding whitespaces.
2626
*
2727
* @author Mark Paluch
28+
* @author Myeonghyeon Lee
2829
* @since 1.1
2930
*/
3031
public interface SelectRenderContext {
@@ -39,6 +40,16 @@ public interface SelectRenderContext {
3940
return select -> "";
4041
}
4142

43+
/**
44+
* Customization hook: Rendition of a part after {@code FROM} table.
45+
* Renders an empty string by default.
46+
*
47+
* @return render {@link Function} invoked after rendering {@code FROM} table.
48+
*/
49+
default Function<Select, ? extends CharSequence> afterFromTable() {
50+
return select -> "";
51+
}
52+
4253
/**
4354
* Customization hook: Rendition of a part after {@code ORDER BY}. The rendering function is called always, regardless
4455
* whether {@code ORDER BY} exists or not. Renders an empty string by default.

spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/render/SelectStatementVisitor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
*
2929
* @author Mark Paluch
3030
* @author Jens Schauder
31+
* @author Myeonghyeon Lee
3132
* @since 1.1
3233
*/
3334
class SelectStatementVisitor extends DelegatingVisitor implements PartRenderer {
@@ -125,6 +126,8 @@ public Delegation doLeave(Visitable segment) {
125126
builder.append(" FROM ").append(from);
126127
}
127128

129+
builder.append(selectRenderContext.afterFromTable().apply(select));
130+
128131
if (join.length() != 0) {
129132
builder.append(' ').append(join);
130133
}

0 commit comments

Comments
 (0)