1111
1212import org .hibernate .SessionFactory ;
1313import org .hibernate .cache .spi .access .AccessType ;
14+ import org .hibernate .cfg .AvailableSettings ;
1415import org .hibernate .cfg .CacheSettings ;
1516import org .hibernate .cfg .JdbcSettings ;
1617import org .hibernate .cfg .JpaComplianceSettings ;
@@ -54,7 +55,8 @@ public SessionFactory createEntityManagerFactory() {
5455 }
5556
5657 /**
57- * Name of the JDBC driver to use for non-Datasource connection
58+ * JDBC driver class name for non-{@link javax.sql.DataSource DataSource}
59+ * connection.
5860 *
5961 * @see #JDBC_DRIVER
6062 */
@@ -64,7 +66,7 @@ public HibernatePersistenceConfiguration jdbcDriver(String driverName) {
6466 }
6567
6668 /**
67- * URL to use for non-Datasource JDBC connection
69+ * JDBC URL of non-{@link javax.sql.DataSource DataSource} JDBC connection.
6870 *
6971 * @see #JDBC_URL
7072 */
@@ -74,7 +76,7 @@ public HibernatePersistenceConfiguration jdbcUrl(String url) {
7476 }
7577
7678 /**
77- * User-name to use for non-Datasource JDBC connection
79+ * Username for non-{@link javax.sql.DataSource DataSource} JDBC connection.
7880 *
7981 * @see #JDBC_USER
8082 * @see #jdbcPassword
@@ -85,7 +87,7 @@ public HibernatePersistenceConfiguration jdbcUsername(String username) {
8587 }
8688
8789 /**
88- * User-name to use for non-Datasource JDBC connection
90+ * Password for non-{@link javax.sql.DataSource DataSource} JDBC connection.
8991 *
9092 * @see #JDBC_PASSWORD
9193 * @see #jdbcUsername
@@ -96,7 +98,39 @@ public HibernatePersistenceConfiguration jdbcPassword(String password) {
9698 }
9799
98100 /**
99- * Defines whether Hibernate will strictly adhere to compliance with Jakarta Persistence for
101+ * Username and password for non-{@link javax.sql.DataSource DataSource}
102+ * JDBC connection.
103+ *
104+ * @see #JDBC_USER
105+ * @see #JDBC_PASSWORD
106+ * @see #jdbcUsername
107+ * @see #jdbcPassword
108+ */
109+ public HibernatePersistenceConfiguration jdbcCredentials (String username , String password ) {
110+ jdbcUsername ( username );
111+ jdbcPassword ( password );
112+ return this ;
113+ }
114+
115+ /**
116+ * Enables SQL logging to the console.
117+ * <p>
118+ * Sets {@value AvailableSettings#SHOW_SQL}, {@value AvailableSettings#FORMAT_SQL},
119+ * and {@value AvailableSettings#HIGHLIGHT_SQL}.
120+ *
121+ * @param showSql should SQL be logged to console?
122+ * @param formatSql should logged SQL be formatted
123+ * @param highlightSql should logged SQL be highlighted with pretty colors
124+ */
125+ public HibernatePersistenceConfiguration showSql (boolean showSql , boolean formatSql , boolean highlightSql ) {
126+ property ( JdbcSettings .SHOW_SQL , showSql );
127+ property ( JdbcSettings .FORMAT_SQL , formatSql );
128+ property ( JdbcSettings .HIGHLIGHT_SQL , highlightSql );
129+ return this ;
130+ }
131+
132+ /**
133+ * Specifies whether Hibernate will strictly adhere to compliance with Jakarta Persistence for
100134 * all aspects of {@linkplain jakarta.persistence.Query} handling.
101135 *
102136 * @see JpaComplianceSettings#JPA_QUERY_COMPLIANCE
@@ -107,7 +141,7 @@ public HibernatePersistenceConfiguration queryCompliance(boolean enabled) {
107141 }
108142
109143 /**
110- * Defines whether Hibernate will strictly adhere to compliance with Jakarta Persistence for
144+ * Specifies whether Hibernate will strictly adhere to compliance with Jakarta Persistence for
111145 * all aspects of transaction handling.
112146 *
113147 * @see JpaComplianceSettings#JPA_TRANSACTION_COMPLIANCE
@@ -118,7 +152,7 @@ public HibernatePersistenceConfiguration transactionCompliance(boolean enabled)
118152 }
119153
120154 /**
121- * Defines whether Hibernate will strictly adhere to compliance with Jakarta Persistence for
155+ * Specifies whether Hibernate will strictly adhere to compliance with Jakarta Persistence for
122156 * handling around calls to {@linkplain EntityManager#close()},
123157 * {@linkplain EntityManager#isOpen()},
124158 * {@linkplain EntityManagerFactory#close()} and
@@ -132,7 +166,7 @@ public HibernatePersistenceConfiguration closedCompliance(boolean enabled) {
132166 }
133167
134168 /**
135- * Defines whether Hibernate will strictly adhere to compliance with Jakarta Persistence for
169+ * Specifies whether Hibernate will strictly adhere to compliance with Jakarta Persistence for
136170 * handling of proxies.
137171 *
138172 * @see JpaComplianceSettings#JPA_PROXY_COMPLIANCE
@@ -143,7 +177,7 @@ public HibernatePersistenceConfiguration proxyCompliance(boolean enabled) {
143177 }
144178
145179 /**
146- * Defines whether Hibernate will strictly adhere to compliance with Jakarta Persistence for
180+ * Specifies whether Hibernate will strictly adhere to compliance with Jakarta Persistence for
147181 * handling of proxies.
148182 *
149183 * @see JpaComplianceSettings#JPA_PROXY_COMPLIANCE
@@ -154,7 +188,7 @@ public HibernatePersistenceConfiguration cachingCompliance(boolean enabled) {
154188 }
155189
156190 /**
157- * Defines whether Hibernate will strictly adhere to compliance with Jakarta Persistence for
191+ * Specifies whether Hibernate will strictly adhere to compliance with Jakarta Persistence for
158192 * in terms of collecting all named value generators globally, regardless of location.
159193 *
160194 * @see JpaComplianceSettings#JPA_ID_GENERATOR_GLOBAL_SCOPE_COMPLIANCE
@@ -165,7 +199,7 @@ public HibernatePersistenceConfiguration globalGeneratorCompliance(boolean enabl
165199 }
166200
167201 /**
168- * Defines whether Hibernate will strictly adhere to compliance with Jakarta Persistence for
202+ * Specifies whether Hibernate will strictly adhere to compliance with Jakarta Persistence for
169203 * the interpretation of {@link jakarta.persistence.OrderBy}.
170204 *
171205 * @see JpaComplianceSettings#JPA_ORDER_BY_MAPPING_COMPLIANCE
@@ -176,7 +210,7 @@ public HibernatePersistenceConfiguration orderByMappingCompliance(boolean enable
176210 }
177211
178212 /**
179- * Defines whether Hibernate will strictly adhere to compliance with Jakarta Persistence for
213+ * Specifies whether Hibernate will strictly adhere to compliance with Jakarta Persistence for
180214 * the allowed type of identifier value passed to
181215 * {@link jakarta.persistence.EntityManager#getReference} and
182216 * {@link jakarta.persistence.EntityManager#find}
@@ -189,7 +223,7 @@ public HibernatePersistenceConfiguration loadByIdCompliance(boolean enabled) {
189223 }
190224
191225 /**
192- * Enable/ disable Hibernate's caching support
226+ * Enable or disable the second-level and query caches.
193227 */
194228 public HibernatePersistenceConfiguration caching (CachingType type ) {
195229 assert Objects .nonNull ( type );
0 commit comments