Skip to content

HSEARCH-5380 Upgrade to Hibernate ORM 7.0.0.CR2 / HSEARCH-5383 Upgrade to Hibernate ORM 7.0.0.Final #4616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
7 changes: 2 additions & 5 deletions build/config/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,6 @@
<artifact>jakarta.persistence:jakarta.persistence-api</artifact>
<failOnNotFound>true</failOnNotFound>
</item>
<item>
<property>${version.org.hibernate.models}</property>
<artifact>org.hibernate.models:hibernate-models</artifact>
<failOnNotFound>true</failOnNotFound>
</item>
</propertiesToCheck>
</versionAlignRule>
</rules>
Expand Down Expand Up @@ -232,6 +227,7 @@
This would mean that a corresponding pattern will only be applied to filtering of internal/public rules.
If no prefix is specified then rule is considered to be both public and internal at the same time.
-->

<argument>^org\.hibernate\.query\.Query$</argument>
<argument>^org\.hibernate\.query\.SelectionQuery$</argument>
<argument>^org\.hibernate\.query\.MutationQuery$</argument>
Expand All @@ -243,6 +239,7 @@
<argument>^org\.hibernate\.metamodel\.mapping\.SelectableMapping$</argument>
<argument>^org\.hibernate\.metamodel\.mapping\.SelectablePath$</argument>
<argument>^org\.hibernate\.metamodel\.model\.domain\.JpaMetamodel$</argument>
<argument>^org\.hibernate\.metamodel\.model\.domain\.NavigableRole$</argument>

<argument>^org\.hibernate\.boot\.spi\.BootstrapContext\b.*+$</argument>
<argument>^org\.hibernate\.boot\.spi\.AdditionalMappingContributor$</argument>
Expand Down
8 changes: 1 addition & 7 deletions build/parents/build/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@
NOTE: when Hibernate ORM updates Byte Buddy, make sure to check Jenkinsfile to see if
`net.bytebuddy.experimental` property can be removed.
-->
<version.org.hibernate.orm>7.0.0.CR1</version.org.hibernate.orm>
<version.org.hibernate.models>1.0.0.CR1</version.org.hibernate.models>
<version.org.hibernate.orm>7.0.0.Final</version.org.hibernate.orm>

<javadoc.org.hibernate.orm.url>https://docs.jboss.org/hibernate/orm/${parsed-version.org.hibernate.orm.majorVersion}.${parsed-version.org.hibernate.orm.minorVersion}/javadocs/</javadoc.org.hibernate.orm.url>
<documentation.org.hibernate.orm.url>https://docs.jboss.org/hibernate/orm/${parsed-version.org.hibernate.orm.majorVersion}.${parsed-version.org.hibernate.orm.minorVersion}/userguide/html_single/Hibernate_User_Guide.html</documentation.org.hibernate.orm.url>
Expand Down Expand Up @@ -407,11 +406,6 @@
<artifactId>jboss-logging</artifactId>
<version>${version.org.jboss.logging.jboss-logging}</version>
</dependency>
<dependency>
<groupId>org.hibernate.models</groupId>
<artifactId>hibernate-models-jandex</artifactId>
<version>${version.org.hibernate.models}</version>
</dependency>

<!-- Other public dependencies -->
<!-- Elasticsearch backend -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
*/
package org.hibernate.search.engine.environment.classpath.spi;

import java.net.URL;
import java.util.Collection;

import org.hibernate.search.util.common.annotation.Incubating;

Expand Down Expand Up @@ -37,24 +35,4 @@ public interface ClassResolver {
@Incubating
Package packageForName(String packageName);

/**
* Locate a resource by name
*
* @param resourceName The name of the resource to resolve
* @return The located resource;
* may return {@code null} to indicate the resource was not found
*/
@Incubating
URL locateResource(String resourceName);

/**
* Discovers and instantiates implementations of the given {@link java.util.ServiceLoader Java service} contract.
*
* @param serviceType The java type defining the service contract
* @param <S> The type of the service contract
*
* @return The ordered set of discovered services.
*/
@Incubating
<S> Collection<S> loadJavaServices(Class<S> serviceType);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,9 @@
*/
package org.hibernate.search.engine.environment.classpath.spi;

import java.net.URL;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.ServiceLoader;
import java.util.Set;

import org.hibernate.search.engine.logging.impl.EngineMiscLog;

import org.hibernate.search.util.common.annotation.Incubating;

/**
* Default implementation of {@code ClassResolver} relying on an {@link AggregatedClassLoader}.
Expand Down Expand Up @@ -52,27 +46,8 @@ public Package packageForName(String packageName) {
}
}

@Override
public URL locateResource(String resourceName) {
try {
return aggregatedClassLoader.getResource( resourceName );
}
catch (Exception e) {
return null;
}
@Incubating
public AggregatedClassLoader aggregatedClassLoader() {
return aggregatedClassLoader;
}

@Override
public <S> Collection<S> loadJavaServices(Class<S> serviceType) {
ServiceLoader<S> loadedServices = ServiceLoader.load( serviceType, aggregatedClassLoader );
Iterator<S> iterator = loadedServices.iterator();
Set<S> services = new HashSet<>();

while ( iterator.hasNext() ) {
services.add( iterator.next() );
}

return services;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,14 @@ public InputStream locateResourceStream(String name) {
return null;
}

@Override
public URL locateResource(String resourceName) {
try {
return aggregatedClassLoader.getResource( resourceName );
}
catch (Exception e) {
return null;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
package org.hibernate.search.engine.environment.classpath.spi;

import java.io.InputStream;
import java.net.URL;

import org.hibernate.search.util.common.annotation.Incubating;

/**
* A resolver of Java resources.
Expand All @@ -22,4 +25,14 @@ public interface ResourceResolver {
* @return The stream of the located resource; may return {@code null} to indicate the resource was not found
*/
InputStream locateResourceStream(String name);

/**
* Locate a resource by name
*
* @param resourceName The name of the resource to resolve
* @return The located resource;
* may return {@code null} to indicate the resource was not found
*/
@Incubating
URL locateResource(String resourceName);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import jakarta.persistence.PessimisticLockException;

import org.hibernate.LockMode;
import org.hibernate.LockOptions;
import org.hibernate.Session;
import org.hibernate.dialect.Dialect;
import org.hibernate.query.Query;
Expand All @@ -27,7 +26,7 @@ final class OutboxEventLoader implements ToStringTreeAppendable {

private static final String LOAD_QUERY_STRING = "select e from " + ENTITY_NAME + " e where e.id in (:ids)";

private final LockOptions lockOptions;
private final LockMode lockMode;

OutboxEventLoader(Dialect dialect) {
// HSEARCH-4289: some databases encounter deadlocks when multiple processors query or delete events
Expand All @@ -46,7 +45,7 @@ final class OutboxEventLoader implements ToStringTreeAppendable {
// so we can afford to just skip events that are already locked,
// and process them later when they are no longer locked.
if ( dialect.supportsSkipLocked() ) {
lockOptions = new LockOptions( LockMode.UPGRADE_SKIPLOCKED );
lockMode = LockMode.UPGRADE_SKIPLOCKED;
}
// If LockMode.UPGRADE_SKIPLOCKED is not supported, we just do basic locking and hope for the best
// (in particular we hope for transaction deadlocks to be detected by the database and result in a failure,
Expand All @@ -57,7 +56,7 @@ final class OutboxEventLoader implements ToStringTreeAppendable {
// so as long as we target a distinct set of events in each processor (we do),
// locking shouldn't trigger any deadlocks.
else {
lockOptions = new LockOptions( LockMode.PESSIMISTIC_WRITE );
lockMode = LockMode.PESSIMISTIC_WRITE;
}
}

Expand All @@ -69,16 +68,15 @@ public String toString() {
@Override
public void appendTo(ToStringTreeAppender appender) {
appender.startObject( "lockOptions" )
.attribute( "lockMode", lockOptions.getLockMode() )
.attribute( "timeout", lockOptions.getTimeOut() )
.attribute( "lockMode", lockMode )
.endObject();
}

List<OutboxEvent> loadLocking(Session session, Set<UUID> ids, String processorName) {
try {
Query<OutboxEvent> query = session.createQuery( LOAD_QUERY_STRING, OutboxEvent.class );
query.setParameter( "ids", ids );
query.setLockOptions( lockOptions );
query.setHibernateLockMode( lockMode );
return query.getResultList();
}
catch (PessimisticLockException | OptimisticLockException lockException) {
Expand Down
4 changes: 0 additions & 4 deletions mapper/orm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@
<groupId>org.hibernate.models</groupId>
<artifactId>hibernate-models</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate.models</groupId>
<artifactId>hibernate-models-jandex</artifactId>
</dependency>
<dependency>
<groupId>jakarta.persistence</groupId>
<artifactId>jakarta.persistence-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public URL locateResource(String resourceName) {
// ignore
}
if ( url == null ) {
url = internalClassResolver.locateResource( resourceName );
url = internalResourceResolver.locateResource( resourceName );
}
return url;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import java.util.List;

import org.hibernate.LockOptions;
import org.hibernate.LockMode;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.query.QueryFlushMode;
import org.hibernate.search.mapper.orm.common.spi.TransactionHelper;
Expand Down Expand Up @@ -57,15 +57,15 @@ public void load(List<I> identifiers) throws InterruptedException {
private List<E> multiLoad(List<I> identifiers) {
return typeQueryLoader.createMultiIdentifierLoadAccess( session )
.with( options.cacheMode() )
.with( LockOptions.NONE )
.with( LockMode.NONE )
.multiLoad( identifiers );
}

private List<E> queryByIds(List<I> identifiers) {
return typeQueryLoader.createLoadingQuery( session, ID_PARAMETER_NAME )
.setParameter( ID_PARAMETER_NAME, identifiers )
.setCacheMode( options.cacheMode() )
.setLockOptions( LockOptions.NONE )
.setHibernateLockMode( LockMode.NONE )
.setCacheable( false )
.setQueryFlushMode( QueryFlushMode.NO_FLUSH )
.setFetchSize( identifiers.size() )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,9 @@ public LockModeType getLockMode() {
throw lockOptionsNotSupported();
}

@Deprecated(since = "8.0")
@Override
@SuppressWarnings("removal")
public LockOptions getLockOptions() {
/*
* Ideally we'd throw an UnsupportedOperationException,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.hibernate.boot.spi.MetadataImplementor;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.dialect.H2Dialect;
import org.hibernate.models.internal.BasicModelsContextImpl;
import org.hibernate.models.spi.ModelsConfiguration;
import org.hibernate.models.spi.ModelsContext;
import org.hibernate.search.util.common.impl.Closer;
import org.hibernate.search.util.common.reflect.spi.ValueHandleFactory;
Expand Down Expand Up @@ -78,12 +78,9 @@ public static ModelsContext createModelBuildingContext(BootstrapContext bootstra
ClassLoaderService classLoaderService =
getServiceOrEmpty( bootstrapContext.getServiceRegistry(), ClassLoaderService.class )
.orElseThrow();
ClassLoaderServiceLoading classLoading = new ClassLoaderServiceLoading( classLoaderService );
return new BasicModelsContextImpl(
classLoading,
ModelsHelper::preFillRegistries
);
return new ModelsConfiguration()
.setClassLoading( new ClassLoaderServiceLoading( classLoaderService ) )
.setRegistryPrimer( ModelsHelper::preFillRegistries )
.bootstrap();
}


}
27 changes: 23 additions & 4 deletions mapper/pojo-base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@
<groupId>org.hibernate.models</groupId>
<artifactId>hibernate-models</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate.models</groupId>
<artifactId>hibernate-models-jandex</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
Expand All @@ -51,4 +47,27 @@
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.moditect</groupId>
<artifactId>moditect-maven-plugin</artifactId>
<executions>
<execution>
<id>add-module-infos</id>
<configuration>
<module>
<moduleInfo>
<uses>
org.hibernate.models.spi.ModelsContextProvider;
</uses>
</moduleInfo>
</module>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Loading