Skip to content

Commit 2287233

Browse files
committed
HSEARCH-4465 Upgrade to Hibernate ORM 6.0.0.CR1
1 parent 08a9a7f commit 2287233

File tree

7 files changed

+44
-82
lines changed

7 files changed

+44
-82
lines changed

mapper/orm/src/main/java/org/hibernate/search/mapper/orm/loading/impl/MutableEntityLoadingOptions.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ public void entityGraphHint(EntityGraphHint<?> entityGraphHint, boolean replaceE
5050
else if ( replaceExisting ) {
5151
entityGraphHints.clear();
5252
}
53+
if ( entityGraphHint == null ) {
54+
return;
55+
}
5356
this.entityGraphHints.add( entityGraphHint );
5457
}
5558
}

mapper/orm/src/main/java/org/hibernate/search/mapper/orm/model/impl/HibernateOrmBasicTypeMetadataProvider.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import org.hibernate.mapping.Value;
2424
import org.hibernate.property.access.spi.Getter;
2525

26-
@SuppressWarnings( "unchecked" ) // Hibernate ORM gives us raw types, we must make do.
26+
@SuppressWarnings( "unchecked" ) // Hibernate Commons annotations gives us wildcard types, we must make do.
2727
public class HibernateOrmBasicTypeMetadataProvider {
2828

2929
public static HibernateOrmBasicTypeMetadataProvider create(Metadata metadata) {
@@ -161,7 +161,7 @@ else if ( value instanceof org.hibernate.mapping.Array ) {
161161
else if ( value instanceof org.hibernate.mapping.Map ) {
162162
org.hibernate.mapping.Map map = (org.hibernate.mapping.Map) value;
163163
return HibernateOrmTypeModelFactory.map(
164-
map.getCollectionType().getReturnedClass(),
164+
(Class<? extends Map<?, ?>>) map.getCollectionType().getReturnedClass(),
165165
/*
166166
* Do not let ORM confuse you: getKey() doesn't return the value of the map key,
167167
* but the value of the foreign key to the targeted entity...
@@ -174,7 +174,7 @@ else if ( value instanceof org.hibernate.mapping.Map ) {
174174
else if ( value instanceof org.hibernate.mapping.Collection ) {
175175
org.hibernate.mapping.Collection collection = (org.hibernate.mapping.Collection) value;
176176
return HibernateOrmTypeModelFactory.collection(
177-
collection.getCollectionType().getReturnedClass(),
177+
(Class<? extends Collection<?>>) collection.getCollectionType().getReturnedClass(),
178178
collectValue( metadataProviderBuilder, collection.getElement() )
179179
);
180180
}

mapper/orm/src/main/java/org/hibernate/search/mapper/orm/search/query/impl/HibernateOrmSearchQueryAdapter.java

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public HibernateOrmSearchQueryAdapter<R> setHint(String hintName, Object value)
129129
case HibernateOrmSearchQueryHints.JAKARTA_FETCHGRAPH:
130130
case HibernateOrmSearchQueryHints.JAVAX_LOADGRAPH:
131131
case HibernateOrmSearchQueryHints.JAKARTA_LOADGRAPH:
132-
applyEntityGraphQueryHint( hintName, hintValueToEntityGraph( value ) );
132+
applyEntityGraphHint( hintName, value );
133133
break;
134134
default:
135135
log.ignoringUnrecognizedQueryHint( hintName );
@@ -145,25 +145,19 @@ public HibernateOrmSearchQueryAdapter<R> setTimeout(int timeout) {
145145
}
146146

147147
@Override
148-
@SuppressWarnings({ "unchecked", "rawtypes" })
148+
@SuppressWarnings("rawtypes")
149149
public HibernateOrmSearchQueryAdapter<R> applyGraph(RootGraph graph, GraphSemantic semantic) {
150-
loadingOptions.entityGraphHint( new EntityGraphHint<>( graph, semantic ), true );
150+
applyGraph( (RootGraphImplementor) graph, semantic );
151151
return this;
152152
}
153153

154154
@Override
155-
protected void applyEntityGraphQueryHint(String hintName, RootGraphImplementor<?> entityGraph) {
156-
GraphSemantic graphSemantic = GraphSemantic.fromJpaHintName( hintName );
157-
this.applyGraph( entityGraph, graphSemantic );
158-
}
159-
160-
@Override
161-
public ScrollableResultsImplementor scroll() {
155+
public ScrollableResultsImplementor<R> scroll() {
162156
return scroll( ScrollMode.FORWARD_ONLY );
163157
}
164158

165159
@Override
166-
public ScrollableResultsImplementor scroll(ScrollMode scrollMode) {
160+
protected ScrollableResultsImplementor<R> doScroll(ScrollMode scrollMode) {
167161
if ( !ScrollMode.FORWARD_ONLY.equals( scrollMode ) ) {
168162
throw log.canOnlyUseScrollWithScrollModeForwardsOnly( scrollMode );
169163
}
@@ -189,8 +183,8 @@ protected List<R> doList() {
189183
}
190184

191185
@Override
192-
protected void beforeQuery(boolean requiresTxn) {
193-
super.beforeQuery( requiresTxn );
186+
protected void beforeQuery() {
187+
super.beforeQuery();
194188

195189
extractQueryOptions();
196190
}
@@ -204,6 +198,11 @@ private void extractQueryOptions() {
204198
if ( queryTimeout != null ) {
205199
delegate.failAfter( queryTimeout, TimeUnit.SECONDS );
206200
}
201+
EntityGraphHint<?> entityGraphHint = null;
202+
if ( queryOptions.getGraph() != null ) {
203+
entityGraphHint = new EntityGraphHint<>( queryOptions.getGraph(), queryOptions.getSemantic() );
204+
}
205+
loadingOptions.entityGraphHint( entityGraphHint, true );
207206
}
208207

209208
//-------------------------------------------------------------
@@ -227,7 +226,7 @@ public QueryParameterBindings getParameterBindings() {
227226
}
228227

229228
@Override
230-
protected QueryParameterBindings getQueryParameterBindings() {
229+
public QueryParameterBindings getQueryParameterBindings() {
231230
// parameters not supported in Hibernate Search queries
232231
return QueryParameterBindings.NO_PARAM_BINDINGS;
233232
}
@@ -328,8 +327,4 @@ private static int hintValueToInteger(Object value) {
328327
}
329328
}
330329

331-
private static RootGraphImplementor<?> hintValueToEntityGraph(Object value) {
332-
return (RootGraphImplementor<?>) value;
333-
}
334-
335330
}

pom.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,12 +257,12 @@
257257
when the versions start diverging, thanks to the maven-enforcer-plugin
258258
and to our own explicit dependencies in the relevant artifacts.
259259
-->
260-
<version.org.jboss.jandex>2.2.3.Final</version.org.jboss.jandex>
260+
<version.org.jboss.jandex>2.4.2.Final</version.org.jboss.jandex>
261261
<version.org.hibernate.commons.annotations>${version.org.hibernate.commons.annotations.orm6}</version.org.hibernate.commons.annotations>
262262
<version.net.bytebuddy>${version.net.bytebuddy.orm6}</version.net.bytebuddy>
263263

264264
<!-- >>> ORM 6 with Jakarta Persistence -->
265-
<version.org.hibernate.orm>6.0.0.Beta3</version.org.hibernate.orm>
265+
<version.org.hibernate.orm>6.0.0.CR1</version.org.hibernate.orm>
266266
<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>
267267
<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>
268268
<!-- These version must be kept in sync with the version of the dependency in Hibernate ORM 6.
@@ -272,13 +272,13 @@
272272
and to our own explicit dependencies in the relevant artifacts.
273273
-->
274274
<version.io.smallrye.jandex>3.0.5</version.io.smallrye.jandex>
275-
<version.org.hibernate.commons.annotations.orm6>5.1.3.Final</version.org.hibernate.commons.annotations.orm6>
275+
<version.org.hibernate.commons.annotations.orm6>6.0.0.CR1</version.org.hibernate.commons.annotations.orm6>
276276
<version.jakarta.persistence>3.0.0</version.jakarta.persistence>
277277
<version.jakarta.transaction-api>2.0.0</version.jakarta.transaction-api>
278278
<version.jakarta.interceptor-api>2.0.1</version.jakarta.interceptor-api>
279279
<version.jakarta.enterprise>3.0.1</version.jakarta.enterprise>
280-
<version.jakarta.xml.bind>4.0.0</version.jakarta.xml.bind>
281-
<version.net.bytebuddy.orm6>1.12.18</version.net.bytebuddy.orm6>
280+
<version.jakarta.xml.bind>3.0.1</version.jakarta.xml.bind>
281+
<version.net.bytebuddy.orm6>1.12.7</version.net.bytebuddy.orm6>
282282

283283
<!-- >>> JSR 352 -->
284284
<version.jakarta.batch>2.1.1</version.jakarta.batch>

v5migrationhelper/orm/src/main/java/org/hibernate/search/FullTextSharedSessionBuilder.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
import jakarta.persistence.EntityManager;
1212

13-
import org.hibernate.ConnectionReleaseMode;
1413
import org.hibernate.Interceptor;
1514
import org.hibernate.Session;
1615
import org.hibernate.SharedSessionBuilder;
@@ -40,10 +39,6 @@ public interface FullTextSharedSessionBuilder extends SharedSessionBuilder {
4039
@Override
4140
FullTextSharedSessionBuilder autoClose();
4241

43-
@Deprecated
44-
@Override
45-
FullTextSharedSessionBuilder flushBeforeCompletion();
46-
4742
@Deprecated
4843
@Override
4944
FullTextSharedSessionBuilder transactionContext();
@@ -57,21 +52,13 @@ public interface FullTextSharedSessionBuilder extends SharedSessionBuilder {
5752
@Override
5853
FullTextSharedSessionBuilder connection(Connection connection);
5954

60-
@Deprecated
61-
@Override
62-
FullTextSharedSessionBuilder connectionReleaseMode(ConnectionReleaseMode connectionReleaseMode);
63-
6455
@Override
6556
FullTextSharedSessionBuilder autoJoinTransactions(boolean autoJoinTransactions);
6657

6758
@Deprecated
6859
@Override
6960
FullTextSharedSessionBuilder autoClose(boolean autoClose);
7061

71-
@Deprecated
72-
@Override
73-
FullTextSharedSessionBuilder flushBeforeCompletion(boolean flushBeforeCompletion);
74-
7562
@Override
7663
FullTextSession openSession();
7764

v5migrationhelper/orm/src/main/java/org/hibernate/search/impl/FullTextSharedSessionBuilderDelegator.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import java.sql.Connection;
1010
import java.util.TimeZone;
1111

12-
import org.hibernate.ConnectionReleaseMode;
1312
import org.hibernate.FlushMode;
1413
import org.hibernate.Interceptor;
1514
import org.hibernate.SessionBuilder;
@@ -63,13 +62,6 @@ public FullTextSharedSessionBuilder autoClose() {
6362
return this;
6463
}
6564

66-
@Deprecated
67-
@Override
68-
public FullTextSharedSessionBuilder flushBeforeCompletion() {
69-
builder.flushBeforeCompletion();
70-
return this;
71-
}
72-
7365
@Deprecated
7466
@Override
7567
public FullTextSharedSessionBuilder transactionContext() {
@@ -95,13 +87,6 @@ public FullTextSharedSessionBuilder connection(Connection connection) {
9587
return this;
9688
}
9789

98-
@Deprecated
99-
@Override
100-
public FullTextSharedSessionBuilder connectionReleaseMode(ConnectionReleaseMode connectionReleaseMode) {
101-
builder.connectionReleaseMode( connectionReleaseMode );
102-
return this;
103-
}
104-
10590
@Override
10691
public FullTextSharedSessionBuilder autoJoinTransactions(boolean autoJoinTransactions) {
10792
builder.autoJoinTransactions( autoJoinTransactions );
@@ -115,13 +100,6 @@ public FullTextSharedSessionBuilder autoClose(boolean autoClose) {
115100
return this;
116101
}
117102

118-
@Deprecated
119-
@Override
120-
public FullTextSharedSessionBuilder flushBeforeCompletion(boolean flushBeforeCompletion) {
121-
builder.flushBeforeCompletion( flushBeforeCompletion );
122-
return this;
123-
}
124-
125103
@Override
126104
public FullTextSession openSession() {
127105
return Search.getFullTextSession( builder.openSession() );

v5migrationhelper/orm/src/main/java/org/hibernate/search/query/hibernate/impl/FullTextQueryImpl.java

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@
1313
import java.util.concurrent.TimeUnit;
1414
import java.util.function.Consumer;
1515
import java.util.function.Function;
16-
import jakarta.persistence.FlushModeType;
17-
import jakarta.persistence.LockModeType;
1816
import jakarta.persistence.Parameter;
19-
import jakarta.persistence.PersistenceException;
20-
import jakarta.persistence.QueryTimeoutException;
2117

2218
import org.hibernate.HibernateException;
2319
import org.hibernate.LockMode;
@@ -55,6 +51,10 @@
5551
import org.hibernate.search.util.common.SearchTimeoutException;
5652
import org.hibernate.transform.ResultTransformer;
5753

54+
import jakarta.persistence.FlushModeType;
55+
import jakarta.persistence.LockModeType;
56+
import jakarta.persistence.PersistenceException;
57+
import jakarta.persistence.QueryTimeoutException;
5858
import org.apache.lucene.search.Explanation;
5959
import org.apache.lucene.search.Query;
6060
import org.apache.lucene.search.Sort;
@@ -118,6 +118,11 @@ public List getResultList() {
118118

119119
@Override
120120
public ScrollableResultsImplementor scroll() {
121+
return scroll( ScrollMode.FORWARD_ONLY );
122+
}
123+
124+
@Override
125+
protected ScrollableResultsImplementor doScroll(ScrollMode scrollMode) {
121126
extractQueryOptions();
122127
SearchScroll<?> scroll = hSearchQuery.scroll( fetchSize != null ? fetchSize : 100 );
123128
Integer maxResults = hSearchQuery.maxResults();
@@ -126,11 +131,6 @@ public ScrollableResultsImplementor scroll() {
126131
Search5ScrollHitExtractor.INSTANCE );
127132
}
128133

129-
@Override
130-
public ScrollableResultsImplementor scroll(ScrollMode scrollMode) {
131-
return scroll();
132-
}
133-
134134
@Override
135135
public List list() {
136136
try {
@@ -151,8 +151,8 @@ protected List doList() {
151151
}
152152

153153
@Override
154-
protected void beforeQuery(boolean requiresTxn) {
155-
super.beforeQuery( requiresTxn );
154+
protected void beforeQuery() {
155+
super.beforeQuery();
156156

157157
extractQueryOptions();
158158
}
@@ -201,11 +201,16 @@ public int doGetResultSize() {
201201
}
202202

203203
@Override
204-
public FullTextQueryImpl applyGraph(RootGraph graph, GraphSemantic semantic) {
205-
entityGraphHints.add( new EntityGraphHint<>( graph, semantic ) );
204+
public FullTextQuery applyGraph(RootGraph graph, GraphSemantic semantic) {
205+
applyGraph( (RootGraphImplementor) graph, semantic );
206206
return this;
207207
}
208208

209+
@Override
210+
protected void applyGraph(RootGraphImplementor<?> graph, GraphSemantic semantic) {
211+
entityGraphHints.add( new EntityGraphHint<>( graph, semantic ) );
212+
}
213+
209214
@Override
210215
public FullTextQueryImpl setProjection(String... fields) {
211216
hSearchQuery.projection( fields );
@@ -252,20 +257,14 @@ public FullTextQuery setHint(String hintName, Object value) {
252257
case HibernateOrmSearchQueryHints.JAKARTA_FETCHGRAPH:
253258
case HibernateOrmSearchQueryHints.JAVAX_LOADGRAPH:
254259
case HibernateOrmSearchQueryHints.JAKARTA_LOADGRAPH:
255-
applyEntityGraphQueryHint( hintName, hintValueToEntityGraph( value ) );
260+
applyEntityGraphHint( hintName, hintValueToEntityGraph( value ) );
256261
break;
257262
default:
258263
break;
259264
}
260265
return this;
261266
}
262267

263-
@Override
264-
protected void applyEntityGraphQueryHint(String hintName, RootGraphImplementor entityGraph) {
265-
GraphSemantic graphSemantic = GraphSemantic.fromJpaHintName( hintName );
266-
this.applyGraph( entityGraph, graphSemantic );
267-
}
268-
269268
@Override
270269
public Map<String, Object> getHints() {
271270
return hints;
@@ -283,7 +282,7 @@ public QueryParameterBindings getParameterBindings() {
283282
}
284283

285284
@Override
286-
protected QueryParameterBindings getQueryParameterBindings() {
285+
public QueryParameterBindings getQueryParameterBindings() {
287286
// parameters not supported in Hibernate Search queries
288287
return QueryParameterBindings.NO_PARAM_BINDINGS;
289288
}

0 commit comments

Comments
 (0)