You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: documentation/src/main/asciidoc/introduction/Advanced.adoc
+15-2Lines changed: 15 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -126,12 +126,20 @@ var session =
126
126
.openSession();
127
127
----
128
128
129
-
However, since we often don't have this level of control of creation of the session, it's more common to supply an implementation of `CurrentTenantIdentifierResolver` to Hibernate.
However, since we often don't have this level of control over creation of the session, it's more common to supply an implementation of `CurrentTenantIdentifierResolver` to Hibernate.
130
138
131
139
There are three common ways to implement multi-tenancy:
132
140
133
141
1. each tenant has its own database,
134
-
2. each tenant has its own schema,
142
+
2. each tenant has its own schema, or
135
143
3. tenants share tables in a single schema, and rows are tagged with the tenant id.
136
144
137
145
From the point of view of Hibernate, there's little difference between the first two options.
@@ -156,6 +164,7 @@ In this case we don't need a `MultiTenantConnectionProvider`, but we will need a
156
164
class Account {
157
165
@Id String id;
158
166
@TenantId String tenantId;
167
+
159
168
...
160
169
}
161
170
----
@@ -177,6 +186,10 @@ Native SQL queries are _not_ automatically filtered by tenant id; you'll have to
177
186
| `hibernate.multi_tenant_connection_provider` | Specifies the `MultiTenantConnectionProvider`
178
187
|===
179
188
189
+
[TIP]
190
+
====
191
+
If you only need to filter rows by a static condition with no parameters, `@SQLRestriction` is a much simpler way to do that.
0 commit comments