@@ -1068,9 +1068,18 @@ On the other hand, if you use `openSession()`, you'll have to manage the
10681068association between sessions and contexts yourself. Now, that's in principle
10691069straightforward, but you'd be surprised how often people mess up.
10701070
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.
10741083
10751084For example, I bet you would like to be able to write code like this:
10761085
@@ -1507,20 +1516,23 @@ In a multitenant application, the database or database schema depends on the cur
15071516tenant identifier. The easiest way to set this up in Hibernate Reactive is to extend
15081517`DefaultSqlClientPool` and override `getTenantPool(String tenantId)`.
15091518
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:
15121521
15131522|===
15141523| Configuration property name | Value
15151524
1516- | `hibernate.multiTenancy` | The multitenancy strategy: `database` or `schema`
15171525| `hibernate.tenant_identifier_resolver` | (Optional) A class which implements `CurrentTenantIdentifierResolver`
15181526|===
15191527
15201528If you don't provide a `CurrentTenantIdentifierResolver`, you can specify
15211529the tenant id explicitly when you call `openSession()`, `withSession()`,
15221530or `withTransaction()`.
15231531
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+
15241536== Next steps
15251537
15261538:Quarkus: https://quarkus.io/guides/getting-started-reactive
0 commit comments