Skip to content

Commit f00214f

Browse files
committed
HHH-19925 - Locking root(s) should be based on select-clause, not from-clause
1 parent 9b52a52 commit f00214f

40 files changed

+294
-289
lines changed

hibernate-core/src/test/java/org/hibernate/orm/test/flush/TestAutoFlushBeforeQueryExecution.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import org.hibernate.Hibernate;
88
import org.hibernate.boot.Metadata;
9+
import org.hibernate.boot.registry.BootstrapServiceRegistry;
910
import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
1011
import org.hibernate.boot.spi.BootstrapContext;
1112
import org.hibernate.engine.spi.ActionQueue;
@@ -15,10 +16,10 @@
1516
import org.hibernate.event.spi.PreUpdateEvent;
1617
import org.hibernate.event.spi.PreUpdateEventListener;
1718
import org.hibernate.integrator.spi.Integrator;
19+
import org.hibernate.testing.orm.junit.BootstrapServiceRegistryProducer;
1820
import org.hibernate.testing.orm.junit.DomainModel;
1921
import org.hibernate.testing.orm.junit.JiraKey;
2022
import org.hibernate.testing.orm.junit.ServiceRegistryFunctionalTesting;
21-
import org.hibernate.testing.orm.junit.ServiceRegistryProducer;
2223
import org.hibernate.testing.orm.junit.SessionFactory;
2324
import org.hibernate.testing.orm.junit.SessionFactoryScope;
2425
import org.junit.jupiter.api.Assertions;
@@ -36,7 +37,7 @@
3637
@ServiceRegistryFunctionalTesting
3738
@DomainModel(annotatedClasses = { Author.class, Book.class, Publisher.class, UnrelatedEntity.class })
3839
@SessionFactory
39-
public class TestAutoFlushBeforeQueryExecution implements ServiceRegistryProducer {
40+
public class TestAutoFlushBeforeQueryExecution implements BootstrapServiceRegistryProducer {
4041

4142
@Test
4243
public void testAutoflushIsRequired(SessionFactoryScope factoryScope) {
@@ -211,7 +212,7 @@ record Ids (Long publisherId, Long unrelatedEntityId ) {
211212
}
212213

213214
@Override
214-
public void prepareBootstrapRegistryBuilder(BootstrapServiceRegistryBuilder builder) {
215+
public BootstrapServiceRegistry produceServiceRegistry(BootstrapServiceRegistryBuilder builder) {
215216
builder.applyIntegrator(
216217
new Integrator() {
217218
@Override
@@ -229,6 +230,7 @@ private void integrate(SessionFactoryImplementor sessionFactory) {
229230
}
230231
}
231232
);
233+
return builder.build();
232234
}
233235

234236
public static class InitializingPreUpdateEventListener implements PreUpdateEventListener {

hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/BaseUnitTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@
1313
import org.junit.jupiter.api.TestInstance;
1414
import org.junit.jupiter.api.extension.ExtendWith;
1515

16+
/// Applies standard set of JUnit Jupiter [extensions][org.junit.jupiter.api.extension.Extension]
17+
/// useful for all testing.
18+
///
19+
/// @see FailureExpectedExtension
20+
/// @see ExpectedExceptionExtension
21+
/// @see DialectFilterExtension
22+
///
23+
/// @author Steve Ebersole
1624
@Inherited
1725
@Target( ElementType.TYPE )
1826
@Retention( RetentionPolicy.RUNTIME )

hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/BootstrapServiceRegistry.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212

1313
import org.hibernate.integrator.spi.Integrator;
1414

15-
/**
16-
* Used to define the bootstrap ServiceRegistry to be used for testing.
17-
*/
15+
/// Used to define the bootstrap [org.hibernate.boot.registry.BootstrapServiceRegistry] to be used for testing.
16+
///
17+
/// @see ServiceRegistryExtension
18+
///
19+
/// @author Steve Ebersole
1820
@Inherited
1921
@Target({ElementType.TYPE, ElementType.METHOD})
2022
@Retention(RetentionPolicy.RUNTIME)

hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/BootstrapServiceRegistryProducer.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@
77
import org.hibernate.boot.registry.BootstrapServiceRegistry;
88
import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
99

10-
/**
11-
* Producer of BootstrapServiceRegistry
12-
*/
10+
/// An alternative to [@BootstrapServiceRegistry][org.hibernate.testing.orm.junit.BootstrapServiceRegistry]
11+
/// for producing a [BootstrapServiceRegistry] when programmatic building is needed.
12+
///
13+
/// @see ServiceRegistryExtension
14+
///
15+
/// @author Steve Ebersole
1316
public interface BootstrapServiceRegistryProducer {
17+
/// Produce the [BootstrapServiceRegistry]
1418
BootstrapServiceRegistry produceServiceRegistry(BootstrapServiceRegistryBuilder builder);
1519
}

hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/ClassLoadingIsolaterExtension.java

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

1111
import org.jboss.logging.Logger;
1212

13+
/// Provides [ClassLoader] isolation for tests.
14+
/// Used in combination with the test class implementing the [IsolatedClassLoaderProvider], e.g.
15+
///
16+
/// ```java
17+
/// @ExtendWith(ClassLoadingIsolaterExtension.class)
18+
/// class SomeTestClass implements IsolatedClassLoaderProvider {
19+
/// ...
20+
/// }
21+
/// ```
22+
///
23+
/// @author Andrea Boriero
1324
public class ClassLoadingIsolaterExtension implements AfterEachCallback, BeforeEachCallback {
1425

1526
private static final Logger log = Logger.getLogger( ClassLoadingIsolaterExtension.class );

hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/DialectFilterExtension.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@
1818

1919
import org.jboss.logging.Logger;
2020

21-
/**
22-
* JUnit Jupiter extension used to add {@link RequiresDialect} and {@link SkipForDialect}
23-
* handling
24-
*
25-
* @author Steve Ebersole
26-
*/
21+
/// JUnit Jupiter extension used to add [RequiresDialect] and [SkipForDialect]
22+
/// handling
23+
///
24+
/// @author Steve Ebersole
2725
public class DialectFilterExtension implements ExecutionCondition {
2826
private static final Logger log = Logger.getLogger( DialectFilterExtension.class );
2927

hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/DomainModel.java

Lines changed: 20 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -20,64 +20,26 @@
2020

2121
import jakarta.persistence.SharedCacheMode;
2222

23-
/**
24-
* @asciidoc
25-
*
26-
* Used to define the test model ({@link org.hibernate.boot.spi.MetadataImplementor})
27-
* to be used for testing.
28-
*
29-
* Can be used by itself, along with {@link DomainModelScopeAware}, to test the MetadataImplementor. E.g.
30-
*
31-
* [source, java, indent=0]
32-
* ----
33-
* @TestDomain ( ... )
34-
* class MyTest implements TestDomainAware {
35-
*
36-
* @Test
37-
* public void doTheTest() {
38-
* // use the injected MetadataImplementor
39-
* }
40-
*
41-
* private MetadataImplementor model;
42-
*
43-
* @Override
44-
* public void injectTestModelScope(MetadataImplementor model) {
45-
* this.model = model;
46-
* }
47-
* }
48-
* ----
49-
*
50-
*
51-
* Can optionally be used with {@link ServiceRegistry} to define the ServiceRegistry used to
52-
* build the MetadataImplementor (passed to
53-
* {@link org.hibernate.boot.MetadataSources#MetadataSources(org.hibernate.service.ServiceRegistry)}).
54-
*
55-
* [source, java, indent=0]
56-
* ----
57-
* @ServiceRegistry ( ... )
58-
* @TestDomain ( ... )
59-
* class MyTest implements TestDomainAware {
60-
*
61-
* @Test
62-
* public void doTheTest() {
63-
* // use the injected MetadataImplementor
64-
* }
65-
*
66-
* private MetadataImplementor model;
67-
*
68-
* @Override
69-
* public void injectTestModelScope(MetadataImplementor model) {
70-
* this.model = model;
71-
* }
72-
* }
73-
* ----
74-
*
75-
* It can also be used in conjunction with {@link SessionFactory}
76-
*
77-
* @see DomainModelScopeAware
78-
*
79-
* @author Steve Ebersole
80-
*/
23+
/// Used to define the [domain model][org.hibernate.boot.spi.MetadataImplementor] to be used for testing.
24+
/// Produces a [DomainModelScope] which can be injected via [JUnit ParameterResolver][DomainModelParameterResolver]
25+
/// or via [DomainModelScopeAware]; the ParameterResolver should be preferred.
26+
///
27+
/// ```java
28+
/// @DomainModel(annotatedClasses=SomeEntity.class)
29+
/// class SomeTest {
30+
/// @Test
31+
/// void testStuff(DomainModelScope modelScope) {
32+
/// ...
33+
/// }
34+
/// }
35+
/// ```
36+
///
37+
/// @see DomainModelExtension
38+
/// @see DomainModelScope
39+
/// @see DomainModelScopeAware
40+
/// @see DomainModelProducer
41+
///
42+
/// @author Steve Ebersole
8143
@Inherited
8244
@Target({ElementType.TYPE, ElementType.METHOD})
8345
@Retention(RetentionPolicy.RUNTIME)

hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/DomainModelExtension.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@
3232

3333
import jakarta.persistence.SharedCacheMode;
3434

35-
/**
36-
* hibernate-testing implementation of a few JUnit5 contracts to support SessionFactory-based testing,
37-
* including argument injection (or see {@link DomainModelScopeAware})
38-
*
39-
* @see ServiceRegistryScope
40-
* @see DomainModelExtension
41-
*
42-
* @author Steve Ebersole
43-
*/
35+
/// Support for defining the [domain model][MetadataImplementor] used in a test.
36+
///
37+
/// @see DomainModel
38+
/// @see DomainModelFunctionalTesting
39+
/// @see DomainModelProducer
40+
///
41+
/// @implNote Leverages the [service registry][ServiceRegistryScope] defined using the [ServiceRegistryExtension].
42+
///
43+
/// @author Steve Ebersole
4444
public class DomainModelExtension
4545
implements TestInstancePostProcessor, BeforeEachCallback, TestExecutionExceptionHandler {
4646

hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/DomainModelFunctionalTesting.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,26 @@
1313
import org.junit.jupiter.api.TestInstance;
1414
import org.junit.jupiter.api.extension.ExtendWith;
1515

16-
/**
17-
* @author Steve Ebersole
18-
*/
16+
/// Used in conjunction with [DomainModelProducer] to behave
17+
/// as if [@DomainModel][DomainModel] were used. E.g.
18+
///
19+
/// ```java
20+
/// @DomainModelFunctionalTesting
21+
/// class SomeTest implements DomainModelProducer {
22+
/// @Override
23+
/// MetadataImplementor produceModel(StandardServiceRegistry serviceRegistry) {
24+
/// }
25+
///
26+
/// @Test
27+
/// void testStuff(DomainModelScope modelScope) {
28+
/// ...
29+
/// }
30+
///
31+
/// ...
32+
/// }
33+
/// ```
34+
///
35+
/// @author Steve Ebersole
1936
@Inherited
2037
@Retention( RetentionPolicy.RUNTIME )
2138
@Target({ElementType.TYPE, ElementType.METHOD})

hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/DomainModelParameterResolver.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
import org.junit.jupiter.api.extension.ParameterResolutionException;
1212
import org.junit.jupiter.api.extension.ParameterResolver;
1313

14-
/**
15-
* @author Steve Ebersole
16-
*/
14+
/// ParameterResolver for [DomainModelExtension], capable of resolving
15+
/// either [DomainModelScope] or [MetadataImplementor].
16+
///
17+
/// @author Steve Ebersole
1718
public class DomainModelParameterResolver implements ParameterResolver {
1819
@Override
1920
public boolean supportsParameter(

0 commit comments

Comments
 (0)