Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
d4e1b7f
HHH-13561 Do not retrieve the same ActionQueue multiple times
Sanne Aug 11, 2019
25ca80b
HHH-13563 ResultSetReturnImpl is looking up JdbcServices on each cons…
Sanne Aug 11, 2019
3e17be9
HHH-13562 List of TransactionObserver for JdbcResourceLocalTransactio…
Sanne Aug 11, 2019
1b06b76
HHH-13557 : LocalTimeTest#writeThenNativeRead and OffsetTimeTest#writ…
gbadner Aug 13, 2019
3583074
HHH-13558 : InstantTest, LocalDateTimeTest, OffsetDateTimeTest, Zoned…
gbadner Aug 13, 2019
31fb14e
HHH-13551 Restucture ClassPathAndModulePathAggregatedServiceLoader
yrodiere Aug 9, 2019
5174fc2
HHH-13551 Ignore ServiceConfigurationError thrown when accessing serv…
yrodiere Aug 9, 2019
f2f788c
HHH-13551 Test the retrieval of a service when an "incompatible" clas…
yrodiere Aug 9, 2019
2aee5a9
HHH-13556 Tests doing dynamic fetch scrolling a collection fail on DB2
dreab8 Aug 13, 2019
1a5b401
HHH-13554 QueryAndSQLTest.testNativeQueryWithFormulaAttributeWithoutA…
dreab8 Aug 13, 2019
937d4a3
HHH-13569 : org.hibernate.test.annotations.embedded.EmbeddedTest fail…
gbadner Aug 14, 2019
9988d67
HHH-13571 : Test failures due to cross joined table out of scope of a…
gbadner Aug 14, 2019
ce03ef9
HHH-13570 : Test failures due to Sybase not supporting UPDATE stateme…
gbadner Aug 14, 2019
fed93b0
HHH-13573 : Test failure due to Sybase not supporting cascade delete …
gbadner Aug 14, 2019
35037da
HHH-13259 Fix StackOverflowError in StringHelper
Legohuman Aug 9, 2019
7746227
HHH-13576 Invoking tracef() or debugf() w/o an array of parameters ac…
Sanne Aug 14, 2019
e110ab0
HHH-13576 A couple more Logger mistakes in SessionImpl
Sanne Aug 14, 2019
6b48947
HHH-13576 Similar debugf and tracef issues found via grepping
Sanne Aug 14, 2019
cfd7db3
HHH-13574 SybaseASE does not support PARTITION BY
dreab8 Aug 14, 2019
210aff0
HHH-13577 LockTest.testContendedPessimisticLock and StatementIsClosed…
dreab8 Aug 14, 2019
7c57047
HHH-13569 : Shorten table name that's too long for Oracle
gbadner Aug 15, 2019
927f4c2
HHH-13584 Reduce ServiceRegistry lookups in LocalConnectionAccess in …
Sanne Aug 16, 2019
0b64cef
HHH-13579 Optimise ResourceRegistryStandardImpl to avoid heavy alloca…
Sanne Aug 14, 2019
0a1213b
HHH-13585 Duplicate resource release in PessimisticReadSelectLockingS…
Sanne Aug 16, 2019
0a3f62a
HHH-13588 Add missed functions to MySQL Dialect: weight_string, to_ba…
stokito Aug 17, 2019
f49c97c
HHH-13589 ActionQueue review: code formatting
Sanne Aug 18, 2019
d065888
HHH-13589 Avoid HashMap.values() when forEach is an easy replacement
Sanne Aug 18, 2019
eb675e1
HHH-13587 Review formatting and logging style of StatefulPersistenceC…
Sanne Aug 17, 2019
5bbf417
HHH-13587 Allocate StatefulPersistenceContext#nullifiableEntityKeys l…
Sanne Aug 17, 2019
aae670b
HHH-13587 Allocate StatefulPersistenceContext#nullAssociations lazily
Sanne Aug 17, 2019
0538b97
HHH-13587 Allocate StatefulPersistenceContext#naturalIdXrefDelegate l…
Sanne Aug 17, 2019
a113595
HHH-13587 Lazily initialize ConcurrentReferenceHashMap proxiesByKey i…
Sanne Aug 17, 2019
1101727
HHH-13587 StatefulPersistenceContext#unownedCollections was almost fu…
Sanne Aug 17, 2019
0d10174
HHH-13587 Make StatefulPersistenceContext#parentsByChild a lazily ini…
Sanne Aug 17, 2019
3b30c60
HHH-13587 Introduce SPI method PersistenceContext#getCollectionEntrie…
Sanne Aug 17, 2019
690a8d5
HHH-13587 Make StatefulPersistenceContext#collectionEntries also lazi…
Sanne Aug 17, 2019
dbbc24c
HHH-13587 Make StatefulPersistenceContext#nonlazyCollections a lazily…
Sanne Aug 17, 2019
05b888e
HHH-13587 Make StatefulPersistenceContext#arrayHolders lazily initial…
Sanne Aug 17, 2019
7531ed7
HHH-13587 Make StatefulPersistenceContext#entitiesByUniqueKey lazily …
Sanne Aug 17, 2019
da847f4
HHH-13587 Avoid using deprecated PersistenceContext#getCollectionEntr…
Sanne Aug 17, 2019
e0f4047
HHH-12993 Omit joining of superclass table when querying subclass only
Oct 11, 2018
19ac013
HHH-13591 Replaces simple uses of array iteration with a correspondin…
carstenartur Aug 18, 2019
4661efa
HHH-13591 Fixing formatting of previous patch
Sanne Aug 20, 2019
408275d
HHH-13594 ResourceRegistryStandardImpl#release could avoid allocating…
Sanne Aug 20, 2019
5eaa149
HHH-13565 Session opening efficiency: introduce FastSessionServices a…
Sanne Aug 9, 2019
a39aceb
HHH-13565 Move field AbstractSharedSessionContract#disallowOutOfTrans…
Sanne Aug 9, 2019
8a3c1ee
HHH-13565 Promote field useStreamForLobBinding as cross-Session constant
Sanne Aug 9, 2019
72ce71e
HHH-13565 Dialect is another constant
Sanne Aug 9, 2019
185ef2e
HHH-13565 Extract some hot ServiceRegistry services as well
Sanne Aug 9, 2019
8931ef0
HHH-13565 Promote JDBCServices as hot service to be retrieved from Fa…
Sanne Aug 12, 2019
be9fe27
HHH-13565 Promote to FastSessionServices: isJtaTransactionAccessible
Sanne Aug 12, 2019
bc5b3c0
HHH-13565 Remove some related dead code
Sanne Aug 12, 2019
457e9b6
HHH-13565 Formatting improvements
Sanne Aug 12, 2019
e23e6a7
HHH-13565 Extract Session properties to avoid eager initialization of…
Sanne Aug 12, 2019
4ef8030
HHH-13565 Move field SessionImpl#discardOnClose to FastSessionService…
Sanne Aug 13, 2019
4b2f056
HHH-13565 Avoid allocating ArrayList of ConnectionObserver instances …
Sanne Aug 13, 2019
269d5f8
HHH-13565 Review allocations for default SessionEventListener instances
Sanne Aug 22, 2019
b8f3fc3
HHH-13565 Convert iteration of event listeners to be allocation free
Sanne Aug 19, 2019
91299ae
HHH-13565 Remove some dead code from SessionImpl
Sanne Aug 20, 2019
cc39f54
HHH-13565 Micro cleanup of Trace level checks
Sanne Aug 20, 2019
2de048f
HHH-13565 Prepare the most commonly needed SessionBuilder instances i…
Sanne Aug 20, 2019
646a875
HHH-13565 Making SessionFactoryImpl#LockOptions lazily initialized as…
Sanne Aug 21, 2019
9bfffd8
HHH-13565 Ensure all events from EventListenerGroup can be fired with…
Sanne Aug 21, 2019
618a502
HHH-13592 Test AutoFlushEvent#isFlushRequired
yrodiere Aug 20, 2019
5fc6012
HHH-13592 Populate AutoFlushEvent#isFlushRequired with the correct value
yrodiere Aug 20, 2019
13afce9
HHH-13412 Move custom driver properties into their own section
elefeint May 24, 2019
ba1f155
HHH-13412 Remove stray newlines
elefeint May 24, 2019
952bf6f
HHH-13412 Added link for predefined properties, warning that not all …
elefeint May 28, 2019
c94117c
HHH-13595 Deprecate ConnectionObserver
Sanne Aug 23, 2019
db92f7a
HHH-13595 Small tuning of JdbcObserverImpl
Sanne Aug 23, 2019
44c6f0f
HHH-13595 Remove the invocations to the no-op methods of ConnectionOb…
Sanne Aug 23, 2019
5c95096
HHH-13564 - Fix NullPointerException for audited entity with embedded-id
Naros Aug 23, 2019
bcbfea7
HHH-13599 Avoid ArrayList allocation in JtaTransactionCoordinatorImp …
Sanne Aug 27, 2019
3d715c0
HHH-13600 Extract Alias allocation from loop in AbstractCollectionPer…
Sanne Aug 28, 2019
86e498f
HHH-13600 Avoid capturing lambdas in AbstractDomainDataRegion constru…
Sanne Aug 28, 2019
9f71bd8
HHH-13600 Unguarded log statement in CollectionCacheInvalidator
Sanne Aug 28, 2019
c8a36cd
HHH-13600 Extracting some more constants from loops
Sanne Aug 28, 2019
40b30fa
HHH-13600 Avoid capturing lambdas in ParameterTranslationsImpl
Sanne Aug 28, 2019
ea301a7
HHH-13564 - Fix EmbeddedIdGenericsTest failures on Oracle and MariaDB
dreab8 Sep 2, 2019
11409ed
HHH-13590 : test cases
gbadner Aug 26, 2019
148b4b2
HHH-13590 : TransientObjectException merging a non-proxy association …
gbadner Aug 26, 2019
650b1de
HHH-13607 : Added tests
gbadner Aug 31, 2019
7ceaf3a
HHH-13607 - Exception thrown while flushing uninitialized enhanced pr…
sebersole Sep 4, 2019
1cb81c0
HHH-13586 : test case
gbadner Aug 24, 2019
2076c68
HHH-13586 : ClassCastException when using a single region name for bo…
gbadner Aug 24, 2019
b26ec4e
HHH-13611 : Restore EntityMetamodel constructor to take SessionFactor…
gbadner Sep 3, 2019
ea8694a
HHH-13611 : Restore EntityMetamodel constructor to take SessionFactor…
dreab8 Sep 9, 2019
f0218e8
HHH-13616 Enable the hibernate-orm-modules test for JDK 11
dreab8 Sep 10, 2019
be7cc76
HHH-13582 Upgrade MySQL Connector/J to 8.0.17
yrodiere Aug 26, 2019
a580227
HHH-13582 Ignore LocalDateTest for MySQL
yrodiere Aug 27, 2019
f9f6793
HHH-13580 Fix a copy/paste error in OffsetTimeTest
yrodiere Aug 26, 2019
8fce51c
HHH-13580 Use safer ZoneId => TimeZone conversion in AbstractJavaTime…
yrodiere Aug 26, 2019
74d35b2
HHH-13580 Ignore LocalTimeTest and OffsetTimeTest's 'nativeWriteThenR…
yrodiere Aug 26, 2019
debc5d3
HHH-13581 Disable tests involving MariaDB ConnectorJ's buggy ResultSe…
yrodiere Aug 26, 2019
ef87991
HHH-13605 Upgrade the MariaDB JDBC driver to 2.2.4 in the matrix_mari…
yrodiere Aug 30, 2019
26c2e0b
HHH-13621 Add test for issue
dreab8 Sep 13, 2019
f587705
HHH-13621 Exception if spaces after value of javax.persistence.schema…
dreab8 Sep 13, 2019
57dbfbb
HHH-13622 Upgrade the WildFly Transaction Client to 1.1.7.Final
Sanne Sep 16, 2019
0f2a037
HHH-13606 Upgrade the HANA JDBC driver to 2.4.59 in the matrix_hana task
yrodiere Aug 30, 2019
a1662b3
Merge pull request #2 from hibernate/master
EdgarScott Sep 17, 2019
a651534
Merge branch 'add-tests-for-StringHelper' into master
EdgarScott Sep 17, 2019
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
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ task ciBuild {


wrapper {
gradleVersion = '4.10.2'
gradleVersion = '4.10.3'
distributionType = Wrapper.DistributionType.ALL
}

Expand Down
2 changes: 1 addition & 1 deletion databases/hana/matrix.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/

jdbcDependency 'com.sap.cloud.db.jdbc:ngdbc:2.2.16'
jdbcDependency 'com.sap.cloud.db.jdbc:ngdbc:2.4.59'
2 changes: 1 addition & 1 deletion databases/mariadb/matrix.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
jdbcDependency 'org.mariadb.jdbc:mariadb-java-client:1.5.7'
jdbcDependency 'org.mariadb.jdbc:mariadb-java-client:2.2.4'
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ The `DataSource` `ConnectionProvider` also (optionally) accepts the `hibernate.c
If specified, the https://docs.oracle.com/javase/8/docs/api/javax/sql/DataSource.html#getConnection-java.lang.String-java.lang.String-[`DataSource#getConnection(String username, String password)`] will be used.
Otherwise, the no-arg form is used.

[[database-connectionprovider-driver]]
=== Driver Configuration
`hibernate.connection.driver_class`:: The name of the JDBC Driver class to use
`hibernate.connection.url`:: The JDBC connection url
`hibernate.connection.*`:: All such setting names (except the <<appendices/Configurations.adoc#configurations-database-connection,predefined ones>>) will have the `hibernate.connection.` prefix stripped. The remaining name and the original value will be passed to the driver as a JDBC connection property

NOTE: Not all properties apply to all situations. For example, if you are providing a data source, `hibernate.connection.driver_class` setting will not be used.

[[database-connectionprovider-c3p0]]
=== Using c3p0

Expand All @@ -48,13 +56,10 @@ To use the c3p0 integration, the application must include the `hibernate-c3p0` m
====

Hibernate also provides support for applications to use http://www.mchange.com/projects/c3p0/[c3p0] connection pooling.
When using this c3p0 support, a number of additional configuration settings are recognized.
When c3p0 support is enabled, a number of c3p0-specific configuration settings are recognized in addition to the general ones described in <<database-connectionprovider-driver>>.

Transaction isolation of the Connections is managed by the `ConnectionProvider` itself. See <<database-connectionprovider-isolation>>.

`hibernate.connection.driver_class`:: The name of the JDBC Driver class to use
`hibernate.connection.url`:: The JDBC connection url.
Any settings prefixed with `hibernate.connection.` (other than the "special ones"):: These all have the `hibernate.connection.` prefix stripped and the rest will be passed as JDBC connection properties
`hibernate.c3p0.min_size` or `c3p0.minPoolSize`:: The minimum size of the c3p0 pool. See http://www.mchange.com/projects/c3p0/#minPoolSize[c3p0 minPoolSize]
`hibernate.c3p0.max_size` or `c3p0.maxPoolSize`:: The maximum size of the c3p0 pool. See http://www.mchange.com/projects/c3p0/#maxPoolSize[c3p0 maxPoolSize]
`hibernate.c3p0.timeout` or `c3p0.maxIdleTime`:: The Connection idle time. See http://www.mchange.com/projects/c3p0/#maxIdleTime[c3p0 maxIdleTime]
Expand Down
11 changes: 5 additions & 6 deletions gradle/libraries.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ ext {
geolatteVersion = '1.4.0'

// Wildfly version targeted by module ZIP; Arquillian/Shrinkwrap versions used for CDI testing and testing the module ZIP
wildflyVersion = '14.0.1.Final'
arquillianVersion = '1.4.0.Final'
wildflyVersion = '17.0.1.Final'
arquillianVersion = '1.4.1.Final'
shrinkwrapVersion = '1.2.6'
shrinkwrapDescriptorsVersion = '2.0.0'
wildflyArquillianContainerVersion = '2.1.1.Final'
wildflyArquillianContainerVersion = '2.2.0.Final'

jodaTimeVersion = '2.3'

Expand Down Expand Up @@ -109,8 +109,7 @@ ext {
hsqldb: "org.hsqldb:hsqldb:2.3.2",
derby: "org.apache.derby:derby:10.11.1.1",
postgresql: 'org.postgresql:postgresql:42.2.2',
//Upgrade MySQL Driver only when this issue gets fixed: https://bugs.mysql.com/bug.php?id=85941
mysql: 'mysql:mysql-connector-java:5.1.46',
mysql: 'mysql:mysql-connector-java:8.0.17',
mariadb: 'org.mariadb.jdbc:mariadb-java-client:2.2.3',

oracle: 'com.oracle.jdbc:ojdbc8:12.2.0.1',
Expand Down Expand Up @@ -159,7 +158,7 @@ ext {
wildfly_arquillian_container_managed: "org.wildfly.arquillian:wildfly-arquillian-container-managed:${wildflyArquillianContainerVersion}",
jboss_vfs: "org.jboss:jboss-vfs:3.2.11.Final",
jipijapa_spi: "org.wildfly:jipijapa-spi:${wildflyVersion}",
wildfly_transaction_client : 'org.wildfly.transaction:wildfly-transaction-client:1.0.3.Final',
wildfly_transaction_client : 'org.wildfly.transaction:wildfly-transaction-client:1.1.7.Final',

jboss_ejb_spec_jar : 'org.jboss.spec.javax.ejb:jboss-ejb-api_3.2_spec:1.0.0.Final',
jboss_annotation_spec_jar : 'org.jboss.spec.javax.annotation:jboss-annotations-api_1.2_spec:1.0.0.Final'
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
import static org.hibernate.cfg.AvailableSettings.MAX_FETCH_DEPTH;
import static org.hibernate.cfg.AvailableSettings.MULTI_TENANT_IDENTIFIER_RESOLVER;
import static org.hibernate.cfg.AvailableSettings.NATIVE_EXCEPTION_HANDLING_51_COMPLIANCE;
import static org.hibernate.cfg.AvailableSettings.OMIT_JOIN_OF_SUPERCLASS_TABLES;
import static org.hibernate.cfg.AvailableSettings.ORDER_INSERTS;
import static org.hibernate.cfg.AvailableSettings.JPA_CALLBACKS_ENABLED;
import static org.hibernate.cfg.AvailableSettings.ORDER_UPDATES;
Expand Down Expand Up @@ -212,6 +213,7 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions {
private final boolean procedureParameterNullPassingEnabled;
private final boolean collectionJoinSubqueryRewriteEnabled;
private boolean jdbcStyleParamsZeroBased;
private final boolean omitJoinOfSuperclassTablesEnabled;

// Caching
private boolean secondLevelCacheEnabled;
Expand Down Expand Up @@ -360,6 +362,7 @@ public SessionFactoryOptionsBuilder(StandardServiceRegistry serviceRegistry, Boo
CONVENTIONAL_JAVA_CONSTANTS, BOOLEAN, true );
this.procedureParameterNullPassingEnabled = cfgService.getSetting( PROCEDURE_NULL_PARAM_PASSING, BOOLEAN, false );
this.collectionJoinSubqueryRewriteEnabled = cfgService.getSetting( COLLECTION_JOIN_SUBQUERY, BOOLEAN, true );
this.omitJoinOfSuperclassTablesEnabled = cfgService.getSetting( OMIT_JOIN_OF_SUPERCLASS_TABLES, BOOLEAN, true );

final RegionFactory regionFactory = serviceRegistry.getService( RegionFactory.class );
if ( !NoCachingRegionFactory.class.isInstance( regionFactory ) ) {
Expand Down Expand Up @@ -1064,6 +1067,12 @@ public boolean isEnhancementAsProxyEnabled() {
return enhancementAsProxyEnabled;
}

@Override
public boolean isOmitJoinOfSuperclassTablesEnabled() {
return omitJoinOfSuperclassTablesEnabled;
}


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// In-flight mutation access

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,24 @@
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.ServiceConfigurationError;
import java.util.ServiceLoader;
import java.util.Set;
import java.util.function.Supplier;
import java.util.stream.Stream;

import org.hibernate.AssertionFailure;
import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.CoreMessageLogger;

/**
* A service loader bound to an {@link AggregatedClassLoader}.
* @param <S> The type of the service contract.
*/
abstract class AggregatedServiceLoader<S> {

private static final CoreMessageLogger log = CoreLogging.messageLogger( AggregatedServiceLoader.class );

private static final Method SERVICE_LOADER_STREAM_METHOD;
private static final Method PROVIDER_TYPE_METHOD;

Expand Down Expand Up @@ -145,17 +150,16 @@ public void close() {
* @param <S> The type of loaded services.
*/
private static class ClassPathAndModulePathAggregatedServiceLoader<S> extends AggregatedServiceLoader<S> {
private final Class<S> serviceContract;
private final ServiceLoader<S> aggregatedClassLoaderServiceLoader;
private final List<ServiceLoader<S>> delegates;
private Collection<S> cache = null;

private ClassPathAndModulePathAggregatedServiceLoader(AggregatedClassLoader aggregatedClassLoader,
Class<S> serviceContract) {
this.serviceContract = serviceContract;
this.delegates = new ArrayList<>();
// Always try the aggregated class loader first
this.delegates.add( ServiceLoader.load( serviceContract, aggregatedClassLoader ) );

// Then also try the individual class loaders,
// because only them can instantiate services provided by jars in the module path
this.aggregatedClassLoaderServiceLoader = ServiceLoader.load( serviceContract, aggregatedClassLoader );
final Iterator<ClassLoader> clIterator = aggregatedClassLoader.newClassLoaderIterator();
while ( clIterator.hasNext() ) {
this.delegates.add(
Expand Down Expand Up @@ -185,54 +189,94 @@ public Collection<S> getAll() {
return cache;
}

@SuppressWarnings("unchecked")
private Collection<S> loadAll() {
Set<String> alreadyEncountered = new HashSet<>();
Set<S> result = new LinkedHashSet<>();
delegates.stream()
// Each loader's stream() method returns a stream of service providers: flatten these into a single stream
.flatMap( delegate -> {
try {
return (Stream<? extends Supplier<S>>) SERVICE_LOADER_STREAM_METHOD.invoke( delegate );
}
catch (RuntimeException | IllegalAccessException | InvocationTargetException e) {
throw new AssertionFailure( "Error calling ServiceLoader.stream()", e );
}
} )
// For each provider, check its type to be sure we don't use a provider twice, then get the service
.forEach( provider -> {
Class<?> type;
try {
type = (Class<?>) PROVIDER_TYPE_METHOD.invoke( provider );
}
catch (RuntimeException | IllegalAccessException | InvocationTargetException e) {
throw new AssertionFailure( "Error calling ServiceLoader.Provider.type()", e );
}
String typeName = type.getName();
/*
* We may encounter the same service provider multiple times,
* because the individual class loaders may give access to the same types
* (at the very least a single class loader may be present twice in the aggregated class loader).
* However, we only want to get the service from each provider once.
*
* ServiceLoader.stream() is useful in that regard,
* since it allows us to check the type of the service provider
* before the service is even instantiated.
*
* We could just instantiate every service and check their type afterwards,
* but 1. it would lead to unnecessary instantiation which could have side effects,
* in particular regarding class loading,
* and 2. the type of the provider may not always be the type of the service,
* and one provider may return different types of services
* depending on conditions known only to itself.
*/
if ( alreadyEncountered.add( typeName ) ) {
result.add( provider.get() );
}
} );

// Always try the aggregated class loader first
Iterator<? extends Supplier<S>> providerIterator = providerStream( aggregatedClassLoaderServiceLoader )
.iterator();
while ( providerIterator.hasNext() ) {
Supplier<S> provider = providerIterator.next();
collectServiceIfNotDuplicate( result, alreadyEncountered, provider );
}

/*
* Then also try the individual class loaders,
* because only them can instantiate services provided by jars in the module path.
*/
for ( ServiceLoader<S> delegate : delegates ) {
providerIterator = providerStream( delegate ).iterator();
/*
* Note that advancing the stream itself can lead to (arguably) "legitimate" errors,
* where we fail to load the service,
* but only because individual classloader has its own definition of the service contract class,
* which is different from ours.
* In that case (still arguably), the error should be ignored.
* That's why we wrap the call to hasNext in a method that catches an logs errors.
* See https://hibernate.atlassian.net/browse/HHH-13551.
*/
while ( hasNextIgnoringServiceConfigurationError( providerIterator ) ) {
Supplier<S> provider = providerIterator.next();
collectServiceIfNotDuplicate( result, alreadyEncountered, provider );
}
}

return result;
}

@SuppressWarnings("unchecked")
private Stream<? extends Supplier<S>> providerStream(ServiceLoader<S> serviceLoader) {
try {
return ( (Stream<? extends Supplier<S>>) SERVICE_LOADER_STREAM_METHOD.invoke( serviceLoader ) );
}
catch (RuntimeException | IllegalAccessException | InvocationTargetException e) {
throw new AssertionFailure( "Error calling ServiceLoader.stream()", e );
}
}

private boolean hasNextIgnoringServiceConfigurationError(Iterator<?> iterator) {
while ( true ) {
try {
return iterator.hasNext();
}
catch (ServiceConfigurationError e) {
log.ignoringServiceConfigurationError( serviceContract, e );
}
}
}

/*
* We may encounter the same service provider multiple times,
* because the individual class loaders may give access to the same types
* (at the very least a single class loader may be present twice in the aggregated class loader).
* However, we only want to get the service from each provider once.
*
* ServiceLoader.stream() is useful in that regard,
* since it allows us to check the type of the service provider
* before the service is even instantiated.
*
* We could just instantiate every service and check their type afterwards,
* but 1. it would lead to unnecessary instantiation which could have side effects,
* in particular regarding class loading,
* and 2. the type of the provider may not always be the type of the service,
* and one provider may return different types of services
* depending on conditions known only to itself.
*/
private void collectServiceIfNotDuplicate(Set<S> result, Set<String> alreadyEncountered, Supplier<S> provider) {
Class<?> type;
try {
type = (Class<?>) PROVIDER_TYPE_METHOD.invoke( provider );
}
catch (RuntimeException | IllegalAccessException | InvocationTargetException e) {
throw new AssertionFailure( "Error calling ServiceLoader.Provider.type()", e );
}
String typeName = type.getName();
if ( alreadyEncountered.add( typeName ) ) {
result.add( provider.get() );
}
}

@Override
public void close() {
cache = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,4 +447,9 @@ public boolean areJPACallbacksEnabled() {
public boolean isEnhancementAsProxyEnabled() {
return delegate.isEnhancementAsProxyEnabled();
}

@Override
public boolean isOmitJoinOfSuperclassTablesEnabled() {
return delegate.isOmitJoinOfSuperclassTablesEnabled();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -314,4 +314,6 @@ default boolean areJPACallbacksEnabled() {
default boolean isEnhancementAsProxyEnabled() {
return false;
}

boolean isOmitJoinOfSuperclassTablesEnabled();
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ public Binding bind(InputStreamAccess xmlInputStreamAccess) {
xmlInputStream.close();
}
catch (IOException e) {
LOG.debugf( "Unable to close InputStream obtained from InputStreamAccess : " + xmlInputStreamAccess.getStreamName() );
LOG.debugf( "Unable to close InputStream obtained from InputStreamAccess : %s", xmlInputStreamAccess.getStreamName() );
}
}
}

public Binding bind(InputStream xmlInputStream) {
LOG.tracef( "reading mappings from InputStream" );
LOG.trace( "reading mappings from InputStream" );
final Origin origin = new Origin( SourceType.INPUT_STREAM, null );
return new InputStreamXmlSource( origin, xmlInputStream, false ).doBind( getMappingBinder() );
}
Expand Down
Loading