document that you can insert multiple rows with 'values'
This commit is contained in:
parent
ef53b2a2de
commit
1934236314
|
@ -232,10 +232,10 @@ Delete statements are polymorphic, and affect mapped subclasses of the given ent
|
|||
|
||||
There are two kinds of `insert` statement:
|
||||
|
||||
- `insert ... values`, where the attribute values to insert are given directly, and
|
||||
- `insert ... values`, where the attribute values to insert are given directly as tuples, and
|
||||
- `insert ... select`, where the inserted attribute values are sourced from a subquery.
|
||||
|
||||
The first form inserts a single row in the database.
|
||||
The first form inserts a single row in the database, or multiple rows if you provide multiple tuples in the `values` clause.
|
||||
The second form may insert many new rows, or none at all.
|
||||
|
||||
[TIP]
|
||||
|
|
|
@ -215,7 +215,15 @@ public class HQLTest extends BaseEntityManagerFunctionalTestCase {
|
|||
doInJPA(this::entityManagerFactory, entityManager -> {
|
||||
//tag::hql-insert-example[]
|
||||
entityManager.createQuery(
|
||||
"insert Person (id, name) values (100L, 'Jane Doe')")
|
||||
"insert Person (id, name) " +
|
||||
"values (100L, 'Jane Doe')")
|
||||
.executeUpdate();
|
||||
|
||||
entityManager.createQuery(
|
||||
"insert Person (id, name) " +
|
||||
"values (101L, 'J A Doe III'), " +
|
||||
"(102L, 'J X Doe'), " +
|
||||
"(103L, 'John Doe, Jr')")
|
||||
.executeUpdate();
|
||||
//end::hql-insert-example[]
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue