Skip to content

Commit c698b8a

Browse files
committed
clarify that @generated does not always require a separate select statement
Signed-off-by: Gavin King <[email protected]>
1 parent 2eeb615 commit c698b8a

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

hibernate-core/src/main/java/org/hibernate/annotations/Generated.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,21 @@
1717

1818
/**
1919
* Specifies that the value of the annotated property is generated by the
20-
* database. The generated value will be automatically retrieved using a
21-
* SQL {@code select} after it is generated.
20+
* database. The generated value is automatically retrieved after it is
21+
* generated.
22+
* <p>
23+
* Retrieval of the generated value might require an additional SQL
24+
* {@code select} statement, but this not necessary if:
25+
* <ul>
26+
* <li>
27+
* the SQL dialect of the database
28+
* {@linkplain org.hibernate.dialect.Dialect#supportsInsertReturning
29+
* supports} {@code returning} or {@code select from final table}, or
30+
* <li>
31+
* the JDBC driver
32+
* {@linkplain org.hibernate.dialect.Dialect#supportsInsertReturningGeneratedKeys
33+
* provides} a similar capability via {@code getGeneratedKeys()}.
34+
* </ul>
2235
* <p>
2336
* {@code @Generated} relieves the program of the need to explicitly call
2437
* {@link org.hibernate.Session#refresh(Object) refresh()} to synchronize

hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4242,8 +4242,8 @@ public boolean supportsSubqueryInSelect() {
42424242
* <p>
42434243
* Support for identity columns is insufficient here, we require something like:
42444244
* <ol>
4245-
* <li>{@code insert ... returning ...}
4246-
* <li>{@code select from final table (insert ... )}
4245+
* <li>{@code insert ... returning ...}, or
4246+
* <li>{@code select from final table (insert ... )}.
42474247
* </ol>
42484248
*
42494249
* @return {@code true} if {@link org.hibernate.id.insert.InsertReturningDelegate}

0 commit comments

Comments
 (0)