Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion hibernate-core/src/main/java/org/hibernate/cfg/JdbcSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ public interface JdbcSettings extends C3p0Settings, AgroalSettings, HikariCPSett
* </ul>
* <p>
* See section 8.2.1.9
*
* @see java.sql.DriverManager#getConnection(String, String, String)
* @see javax.sql.DataSource#getConnection(String, String)
*/
String JAKARTA_JDBC_USER = "jakarta.persistence.jdbc.user";

Expand All @@ -115,6 +118,9 @@ public interface JdbcSettings extends C3p0Settings, AgroalSettings, HikariCPSett
* and {@link #JAKARTA_JDBC_USER} to specify how to connect to the database.
* <p>
* See JPA 2 section 8.2.1.9
*
* @see java.sql.DriverManager#getConnection(String, String, String)
* @see javax.sql.DataSource#getConnection(String, String)
*/
String JAKARTA_JDBC_PASSWORD = "jakarta.persistence.jdbc.password";

Expand Down Expand Up @@ -256,11 +262,13 @@ public interface JdbcSettings extends C3p0Settings, AgroalSettings, HikariCPSett
* {@link org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl}.
* <p>
* Possible values are enumerated by {@link java.sql.Connection}:
* {@code NONE}, {@code READ_UNCOMMITTED}, {@code READ_COMMITTED},
* {@code READ_UNCOMMITTED}, {@code READ_COMMITTED},
* {@code REPEATABLE_READ}, {@code SERIALIZABLE}.
* <p>
* If this setting is not explicitly specified, Hibernate does not modify
* the transaction isolation level of the JDBC connection.
*
* @see java.sql.Connection#setTransactionIsolation(int)
*/
String ISOLATION = "hibernate.connection.isolation";

Expand All @@ -270,6 +278,8 @@ public interface JdbcSettings extends C3p0Settings, AgroalSettings, HikariCPSett
* including every built-in implementation except for
* {@link org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl}.
*
* @see java.sql.Connection#setAutoCommit(boolean)
*
* @settingDefault {@code false}
*/
String AUTOCOMMIT = "hibernate.connection.autocommit";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ public SessionFactory createEntityManagerFactory() {
}

/**
* JDBC driver class name for non-{@link javax.sql.DataSource DataSource}
* connection.
* JDBC driver class name. This setting is ignored when Hibernate is configured
* to obtain connections from a {@link javax.sql.DataSource}.
*
* @see #JDBC_DRIVER
*/
Expand All @@ -110,7 +110,8 @@ public HibernatePersistenceConfiguration jdbcDriver(String driverName) {
}

/**
* JDBC URL of non-{@link javax.sql.DataSource DataSource} JDBC connection.
* JDBC URL. This setting is ignored when Hibernate is configured to obtain
* connections from a {@link javax.sql.DataSource}.
*
* @see #JDBC_URL
*/
Expand All @@ -120,35 +121,40 @@ public HibernatePersistenceConfiguration jdbcUrl(String url) {
}

/**
* Username for non-{@link javax.sql.DataSource DataSource} JDBC connection.
* Username for JDBC authentication.
*
* @see #JDBC_USER
* @see #jdbcPassword
* @see java.sql.DriverManager#getConnection(String, String, String)
* @see javax.sql.DataSource#getConnection(String, String)
*/
public HibernatePersistenceConfiguration jdbcUsername(String username) {
property( JDBC_USER, username );
return this;
}

/**
* Password for non-{@link javax.sql.DataSource DataSource} JDBC connection.
* Password for JDBC authentication.
*
* @see #JDBC_PASSWORD
* @see #jdbcUsername
* @see java.sql.DriverManager#getConnection(String, String, String)
* @see javax.sql.DataSource#getConnection(String, String)
*/
public HibernatePersistenceConfiguration jdbcPassword(String password) {
property( JDBC_PASSWORD, password );
return this;
}

/**
* Username and password for non-{@link javax.sql.DataSource DataSource}
* JDBC connection.
* Username and password for JDBC authentication.
*
* @see #JDBC_USER
* @see #JDBC_PASSWORD
* @see #jdbcUsername
* @see #jdbcPassword
* @see java.sql.DriverManager#getConnection(String, String, String)
* @see javax.sql.DataSource#getConnection(String, String)
*/
public HibernatePersistenceConfiguration jdbcCredentials(String username, String password) {
jdbcUsername( username );
Expand All @@ -157,7 +163,8 @@ public HibernatePersistenceConfiguration jdbcCredentials(String username, String
}

/**
* The JDBC connection pool size.
* The JDBC connection pool size. This setting is ignored when Hibernate is
* configured to obtain connections from a {@link javax.sql.DataSource}.
*
* @see JdbcSettings#POOL_SIZE
*/
Expand All @@ -166,6 +173,36 @@ public HibernatePersistenceConfiguration jdbcPoolSize(int poolSize) {
return this;
}

/**
* The JDBC {@linkplain java.sql.Connection#setAutoCommit autocommit mode}
* for pooled connections. This setting is ignored when Hibernate is
* configured to obtain connections from a {@link javax.sql.DataSource}.
*
* @see JdbcSettings#AUTOCOMMIT
*/
public HibernatePersistenceConfiguration jdbcAutocommit(boolean autocommit) {
property( JdbcSettings.AUTOCOMMIT, autocommit );
return this;
}

/**
* The JDBC {@linkplain java.sql.Connection#setTransactionIsolation transaction
* isolation level}. This setting is ignored when Hibernate is configured to
* obtain connections from a {@link javax.sql.DataSource}.
* <p>
* Possible values are enumerated by {@link java.sql.Connection}:
* {@link java.sql.Connection#TRANSACTION_READ_UNCOMMITTED},
* {@link java.sql.Connection#TRANSACTION_READ_COMMITTED},
* {@link java.sql.Connection#TRANSACTION_REPEATABLE_READ}, and
* {@link java.sql.Connection#TRANSACTION_SERIALIZABLE}.
*
* @see JdbcSettings#ISOLATION
*/
public HibernatePersistenceConfiguration jdbcTransactionIsolation(int isolationLevel) {
property( JdbcSettings.ISOLATION, isolationLevel );
return this;
}

/**
* Enables SQL logging to the console.
* <p>
Expand Down
Loading