@@ -1068,9 +1068,18 @@ On the other hand, if you use `openSession()`, you'll have to manage the
1068
1068
association between sessions and contexts yourself. Now, that's in principle
1069
1069
straightforward, but you'd be surprised how often people mess up.
1070
1070
1071
- IMPORTANT: The session is not thread-safe (or "stream-safe"), so using it across
1072
- different threads (or reactive streams) may cause bugs that are _extremely_ hard
1073
- to detect. Don't say we didn't warn you!
1071
+ IMPORTANT: The Hibernate session is not thread-safe (nor "stream-safe"), so using
1072
+ it across different threads (or reactive streams) may cause bugs that are _extremely_
1073
+ hard to detect. Don't say we didn't warn you!
1074
+
1075
+ More than a few users are surprised by this restriction. But we insist that it's
1076
+ completely natural. An atomic operation of the session, from your point of view as
1077
+ a user of the session, is a method like `flush()`, `find()`, or `getResultList()`.
1078
+ Any one of those methods can result in _multiple interactions with the database_.
1079
+ And between such interactions, the session is simply not in a well-defined state.
1080
+ Reactive streams are a kind of thread, and it's quite unreasonable to expect that
1081
+ reactive programming should vanish away your concurrency problems in a shimmering
1082
+ puff of pixie dust. That's not how these things work.
1074
1083
1075
1084
For example, I bet you would like to be able to write code like this:
1076
1085
@@ -1507,20 +1516,23 @@ In a multitenant application, the database or database schema depends on the cur
1507
1516
tenant identifier. The easiest way to set this up in Hibernate Reactive is to extend
1508
1517
`DefaultSqlClientPool` and override `getTenantPool(String tenantId)`.
1509
1518
1510
- For multitenancy, you'll also need to set at least one of the following
1511
- configuration properties defined by Hibernate ORM:
1519
+ For multitenancy, might also need to set the following configuration property defined
1520
+ by Hibernate ORM:
1512
1521
1513
1522
|===
1514
1523
| Configuration property name | Value
1515
1524
1516
- | `hibernate.multiTenancy` | The multitenancy strategy: `database` or `schema`
1517
1525
| `hibernate.tenant_identifier_resolver` | (Optional) A class which implements `CurrentTenantIdentifierResolver`
1518
1526
|===
1519
1527
1520
1528
If you don't provide a `CurrentTenantIdentifierResolver`, you can specify
1521
1529
the tenant id explicitly when you call `openSession()`, `withSession()`,
1522
1530
or `withTransaction()`.
1523
1531
1532
+ TIP: You don't need a custom pool if you're using _discriminator_-based multitenancy.
1533
+ In that case, all you need is to declare the `@TenantId` properties of your entities,
1534
+ just like in Hibernate ORM 6.
1535
+
1524
1536
== Next steps
1525
1537
1526
1538
:Quarkus: https://quarkus.io/guides/getting-started-reactive
0 commit comments