1
+ <!--
2
+ ~ Copyright 2016 Red Hat, Inc. and/or its affiliates
3
+ ~ and other contributors as indicated by the @author tags.
4
+ ~
5
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
6
+ ~ you may not use this file except in compliance with the License.
7
+ ~ You may obtain a copy of the License at
8
+ ~
9
+ ~ http://www.apache.org/licenses/LICENSE-2.0
10
+ ~
11
+ ~ Unless required by applicable law or agreed to in writing, software
12
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
13
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ ~ See the License for the specific language governing permissions and
15
+ ~ limitations under the License.
16
+ -->
17
+
18
+ <!-- Workaround to use custom hibernate properties, see: https://github.com/keycloak/keycloak/issues/19427#issuecomment-2792484805 -->
19
+
20
+ <persistence xmlns =" https://jakarta.ee/xml/ns/persistence"
21
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
22
+ xsi : schemaLocation =" https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd"
23
+ version =" 3.0" >
24
+ <persistence-unit name =" keycloak-default" transaction-type =" RESOURCE_LOCAL" >
25
+ <class >org.keycloak.models.jpa.entities.ClientEntity</class >
26
+ <class >org.keycloak.models.jpa.entities.ClientAttributeEntity</class >
27
+ <class >org.keycloak.models.jpa.entities.CredentialEntity</class >
28
+ <class >org.keycloak.models.jpa.entities.RealmEntity</class >
29
+ <class >org.keycloak.models.jpa.entities.RealmAttributeEntity</class >
30
+ <class >org.keycloak.models.jpa.entities.RequiredCredentialEntity</class >
31
+ <class >org.keycloak.models.jpa.entities.ComponentConfigEntity</class >
32
+ <class >org.keycloak.models.jpa.entities.ComponentEntity</class >
33
+ <class >org.keycloak.models.jpa.entities.UserFederationProviderEntity</class >
34
+ <class >org.keycloak.models.jpa.entities.UserFederationMapperEntity</class >
35
+ <class >org.keycloak.models.jpa.entities.RoleEntity</class >
36
+ <class >org.keycloak.models.jpa.entities.RoleAttributeEntity</class >
37
+ <class >org.keycloak.models.jpa.entities.FederatedIdentityEntity</class >
38
+ <class >org.keycloak.models.jpa.entities.MigrationModelEntity</class >
39
+ <class >org.keycloak.models.jpa.entities.UserEntity</class >
40
+ <class >org.keycloak.models.jpa.entities.RealmLocalizationTextsEntity</class >
41
+ <class >org.keycloak.models.jpa.entities.UserRequiredActionEntity</class >
42
+ <class >org.keycloak.models.jpa.entities.UserAttributeEntity</class >
43
+ <class >org.keycloak.models.jpa.entities.UserRoleMappingEntity</class >
44
+ <class >org.keycloak.models.jpa.entities.IdentityProviderEntity</class >
45
+ <class >org.keycloak.models.jpa.entities.IdentityProviderMapperEntity</class >
46
+ <class >org.keycloak.models.jpa.entities.ProtocolMapperEntity</class >
47
+ <class >org.keycloak.models.jpa.entities.UserConsentEntity</class >
48
+ <class >org.keycloak.models.jpa.entities.UserConsentClientScopeEntity</class >
49
+ <class >org.keycloak.models.jpa.entities.AuthenticationFlowEntity</class >
50
+ <class >org.keycloak.models.jpa.entities.AuthenticationExecutionEntity</class >
51
+ <class >org.keycloak.models.jpa.entities.AuthenticatorConfigEntity</class >
52
+ <class >org.keycloak.models.jpa.entities.RequiredActionProviderEntity</class >
53
+ <class >org.keycloak.models.jpa.session.PersistentUserSessionEntity</class >
54
+ <class >org.keycloak.models.jpa.session.PersistentClientSessionEntity</class >
55
+ <class >org.keycloak.models.jpa.entities.RevokedTokenEntity</class >
56
+ <class >org.keycloak.models.jpa.entities.GroupEntity</class >
57
+ <class >org.keycloak.models.jpa.entities.GroupAttributeEntity</class >
58
+ <class >org.keycloak.models.jpa.entities.GroupRoleMappingEntity</class >
59
+ <class >org.keycloak.models.jpa.entities.UserGroupMembershipEntity</class >
60
+ <class >org.keycloak.models.jpa.entities.ClientScopeEntity</class >
61
+ <class >org.keycloak.models.jpa.entities.ClientScopeAttributeEntity</class >
62
+ <class >org.keycloak.models.jpa.entities.ClientScopeRoleMappingEntity</class >
63
+ <class >org.keycloak.models.jpa.entities.ClientScopeClientMappingEntity</class >
64
+ <class >org.keycloak.models.jpa.entities.DefaultClientScopeRealmMappingEntity</class >
65
+ <class >org.keycloak.models.jpa.entities.ClientInitialAccessEntity</class >
66
+
67
+ <!-- JpaAuditProviders -->
68
+ <class >org.keycloak.events.jpa.EventEntity</class >
69
+ <class >org.keycloak.events.jpa.AdminEventEntity</class >
70
+
71
+ <!-- Authorization -->
72
+ <class >org.keycloak.authorization.jpa.entities.ResourceServerEntity</class >
73
+ <class >org.keycloak.authorization.jpa.entities.ResourceEntity</class >
74
+ <class >org.keycloak.authorization.jpa.entities.ScopeEntity</class >
75
+ <class >org.keycloak.authorization.jpa.entities.PolicyEntity</class >
76
+ <class >org.keycloak.authorization.jpa.entities.PermissionTicketEntity</class >
77
+ <class >org.keycloak.authorization.jpa.entities.ResourceAttributeEntity</class >
78
+
79
+ <!-- User Federation Storage -->
80
+ <class >org.keycloak.storage.jpa.entity.BrokerLinkEntity</class >
81
+ <class >org.keycloak.storage.jpa.entity.FederatedUser</class >
82
+ <class >org.keycloak.storage.jpa.entity.FederatedUserAttributeEntity</class >
83
+ <class >org.keycloak.storage.jpa.entity.FederatedUserConsentEntity</class >
84
+ <class >org.keycloak.storage.jpa.entity.FederatedUserConsentClientScopeEntity</class >
85
+ <class >org.keycloak.storage.jpa.entity.FederatedUserCredentialEntity</class >
86
+ <class >org.keycloak.storage.jpa.entity.FederatedUserGroupMembershipEntity</class >
87
+ <class >org.keycloak.storage.jpa.entity.FederatedUserRequiredActionEntity</class >
88
+ <class >org.keycloak.storage.jpa.entity.FederatedUserRoleMappingEntity</class >
89
+
90
+ <!-- Organization -->
91
+ <class >org.keycloak.models.jpa.entities.OrganizationEntity</class >
92
+ <class >org.keycloak.models.jpa.entities.OrganizationDomainEntity</class >
93
+
94
+ <exclude-unlisted-classes >true</exclude-unlisted-classes >
95
+
96
+ <properties >
97
+ <property name =" jboss.as.jpa.managed" value =" false" />
98
+
99
+ <!-- Execute multiple insert and update statements in a single call to improve bulk insert / update performance.
100
+ See https://docs.jboss.org/hibernate/orm/6.2/userguide/html_single/Hibernate_User_Guide.html#best-practices-jdbc-batching
101
+ and https://docs.jboss.org/hibernate/orm/6.2/userguide/html_single/Hibernate_User_Guide.html#batch-session-batch:
102
+ recommendation between 10 and 50 -->
103
+ <property name =" hibernate.jdbc.batch_size" value =" 32" />
104
+
105
+ <!-- (optional) Allows for more batching for nested objects and less deadlocks, but according to
106
+ https://docs.jboss.org/hibernate/orm/6.2/userguide/html_single/Hibernate_User_Guide.html#batch-jdbcbatch
107
+ may also hava a negative impact on performance.
108
+ See also https://docs.jboss.org/hibernate/orm/6.2/userguide/html_single/Hibernate_User_Guide.html#best-practices-jdbc-batching.
109
+ Keycloak uses many nested objects spread across multiple tables, so a benefit is likely.
110
+ -->
111
+ <property name =" hibernate.order_inserts" value =" true" />
112
+ <property name =" hibernate.order_updates" value =" true" />
113
+
114
+ <!-- Batch fetching collections of entity proxies, default 1. Eases N+1 issues to some extent.
115
+ See https://docs.jboss.org/hibernate/orm/6.2/userguide/html_single/Hibernate_User_Guide.html#fetching-batch -->
116
+ <property name =" hibernate.default_batch_fetch_size" value =" 8" />
117
+
118
+ <!-- Improve cache hits for execution plans.
119
+ See https://docs.jboss.org/hibernate/orm/6.1/userguide/html_single/Hibernate_User_Guide.html#configurations-query -->
120
+ <property name =" hibernate.query.in_clause_parameter_padding" value =" true" />
121
+
122
+ <!-- Increase number of elements fetched at once from Oracle database query result up from 10.
123
+ MSSQL returns the whole result at once.
124
+ See https://docs.oracle.com/en/database/oracle/oracle-database/21/jjdbc/resultset.html -->
125
+ <property name =" hibernate.jdbc.fetch_size" value =" 64" />
126
+
127
+ <property name =" hibernate.log_slow_query" value =" 5000" />
128
+ <property name =" hibernate.use_sql_comments" value =" true" />
129
+
130
+ </properties >
131
+ </persistence-unit >
132
+ </persistence >
0 commit comments