Skip to content

Commit 0d6d1a7

Browse files
committed
4.x: Tests fail when upgrading to Hibernate 6.6.23.Final #10441
Signed-off-by: Jorge Bescos Gascon <[email protected]>
1 parent 75392a9 commit 0d6d1a7

File tree

5 files changed

+32
-12
lines changed

5 files changed

+32
-12
lines changed

dependencies/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@
6969
<version.lib.h2>2.2.220</version.lib.h2>
7070
<version.lib.hamcrest>1.3</version.lib.hamcrest>
7171
<version.lib.handlebars>4.4.0</version.lib.handlebars>
72-
<version.lib.hibernate.family>6.3</version.lib.hibernate.family>
73-
<version.lib.hibernate>${version.lib.hibernate.family}.1.Final</version.lib.hibernate>
72+
<version.lib.hibernate.family>6.6</version.lib.hibernate.family>
73+
<version.lib.hibernate>${version.lib.hibernate.family}.23.Final</version.lib.hibernate>
7474
<version.lib.hibernate-validator>8.0.2.Final</version.lib.hibernate-validator>
7575
<version.lib.hikaricp>5.0.1</version.lib.hikaricp>
7676
<version.lib.hystrix>1.5.18</version.lib.hystrix>

integrations/cdi/hibernate-cdi/src/main/java/io/helidon/integrations/cdi/hibernate/BytecodeProviderInitiator.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2024 Oracle and/or its affiliates.
2+
* Copyright (c) 2024, 2025 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,11 +16,13 @@
1616

1717
package io.helidon.integrations.cdi.hibernate;
1818

19+
import java.util.Map;
1920
import java.util.function.Predicate;
2021

2122
import com.oracle.svm.core.annotate.Substitute;
2223
import com.oracle.svm.core.annotate.TargetClass;
2324
import org.hibernate.bytecode.spi.BytecodeProvider;
25+
import org.hibernate.service.spi.ServiceRegistryImplementor;
2426

2527
/**
2628
* In native image, we force the usage of the no-op bytecode provider so no bytecode
@@ -34,17 +36,23 @@ private BytecodeProviderInitiator() {
3436
}
3537

3638
@Substitute
37-
public static BytecodeProvider buildBytecodeProvider(String providerName) {
39+
public static BytecodeProvider buildDefaultBytecodeProvider() {
3840
return new org.hibernate.bytecode.internal.none.BytecodeProviderImpl();
3941
}
4042

43+
@Substitute
44+
public BytecodeProvider initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
45+
return buildDefaultBytecodeProvider();
46+
}
47+
4148
static class SubstituteOnlyIfPresent implements Predicate<String> {
4249

4350
@Override
4451
public boolean test(String type) {
4552
try {
4653
Class<?> clazz = Class.forName(type, false, getClass().getClassLoader());
47-
clazz.getDeclaredMethod("buildBytecodeProvider", String.class);
54+
clazz.getDeclaredMethod("buildDefaultBytecodeProvider");
55+
clazz.getDeclaredMethod("initiateService", Map.class, ServiceRegistryImplementor.class);
4856
return true;
4957
} catch (ClassNotFoundException | NoClassDefFoundError | NoSuchMethodException ex) {
5058
return false;

integrations/cdi/hibernate-cdi/src/main/resources/META-INF/native-image/io.helidon.integrations.cdi/helidon-integrations-cdi-hibernate/reflect-config.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2147,5 +2147,13 @@
21472147
]
21482148
}
21492149
]
2150+
},
2151+
{
2152+
"name": "org.hibernate.event.spi.PostUpsertEventListener[]",
2153+
"allDeclaredConstructors": true,
2154+
"allPublicConstructors": true,
2155+
"allDeclaredMethods": true,
2156+
"allDeclaredFields": true,
2157+
"unsafeAllocated": true
21502158
}
21512159
]

integrations/cdi/jpa-cdi/src/test/java/io/helidon/integrations/cdi/jpa/chirp/TestJpaTransactionScopedSynchronizedEntityManager.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2023 Oracle and/or its affiliates.
2+
* Copyright (c) 2019, 2025 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -292,9 +292,9 @@ void testJpaTransactionScopedSynchronizedEntityManager()
292292
assertThat(transactionScopedContext.isActive(), is(true));
293293

294294
// Remove the Author we successfully committed before. We
295-
// have to merge because author1 became detached a few lines
296-
// above.
297-
author1 = em.merge(author1);
295+
// have to find because author1 became detached a few lines
296+
// above and it is not allowed to attach it again with merge.
297+
author1 = em.find(Author.class, Integer.valueOf(1));
298298
assertThat(author1, notNullValue());
299299
assertThat(em.contains(author1), is(true));
300300
em.remove(author1);
@@ -313,13 +313,15 @@ void testJpaTransactionScopedSynchronizedEntityManager()
313313
// tables.
314314
assertTableRowCount(dataSource, "AUTHOR", 0);
315315

316-
// Start a new transaction, merge our detached author1, and
316+
// Start a new transaction, persist our detached author1, and
317317
// commit. This will bump the author's ID and put a row in
318318
// the database.
319319
tm.begin();
320320
assertThat(em.isJoinedToTransaction(), is(true));
321321
assertThat(transactionScopedContext.isActive(), is(true));
322-
author1 = em.merge(author1);
322+
author1 = new Author("Abraham Lincoln");
323+
em.persist(author1);
324+
em.merge(author1);
323325
tm.commit();
324326
assertThat(em.isJoinedToTransaction(), is(false));
325327
assertThat(em.contains(author1), is(false));

integrations/cdi/jpa-cdi/src/test/java/io/helidon/integrations/cdi/jpa/chirp/TestRollbackScenarios.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2023 Oracle and/or its affiliates.
2+
* Copyright (c) 2019, 2025 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -276,6 +276,8 @@ void testRollbackScenarios()
276276
assertThat(tm.getStatus(), is(Status.STATUS_ACTIVE));
277277
assertThat(em.isJoinedToTransaction(), is(true));
278278
assertThat(em.contains(author), is(false));
279+
author = new Author("John Kennedy");
280+
em.persist(author);
279281
author = em.merge(author);
280282
em.remove(author);
281283
tm.commit();

0 commit comments

Comments
 (0)