Skip to content

Commit 56ffbc1

Browse files
committed
document @DialectOverride
1 parent 47d8a63 commit 56ffbc1

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

documentation/src/main/asciidoc/introduction/Advanced.adoc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,19 @@ However, the `@Column` annotation does lend some flexibility here:
221221
- if a column should not be written as part of the custom `insert` statement, and has no corresponding JDBC parameter in the custom SQL, map it `@Column(insertable=false)`, or
222222
- if a column should not be written as part of the custom `update` statement, and has no corresponding JDBC parameter in the custom SQL, map it `@Column(updatable=false)`.
223223

224+
[TIP]
225+
====
226+
If you need custom SQL, but are targeting multiple dialects of SQL, you can use the annotations defined in `DialectOverrides`.
227+
For example, this annotation lets us override the custom `insert` statement just for PostgreSQL:
228+
229+
[source,java]
230+
----
231+
@DialectOverride.SQLInsert(dialect = PostgreSQLDialect.class,
232+
override = @SQLInsert(sql="insert into person (name,id) values (?,gen_random_uuid())"))
233+
----
234+
It's even possible to override the custom SQL for specific _versions_ of a database.
235+
====
236+
224237
Sometimes a custom `insert` or `update` statement assigns a value to a mapped column which is calculated when the statement is executed on the database.
225238
For example, the value might be obtained by calling a SQL function:
226239

0 commit comments

Comments
 (0)