diff --git a/mapper/orm/src/main/java/org/hibernate/search/mapper/orm/loading/impl/MutableEntityLoadingOptions.java b/mapper/orm/src/main/java/org/hibernate/search/mapper/orm/loading/impl/MutableEntityLoadingOptions.java index a8669bf79df..776c86fc0e8 100644 --- a/mapper/orm/src/main/java/org/hibernate/search/mapper/orm/loading/impl/MutableEntityLoadingOptions.java +++ b/mapper/orm/src/main/java/org/hibernate/search/mapper/orm/loading/impl/MutableEntityLoadingOptions.java @@ -50,6 +50,9 @@ public void entityGraphHint(EntityGraphHint entityGraphHint, boolean replaceE else if ( replaceExisting ) { entityGraphHints.clear(); } + if ( entityGraphHint == null ) { + return; + } this.entityGraphHints.add( entityGraphHint ); } } diff --git a/mapper/orm/src/main/java/org/hibernate/search/mapper/orm/model/impl/HibernateOrmBasicTypeMetadataProvider.java b/mapper/orm/src/main/java/org/hibernate/search/mapper/orm/model/impl/HibernateOrmBasicTypeMetadataProvider.java index ace5fac92e4..aff98d5143e 100644 --- a/mapper/orm/src/main/java/org/hibernate/search/mapper/orm/model/impl/HibernateOrmBasicTypeMetadataProvider.java +++ b/mapper/orm/src/main/java/org/hibernate/search/mapper/orm/model/impl/HibernateOrmBasicTypeMetadataProvider.java @@ -23,7 +23,7 @@ import org.hibernate.mapping.Value; import org.hibernate.property.access.spi.Getter; -@SuppressWarnings( "unchecked" ) // Hibernate ORM gives us raw types, we must make do. +@SuppressWarnings( "unchecked" ) // Hibernate Commons annotations gives us wildcard types, we must make do. public class HibernateOrmBasicTypeMetadataProvider { public static HibernateOrmBasicTypeMetadataProvider create(Metadata metadata) { @@ -161,7 +161,7 @@ else if ( value instanceof org.hibernate.mapping.Array ) { else if ( value instanceof org.hibernate.mapping.Map ) { org.hibernate.mapping.Map map = (org.hibernate.mapping.Map) value; return HibernateOrmTypeModelFactory.map( - map.getCollectionType().getReturnedClass(), + (Class>) map.getCollectionType().getReturnedClass(), /* * Do not let ORM confuse you: getKey() doesn't return the value of the map key, * but the value of the foreign key to the targeted entity... @@ -174,7 +174,7 @@ else if ( value instanceof org.hibernate.mapping.Map ) { else if ( value instanceof org.hibernate.mapping.Collection ) { org.hibernate.mapping.Collection collection = (org.hibernate.mapping.Collection) value; return HibernateOrmTypeModelFactory.collection( - collection.getCollectionType().getReturnedClass(), + (Class>) collection.getCollectionType().getReturnedClass(), collectValue( metadataProviderBuilder, collection.getElement() ) ); } diff --git a/mapper/orm/src/main/java/org/hibernate/search/mapper/orm/search/query/impl/HibernateOrmSearchQueryAdapter.java b/mapper/orm/src/main/java/org/hibernate/search/mapper/orm/search/query/impl/HibernateOrmSearchQueryAdapter.java index 7203e7d6e8a..b6a7fb955e3 100644 --- a/mapper/orm/src/main/java/org/hibernate/search/mapper/orm/search/query/impl/HibernateOrmSearchQueryAdapter.java +++ b/mapper/orm/src/main/java/org/hibernate/search/mapper/orm/search/query/impl/HibernateOrmSearchQueryAdapter.java @@ -127,7 +127,7 @@ public HibernateOrmSearchQueryAdapter setHint(String hintName, Object value) case HibernateOrmSearchQueryHints.JAKARTA_FETCHGRAPH: case HibernateOrmSearchQueryHints.JAVAX_LOADGRAPH: case HibernateOrmSearchQueryHints.JAKARTA_LOADGRAPH: - applyEntityGraphQueryHint( hintName, hintValueToEntityGraph( value ) ); + applyEntityGraphHint( hintName, value ); break; default: log.ignoringUnrecognizedQueryHint( hintName ); @@ -143,25 +143,19 @@ public HibernateOrmSearchQueryAdapter setTimeout(int timeout) { } @Override - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings("rawtypes") public HibernateOrmSearchQueryAdapter applyGraph(RootGraph graph, GraphSemantic semantic) { - loadingOptions.entityGraphHint( new EntityGraphHint<>( graph, semantic ), true ); + applyGraph( (RootGraphImplementor) graph, semantic ); return this; } - @Override - protected void applyEntityGraphQueryHint(String hintName, RootGraphImplementor entityGraph) { - GraphSemantic graphSemantic = GraphSemantic.fromJpaHintName( hintName ); - this.applyGraph( entityGraph, graphSemantic ); - } - @Override public ScrollableResultsImplementor scroll() { return scroll( ScrollMode.FORWARD_ONLY ); } @Override - public ScrollableResultsImplementor scroll(ScrollMode scrollMode) { + protected ScrollableResultsImplementor doScroll(ScrollMode scrollMode) { if ( !ScrollMode.FORWARD_ONLY.equals( scrollMode ) ) { throw log.canOnlyUseScrollWithScrollModeForwardsOnly( scrollMode ); } @@ -187,8 +181,8 @@ protected List doList() { } @Override - protected void beforeQuery(boolean requiresTxn) { - super.beforeQuery( requiresTxn ); + protected void beforeQuery() { + super.beforeQuery(); extractQueryOptions(); } @@ -202,6 +196,11 @@ private void extractQueryOptions() { if ( queryTimeout != null ) { delegate.failAfter( queryTimeout, TimeUnit.SECONDS ); } + EntityGraphHint entityGraphHint = null; + if ( queryOptions.getGraph() != null ) { + entityGraphHint = new EntityGraphHint<>( queryOptions.getGraph(), queryOptions.getSemantic() ); + } + loadingOptions.entityGraphHint( entityGraphHint, true ); } //------------------------------------------------------------- @@ -225,7 +224,7 @@ public QueryParameterBindings getParameterBindings() { } @Override - protected QueryParameterBindings getQueryParameterBindings() { + public QueryParameterBindings getQueryParameterBindings() { // parameters not supported in Hibernate Search queries return QueryParameterBindings.NO_PARAM_BINDINGS; } @@ -321,8 +320,4 @@ private static int hintValueToInteger(Object value) { } } - private static RootGraphImplementor hintValueToEntityGraph(Object value) { - return (RootGraphImplementor) value; - } - } diff --git a/pom.xml b/pom.xml index 62c0a735e56..d4ae4ffb785 100644 --- a/pom.xml +++ b/pom.xml @@ -274,12 +274,12 @@ when the versions start diverging, thanks to the maven-enforcer-plugin and to our own explicit dependencies in the relevant artifacts. --> - 2.2.3.Final + 2.4.2.Final ${version.org.hibernate.commons.annotations.orm6} ${version.net.bytebuddy.orm6} - 6.0.0.Beta3 + 6.0.0.CR1 https://docs.jboss.org/hibernate/orm/${parsed-version.org.hibernate.orm.majorVersion}.${parsed-version.org.hibernate.orm.minorVersion}/javadocs/ 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 - 5.1.3.Final + 6.0.0.CR1 3.0.0 3.0.1 3.0.1 - 1.12.9 + 1.12.7 2.1.1 diff --git a/v5migrationhelper/orm/src/main/java/org/hibernate/search/FullTextSharedSessionBuilder.java b/v5migrationhelper/orm/src/main/java/org/hibernate/search/FullTextSharedSessionBuilder.java index 8d32aa98525..a5052405803 100644 --- a/v5migrationhelper/orm/src/main/java/org/hibernate/search/FullTextSharedSessionBuilder.java +++ b/v5migrationhelper/orm/src/main/java/org/hibernate/search/FullTextSharedSessionBuilder.java @@ -10,7 +10,6 @@ import jakarta.persistence.EntityManager; -import org.hibernate.ConnectionReleaseMode; import org.hibernate.Interceptor; import org.hibernate.Session; import org.hibernate.SharedSessionBuilder; @@ -40,10 +39,6 @@ public interface FullTextSharedSessionBuilder extends SharedSessionBuilder { @Override FullTextSharedSessionBuilder autoClose(); - @Deprecated - @Override - FullTextSharedSessionBuilder flushBeforeCompletion(); - @Deprecated @Override FullTextSharedSessionBuilder transactionContext(); @@ -57,10 +52,6 @@ public interface FullTextSharedSessionBuilder extends SharedSessionBuilder { @Override FullTextSharedSessionBuilder connection(Connection connection); - @Deprecated - @Override - FullTextSharedSessionBuilder connectionReleaseMode(ConnectionReleaseMode connectionReleaseMode); - @Override FullTextSharedSessionBuilder autoJoinTransactions(boolean autoJoinTransactions); @@ -68,10 +59,6 @@ public interface FullTextSharedSessionBuilder extends SharedSessionBuilder { @Override FullTextSharedSessionBuilder autoClose(boolean autoClose); - @Deprecated - @Override - FullTextSharedSessionBuilder flushBeforeCompletion(boolean flushBeforeCompletion); - @Override FullTextSession openSession(); diff --git a/v5migrationhelper/orm/src/main/java/org/hibernate/search/impl/FullTextSharedSessionBuilderDelegator.java b/v5migrationhelper/orm/src/main/java/org/hibernate/search/impl/FullTextSharedSessionBuilderDelegator.java index 9f6bfae6659..741c9c58984 100644 --- a/v5migrationhelper/orm/src/main/java/org/hibernate/search/impl/FullTextSharedSessionBuilderDelegator.java +++ b/v5migrationhelper/orm/src/main/java/org/hibernate/search/impl/FullTextSharedSessionBuilderDelegator.java @@ -9,7 +9,6 @@ import java.sql.Connection; import java.util.TimeZone; -import org.hibernate.ConnectionReleaseMode; import org.hibernate.FlushMode; import org.hibernate.Interceptor; import org.hibernate.SessionBuilder; @@ -63,13 +62,6 @@ public FullTextSharedSessionBuilder autoClose() { return this; } - @Deprecated - @Override - public FullTextSharedSessionBuilder flushBeforeCompletion() { - builder.flushBeforeCompletion(); - return this; - } - @Deprecated @Override public FullTextSharedSessionBuilder transactionContext() { @@ -95,13 +87,6 @@ public FullTextSharedSessionBuilder connection(Connection connection) { return this; } - @Deprecated - @Override - public FullTextSharedSessionBuilder connectionReleaseMode(ConnectionReleaseMode connectionReleaseMode) { - builder.connectionReleaseMode( connectionReleaseMode ); - return this; - } - @Override public FullTextSharedSessionBuilder autoJoinTransactions(boolean autoJoinTransactions) { builder.autoJoinTransactions( autoJoinTransactions ); @@ -115,13 +100,6 @@ public FullTextSharedSessionBuilder autoClose(boolean autoClose) { return this; } - @Deprecated - @Override - public FullTextSharedSessionBuilder flushBeforeCompletion(boolean flushBeforeCompletion) { - builder.flushBeforeCompletion( flushBeforeCompletion ); - return this; - } - @Override public FullTextSession openSession() { return Search.getFullTextSession( builder.openSession() ); diff --git a/v5migrationhelper/orm/src/main/java/org/hibernate/search/query/hibernate/impl/FullTextQueryImpl.java b/v5migrationhelper/orm/src/main/java/org/hibernate/search/query/hibernate/impl/FullTextQueryImpl.java index 8e34239ef1b..f46722f7b25 100644 --- a/v5migrationhelper/orm/src/main/java/org/hibernate/search/query/hibernate/impl/FullTextQueryImpl.java +++ b/v5migrationhelper/orm/src/main/java/org/hibernate/search/query/hibernate/impl/FullTextQueryImpl.java @@ -14,10 +14,6 @@ import java.util.concurrent.TimeUnit; import java.util.function.Consumer; import java.util.function.Function; -import jakarta.persistence.FlushModeType; -import jakarta.persistence.LockModeType; -import jakarta.persistence.PersistenceException; -import jakarta.persistence.QueryTimeoutException; import org.hibernate.HibernateException; import org.hibernate.LockMode; @@ -53,6 +49,10 @@ import org.hibernate.search.util.common.SearchTimeoutException; import org.hibernate.transform.ResultTransformer; +import jakarta.persistence.FlushModeType; +import jakarta.persistence.LockModeType; +import jakarta.persistence.PersistenceException; +import jakarta.persistence.QueryTimeoutException; import org.apache.lucene.search.Explanation; import org.apache.lucene.search.Query; import org.apache.lucene.search.Sort; @@ -116,6 +116,11 @@ public List getResultList() { @Override public ScrollableResultsImplementor scroll() { + return scroll( ScrollMode.FORWARD_ONLY ); + } + + @Override + protected ScrollableResultsImplementor doScroll(ScrollMode scrollMode) { extractQueryOptions(); SearchScroll scroll = hSearchQuery.scroll( fetchSize != null ? fetchSize : 100 ); Integer maxResults = hSearchQuery.maxResults(); @@ -124,11 +129,6 @@ public ScrollableResultsImplementor scroll() { Search5ScrollHitExtractor.INSTANCE ); } - @Override - public ScrollableResultsImplementor scroll(ScrollMode scrollMode) { - return scroll(); - } - @Override public List list() { try { @@ -149,8 +149,8 @@ protected List doList() { } @Override - protected void beforeQuery(boolean requiresTxn) { - super.beforeQuery( requiresTxn ); + protected void beforeQuery() { + super.beforeQuery(); extractQueryOptions(); } @@ -199,11 +199,16 @@ public int doGetResultSize() { } @Override - public FullTextQueryImpl applyGraph(RootGraph graph, GraphSemantic semantic) { - entityGraphHints.add( new EntityGraphHint<>( graph, semantic ) ); + public FullTextQuery applyGraph(RootGraph graph, GraphSemantic semantic) { + applyGraph( (RootGraphImplementor) graph, semantic ); return this; } + @Override + protected void applyGraph(RootGraphImplementor graph, GraphSemantic semantic) { + entityGraphHints.add( new EntityGraphHint<>( graph, semantic ) ); + } + @Override public FullTextQueryImpl setProjection(String... fields) { hSearchQuery.projection( fields ); @@ -250,7 +255,7 @@ public FullTextQuery setHint(String hintName, Object value) { case HibernateOrmSearchQueryHints.JAKARTA_FETCHGRAPH: case HibernateOrmSearchQueryHints.JAVAX_LOADGRAPH: case HibernateOrmSearchQueryHints.JAKARTA_LOADGRAPH: - applyEntityGraphQueryHint( hintName, hintValueToEntityGraph( value ) ); + applyEntityGraphHint( hintName, hintValueToEntityGraph( value ) ); break; default: break; @@ -258,12 +263,6 @@ public FullTextQuery setHint(String hintName, Object value) { return this; } - @Override - protected void applyEntityGraphQueryHint(String hintName, RootGraphImplementor entityGraph) { - GraphSemantic graphSemantic = GraphSemantic.fromJpaHintName( hintName ); - this.applyGraph( entityGraph, graphSemantic ); - } - @Override public Map getHints() { return hints; @@ -281,7 +280,7 @@ public QueryParameterBindings getParameterBindings() { } @Override - protected QueryParameterBindings getQueryParameterBindings() { + public QueryParameterBindings getQueryParameterBindings() { // parameters not supported in Hibernate Search queries return QueryParameterBindings.NO_PARAM_BINDINGS; }