diff --git a/hibernate-ucp/hibernate-ucp.gradle b/hibernate-ucp/hibernate-ucp.gradle deleted file mode 100644 index ac8da2475647..000000000000 --- a/hibernate-ucp/hibernate-ucp.gradle +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ - -plugins { - id "local.publishing-java-module" - id "local.publishing-group-relocation" -} - -description = 'Integration for Oracle UCP into Hibernate O/RM' - -dependencies { - implementation project( ':hibernate-core' ) - implementation libs.ucp - implementation libs.ojdbc17 - - testImplementation project( ':hibernate-testing' ) -} diff --git a/hibernate-ucp/src/main/java/org/hibernate/oracleucp/internal/StrategyRegistrationProviderImpl.java b/hibernate-ucp/src/main/java/org/hibernate/oracleucp/internal/StrategyRegistrationProviderImpl.java deleted file mode 100644 index 4da10b815013..000000000000 --- a/hibernate-ucp/src/main/java/org/hibernate/oracleucp/internal/StrategyRegistrationProviderImpl.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SPDX-License-Identifier: LGPL-2.1-or-later - * Copyright Red Hat Inc. and Hibernate Authors - */ -package org.hibernate.oracleucp.internal; - -import java.util.Collections; -import java.util.List; - -import org.hibernate.boot.registry.selector.SimpleStrategyRegistrationImpl; -import org.hibernate.boot.registry.selector.StrategyRegistration; -import org.hibernate.boot.registry.selector.StrategyRegistrationProvider; -import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; - -/** - * Provides the {@link UCPConnectionProvider} to the - * {@link org.hibernate.boot.registry.selector.spi.StrategySelector} service. - * - */ -public class StrategyRegistrationProviderImpl implements StrategyRegistrationProvider { - private static final List REGISTRATIONS = Collections.singletonList( - new SimpleStrategyRegistrationImpl<>( - ConnectionProvider.class, - UCPConnectionProvider.class, - "ucp", - "oracleucp", - UCPConnectionProvider.class.getSimpleName(), - "org.oracle.ucp.connection.UCPConnectionProvider" - ) - ); - - @Override - public Iterable getStrategyRegistrations() { - return REGISTRATIONS; - } -} diff --git a/hibernate-ucp/src/main/java/org/hibernate/oracleucp/internal/UCPConnectionProvider.java b/hibernate-ucp/src/main/java/org/hibernate/oracleucp/internal/UCPConnectionProvider.java deleted file mode 100644 index 7e48bd18bdcc..000000000000 --- a/hibernate-ucp/src/main/java/org/hibernate/oracleucp/internal/UCPConnectionProvider.java +++ /dev/null @@ -1,234 +0,0 @@ -/* - * SPDX-License-Identifier: LGPL-2.1-or-later - * Copyright Red Hat Inc. and Hibernate Authors - */ -package org.hibernate.oracleucp.internal; - -import java.io.Serial; -import java.lang.reflect.Method; -import java.sql.Connection; -import java.sql.SQLException; -import java.util.Arrays; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Properties; -import javax.sql.DataSource; - -import org.hibernate.HibernateException; -import org.hibernate.cfg.AvailableSettings; -import org.hibernate.dialect.Dialect; -import org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator; -import org.hibernate.engine.jdbc.connections.internal.DatabaseConnectionInfoImpl; -import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; -import org.hibernate.engine.jdbc.connections.spi.ConnectionProviderConfigurationException; -import org.hibernate.engine.jdbc.connections.spi.DatabaseConnectionInfo; -import org.hibernate.internal.log.ConnectionInfoLogger; -import org.hibernate.internal.util.config.ConfigurationHelper; -import org.hibernate.service.UnknownUnwrapTypeException; -import org.hibernate.service.spi.Configurable; -import org.hibernate.service.spi.Stoppable; - -import oracle.ucp.UniversalConnectionPoolException; -import oracle.ucp.admin.UniversalConnectionPoolManager; -import oracle.ucp.admin.UniversalConnectionPoolManagerImpl; -import oracle.ucp.jdbc.PoolDataSource; -import oracle.ucp.jdbc.PoolDataSourceFactory; - - -public class UCPConnectionProvider implements ConnectionProvider, Configurable, Stoppable { - - @Serial - private static final long serialVersionUID = 1L; - private PoolDataSource ucpDS = null; - private static final String UCP_CONFIG_PREFIX = "hibernate.oracleucp"; - private static final String CONFIG_PREFIX = UCP_CONFIG_PREFIX + "."; - private boolean autoCommit; - private Integer isolation; - - @Override - public void configure(Map props) throws HibernateException { - try { - ConnectionInfoLogger.INSTANCE.configureConnectionPool( "Ucp" ); - - isolation = ConnectionProviderInitiator.extractIsolation( props ); - autoCommit = ConfigurationHelper.getBoolean( AvailableSettings.AUTOCOMMIT, props ); - - UniversalConnectionPoolManager poolManager = - UniversalConnectionPoolManagerImpl.getUniversalConnectionPoolManager(); - ucpDS = PoolDataSourceFactory.getPoolDataSource(); - Properties ucpProps = getConfiguration(props); - configureDataSource(ucpDS, ucpProps); - } - catch (Exception e) { - ConnectionInfoLogger.INSTANCE.unableToInstantiateConnectionPool( e ); - throw new ConnectionProviderConfigurationException( - "Could not configure UCP: " + e.getMessage(), e ); - } - } - - private void configureDataSource(PoolDataSource ucpDS, Properties ucpProps) { - - List methods = Arrays.asList(PoolDataSource.class.getDeclaredMethods()); - - for(String propName : ucpProps.stringPropertyNames()) { - String value = ucpProps.getProperty(propName); - - final String methodName = "set" + propName.substring(0, 1).toUpperCase(Locale.ENGLISH) + propName.substring(1); - Method writeMethod = methods.stream().filter(m -> m.getName().equals(methodName) && m.getParameterCount() == 1).findFirst().orElse(null); - if (writeMethod == null) { - throw new RuntimeException("Property " + propName + " does not exist on target " + PoolDataSource.class); - } - - try { - Class paramClass = writeMethod.getParameterTypes()[0]; - if (paramClass == int.class) { - writeMethod.invoke(ucpDS, Integer.parseInt(value.toString())); - } - else if (paramClass == long.class) { - writeMethod.invoke(ucpDS, Long.parseLong(value.toString())); - } - else if (paramClass == boolean.class || paramClass == Boolean.class) { - writeMethod.invoke(ucpDS, Boolean.parseBoolean(value.toString())); - } - else if (paramClass == String.class) { - writeMethod.invoke(ucpDS, value.toString()); - } - else { - if(propName.equals("connectionProperties") || - propName.equals("connectionFactoryProperties")) { - if (value != null) { - Properties connProps = new Properties(); - - // The Properties string is in the following format: - // {prop1=val1, prop2=val2, ..., propN=valN} - String[] propStrs = value.substring(1, value.length() - 1).split(", "); - for (String onePropStr : propStrs) { - // Separate the name and value strings for each property - String[] nvPair = onePropStr.split("="); - connProps.setProperty(nvPair[0], nvPair[1]); - } - - writeMethod.invoke(ucpDS, connProps); - } - } - else { - writeMethod.invoke(ucpDS, value); - } - } - } - catch (Exception e) { - throw new RuntimeException(e); - } - } - } - - private Properties getConfiguration(Map props) { - Properties ucpProps = new Properties(); - - copyProperty( AvailableSettings.URL, props, "URL", ucpProps ); - copyProperty( AvailableSettings.USER, props, "user", ucpProps ); - copyProperty( AvailableSettings.PASS, props, "password", ucpProps ); - - for ( Object object : props.keySet() ) { - if ( object instanceof String key ) { - if ( key.startsWith( CONFIG_PREFIX ) ) { - ucpProps.setProperty( key.substring( CONFIG_PREFIX.length() ), (String) props.get( key ) ); - } - } - } - - return ucpProps; - } - - @SuppressWarnings("rawtypes") - private static void copyProperty(String srcKey, Map src, String dstKey, Properties dst) { - if ( src.containsKey( srcKey ) ) { - dst.setProperty( dstKey, (String) src.get( srcKey ) ); - } - } - - // ************************************************************************* - // ConnectionProvider - // ************************************************************************* - - @Override - public Connection getConnection() throws SQLException { - Connection conn = null; - if ( ucpDS != null ) { - conn = ucpDS.getConnection(); - if ( isolation != null && isolation != conn.getTransactionIsolation()) { - conn.setTransactionIsolation( isolation ); - } - - if ( conn.getAutoCommit() != autoCommit ) { - conn.setAutoCommit( autoCommit ); - } - } - - return conn; - } - - @Override - public void closeConnection(Connection conn) throws SQLException { - conn.close(); - } - - @Override - public boolean supportsAggressiveRelease() { - return false; - } - - @Override - public DatabaseConnectionInfo getDatabaseConnectionInfo(Dialect dialect) { - return new DatabaseConnectionInfoImpl( - UCPConnectionProvider.class, - ucpDS.getURL(), - ucpDS.getConnectionFactoryClassName(), - dialect.getVersion(), - Boolean.toString( autoCommit ), - isolation != null ? ConnectionProviderInitiator.toIsolationConnectionConstantName( isolation ) : null, - ucpDS.getMinPoolSize(), - ucpDS.getMaxPoolSize() - ); - } - - @Override - @SuppressWarnings("rawtypes") - public boolean isUnwrappableAs(Class unwrapType) { - return ConnectionProvider.class.equals( unwrapType ) - || UCPConnectionProvider.class.isAssignableFrom( unwrapType ) - || DataSource.class.isAssignableFrom( unwrapType ); - } - - @Override - @SuppressWarnings("unchecked") - public T unwrap(Class unwrapType) { - if ( ConnectionProvider.class.equals( unwrapType ) || - UCPConnectionProvider.class.isAssignableFrom( unwrapType ) ) { - return (T) this; - } - else if ( DataSource.class.isAssignableFrom( unwrapType ) ) { - return (T) ucpDS; - } - else { - throw new UnknownUnwrapTypeException( unwrapType ); - } - } - - @Override - public void stop() { - if(this.ucpDS!=null && ucpDS.getConnectionPoolName() != null) { - ConnectionInfoLogger.INSTANCE.cleaningUpConnectionPool( UCP_CONFIG_PREFIX + " [" + ucpDS.getConnectionPoolName() + "]" ); - try { - UniversalConnectionPoolManager poolManager = UniversalConnectionPoolManagerImpl. - getUniversalConnectionPoolManager(); - poolManager.destroyConnectionPool(ucpDS.getConnectionPoolName()); - } - catch (UniversalConnectionPoolException e) { - ConnectionInfoLogger.INSTANCE.unableToDestroyConnectionPool( e ); - } - } - } - -} diff --git a/hibernate-ucp/src/main/java/org/hibernate/oracleucp/internal/package-info.java b/hibernate-ucp/src/main/java/org/hibernate/oracleucp/internal/package-info.java deleted file mode 100644 index b1c39de03bcc..000000000000 --- a/hibernate-ucp/src/main/java/org/hibernate/oracleucp/internal/package-info.java +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ - -/** - * Implementation of ConnectionProvider using UCP. - */ -package org.hibernate.oracleucp.internal; diff --git a/hibernate-ucp/src/main/resources/META-INF/services/org.hibernate.boot.registry.selector.StrategyRegistrationProvider b/hibernate-ucp/src/main/resources/META-INF/services/org.hibernate.boot.registry.selector.StrategyRegistrationProvider deleted file mode 100644 index 2a7dfc6d4e8a..000000000000 --- a/hibernate-ucp/src/main/resources/META-INF/services/org.hibernate.boot.registry.selector.StrategyRegistrationProvider +++ /dev/null @@ -1,14 +0,0 @@ -# -# Hibernate, Relational Persistence for Idiomatic Java -# -# License: GNU Lesser General Public License (LGPL), version 2.1 or later. -# See the lgpl.txt file in the root directory or . -# -# -# Hibernate, Relational Persistence for Idiomatic Java -# -# License: GNU Lesser General Public License (LGPL), version 2.1 or later. -# See the lgpl.txt file in the root directory or . -# -org.hibernate.oracleucp.internal.StrategyRegistrationProviderImpl - diff --git a/hibernate-ucp/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/hibernate-ucp/src/main/resources/OSGI-INF/blueprint/blueprint.xml deleted file mode 100644 index 767a2b6559e4..000000000000 --- a/hibernate-ucp/src/main/resources/OSGI-INF/blueprint/blueprint.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - diff --git a/hibernate-ucp/src/test/java/org/hibernate/test/ucp/UCPConnectionProviderTest.java b/hibernate-ucp/src/test/java/org/hibernate/test/ucp/UCPConnectionProviderTest.java deleted file mode 100644 index 33af5ce0de42..000000000000 --- a/hibernate-ucp/src/test/java/org/hibernate/test/ucp/UCPConnectionProviderTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * SPDX-License-Identifier: LGPL-2.1-or-later - * Copyright Red Hat Inc. and Hibernate Authors - */ -package org.hibernate.test.ucp; - -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ - -import java.sql.Connection; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; - -import org.hibernate.dialect.SybaseDialect; -import org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.ConnectionProviderJdbcConnectionAccess; -import org.hibernate.engine.jdbc.spi.JdbcServices; -import org.hibernate.oracleucp.internal.UCPConnectionProvider; -import org.hibernate.testing.orm.junit.SkipForDialect; -import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; -import org.junit.Test; - -import static org.hibernate.testing.junit4.ExtraAssertions.assertTyping; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -@SkipForDialect(dialectClass = SybaseDialect.class, matchSubTypes = true, reason = "The jTDS driver doesn't implement Connection#isValid so this fails") -public class UCPConnectionProviderTest extends BaseCoreFunctionalTestCase { - - @Test - public void testUCPConnectionProvider() throws Exception { - JdbcServices jdbcServices = serviceRegistry().getService( JdbcServices.class ); - ConnectionProviderJdbcConnectionAccess connectionAccess = assertTyping( - ConnectionProviderJdbcConnectionAccess.class, - jdbcServices.getBootstrapJdbcConnectionAccess() - ); - assertTyping( UCPConnectionProvider.class, connectionAccess.getConnectionProvider() ); - - UCPConnectionProvider ucpProvider = (UCPConnectionProvider) connectionAccess.getConnectionProvider(); - final List conns = new ArrayList(); - for ( int i = 0; i < 2; i++ ) { - Connection conn = ucpProvider.getConnection(); - assertNotNull( conn ); - assertFalse( conn.isClosed() ); - conns.add( conn ); - } - - try { - ucpProvider.getConnection(); - fail( "SQLException expected -- no more connections should have been available in the pool." ); - } - catch (SQLException e) { - // expected - assertTrue( e.getMessage().contains( "Failed to get a connection" ) ); - } - - for ( Connection conn : conns ) { - ucpProvider.closeConnection( conn ); - assertTrue( conn.isClosed() ); - } - - releaseSessionFactory(); - - try { - ucpProvider.getConnection(); - fail( "Exception expected -- the pool should have been shutdown." ); - } - catch (Exception e) { - // expected - assertTrue( e.getMessage().contains( "Failed to get a connection" ) ); - } - } -} diff --git a/hibernate-ucp/src/test/java/org/hibernate/test/ucp/UCPTransactionIsolationConfigTest.java b/hibernate-ucp/src/test/java/org/hibernate/test/ucp/UCPTransactionIsolationConfigTest.java deleted file mode 100644 index dc1d42d15177..000000000000 --- a/hibernate-ucp/src/test/java/org/hibernate/test/ucp/UCPTransactionIsolationConfigTest.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SPDX-License-Identifier: LGPL-2.1-or-later - * Copyright Red Hat Inc. and Hibernate Authors - */ -package org.hibernate.test.ucp; - -import org.hibernate.community.dialect.AltibaseDialect; -import org.hibernate.dialect.SybaseDialect; -import org.hibernate.dialect.TiDBDialect; -import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; -import org.hibernate.oracleucp.internal.UCPConnectionProvider; -import org.hibernate.testing.common.connections.BaseTransactionIsolationConfigTest; -import org.hibernate.testing.orm.junit.SkipForDialect; - -@SkipForDialect(dialectClass = SybaseDialect.class, matchSubTypes = true, reason = "The jTDS driver doesn't implement Connection#getNetworkTimeout() so this fails") -@SkipForDialect(dialectClass = TiDBDialect.class, matchSubTypes = true, reason = "Doesn't support SERIALIZABLE isolation") -@SkipForDialect(dialectClass = AltibaseDialect.class, matchSubTypes = true, reason = "Altibase cannot change isolation level in autocommit mode") -public class UCPTransactionIsolationConfigTest extends BaseTransactionIsolationConfigTest{ - @Override - protected ConnectionProvider getConnectionProviderUnderTest() { - return new UCPConnectionProvider(); - } -} diff --git a/hibernate-ucp/src/test/resources/hibernate.properties b/hibernate-ucp/src/test/resources/hibernate.properties deleted file mode 100644 index 3d4093ce510f..000000000000 --- a/hibernate-ucp/src/test/resources/hibernate.properties +++ /dev/null @@ -1,12 +0,0 @@ -hibernate.dialect @db.dialect@ -hibernate.connection.driver_class @jdbc.driver@ -hibernate.connection.url @jdbc.url@ -hibernate.connection.username @jdbc.user@ -hibernate.connection.password @jdbc.pass@ -hibernate.connection.init_sql @connection.init_sql@ -hibernate.connection.provider_class=UCPConnectionProvider - -hibernate.oracleucp.connectionFactoryClassName=@jdbc.datasource@ -hibernate.oracleucp.minPoolSize=0 -hibernate.oracleucp.maxPoolSize=2 -hibernate.oracleucp.connectionPoolName=TestUCPPool diff --git a/hibernate-ucp/src/test/resources/log4j2.properties b/hibernate-ucp/src/test/resources/log4j2.properties deleted file mode 100644 index d4da0b21a5e8..000000000000 --- a/hibernate-ucp/src/test/resources/log4j2.properties +++ /dev/null @@ -1,19 +0,0 @@ -# -# Hibernate, Relational Persistence for Idiomatic Java -# -# License: GNU Lesser General Public License (LGPL), version 2.1 or later. -# See the lgpl.txt file in the root directory or . -# -appender.stdout.type=Console -appender.stdout.name=STDOUT -appender.stdout.layout.type=PatternLayout -appender.stdout.layout.pattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n - - -rootLogger.level=info -rootLogger.appenderRef.stdout.ref=STDOUT - -logger.hbm2ddl.name=org.hibernate.tool.hbm2ddl -logger.hbm2ddl.level=debug -logger.testing-cache.name=org.hibernate.testing.cache -logger.testing-cache.level=debug diff --git a/settings.gradle b/settings.gradle index 619182bb7831..8de307312151 100644 --- a/settings.gradle +++ b/settings.gradle @@ -87,7 +87,6 @@ dependencyResolutionManagement { def agroalVersion = version "agroal", "2.5" def c3poVersion = version "c3p0", "0.10.1" def hikaricpVersion = version "hikaricp", "6.2.1" - def ucpVersion = version "ucp", "23.7.0.25.01" def jcacheVersion = version "jcache", "1.1.1" def ehcache3Version = version "ehcache3", "3.10.8" @@ -119,9 +118,6 @@ dependencyResolutionManagement { library( "agroalPool", "io.agroal", "agroal-pool" ).versionRef( agroalVersion ) library( "c3p0", "com.mchange", "c3p0" ).versionRef( c3poVersion ) library( "hikaricp", "com.zaxxer", "HikariCP" ).versionRef( hikaricpVersion ) - library( "ucp", "com.oracle.database.jdbc", "ucp11" ).versionRef( ucpVersion ) - - library( "ojdbc17", "com.oracle.database.jdbc", "ojdbc17" ).versionRef( ucpVersion ) library( "geolatte", "org.geolatte", "geolatte-geom" ).versionRef( geolatteVersion ) @@ -317,7 +313,6 @@ include 'hibernate-vector' include 'hibernate-c3p0' include 'hibernate-hikaricp' include 'hibernate-agroal' -include 'hibernate-ucp' include 'hibernate-jcache'