Some changes to simplify the integration with Hibernate Reactive#12239
Some changes to simplify the integration with Hibernate Reactive#12239DavideD wants to merge 58 commits into
Conversation
HHH-20074 - Adapt Hibernate Query contracts to new JPA 4.0 structure
HHH-20074 - Adapt Hibernate Query contracts to new JPA 4.0 structure
HHH-20074 - Adapt Hibernate Query contracts to new JPA 4.0 structure
HHH-20074 - Adapt Hibernate Query contracts to new JPA 4.0 structure
HHH-20074 - Adapt Hibernate Query contracts to new JPA 4.0 structure
HHH-20074 - Adapt Hibernate Query contracts to new JPA 4.0 structure
HHH-20074 - Adapt Hibernate Query contracts to new JPA 4.0 structure
HHH-20074 - Adapt Hibernate Query contracts to new JPA 4.0 structure
- Fix `SkipLockedTests` setting query timeout instead of lock timeout - Fix `PessimisticWriteLockTimeoutTest` setting query timeout instead of lock timeout - Fix exception types in `LockedRowsTest` - Fix `NativeSQLQueriesTest.testAutoDetectAliasing` transformer - Fix `ArrayTest` not clearing the type cache - Fix multi-table query plan detection with generated ids - Fix `FindOption` timeout when using deprecated javax hint - Don't default to `Object.class` for native queries with no result type
HHH-20074 - Adapt Hibernate Query contracts to new JPA 4.0 structure
HHH-20074 - Adapt Hibernate Query contracts to new JPA 4.0 structure
HHH-20074 - Adapt Hibernate Query contracts to new JPA 4.0 structure - clean up some Javadoc errors
HHH-20210 - Redesign ProcedureCall and Outputs
* Enable GH workflow builds on JPA 4 branch
* HHH-20139 - Revamp scanning in lieu of JPA 4 changes
Signed-off-by: Steve Ebersole <steve@hibernate.org>
as it uses H2 JDBC URLs explicitly
…eturning null Co-authored-by: Andrea Boriero <andrea@hibernate.org>
Signed-off-by: Steve Ebersole <steve@hibernate.org>
This change is for Hibernate Reactive to be able to convert the StateManagement into a reactive one without having to know anything about the way it's created in Hibernate ORM Co-authored-by: Andrea Boriero <andrea@hibernate.org>
|
Thanks for your pull request! This pull request does not follow the contribution rules. Could you have a look? ❌ All commit messages should start with a JIRA issue key matching pattern › This message was automatically generated. |
There was a problem hiding this comment.
Pull request overview
This PR broadens a few internal extension points to simplify integration with Hibernate Reactive, mainly by relaxing visibility and allowing customization of StateManagement used by entity persisters.
Changes:
- Make selected internal classes/methods
public/protectedto enable reuse/override from Hibernate Reactive. - Add new protected constructors to key
*EntityPersisterimplementations that accept aFunction<StateManagement, StateManagement>converter. - Expose additional override points in mutation/collection coordinators (
getBatchKey(),buildOperationGroup(), etc.).
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| hibernate-core/src/main/java/org/hibernate/persister/state/internal/AbstractStateManagement.java | Makes the base state-management implementation public to allow extension outside the package. |
| hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/InsertCoordinatorStandard.java | Relaxes helper visibility (getPropertiesToInsert) for reuse in subclasses/extensions. |
| hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/AbstractMutationCoordinator.java | Relaxes visibility of hasValueGenerationOnExecution for reuse by extensions. |
| hibernate-core/src/main/java/org/hibernate/persister/entity/UnionSubclassEntityPersister.java | Adds a protected constructor that forwards a StateManagement converter to the superclass. |
| hibernate-core/src/main/java/org/hibernate/persister/entity/SingleTableEntityPersister.java | Adds a protected constructor that forwards a StateManagement converter to the superclass. |
| hibernate-core/src/main/java/org/hibernate/persister/entity/JoinedSubclassEntityPersister.java | Adds a protected constructor that forwards a StateManagement converter to the superclass. |
| hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java | Introduces a new protected constructor with a StateManagement converter and applies it when assigning stateManagement. |
| hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/RemoveCoordinatorStandard.java | Exposes getBatchKey() and buildOperationGroup() to support Reactive overrides and switches executor batch-key access to a method reference. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ); | ||
| } | ||
|
|
||
| // Used by Hibernate Reactive: it needs to override teh StateManagement |
There was a problem hiding this comment.
Typo in the comment: "teh" should be "the".
| // Used by Hibernate Reactive: it needs to override teh StateManagement | |
| // Used by Hibernate Reactive: it needs to override the StateManagement |
| final EntityDataAccess cacheAccessStrategy, | ||
| final NaturalIdDataAccess naturalIdRegionAccessStrategy, | ||
| final RuntimeModelCreationContext creationContext, | ||
| final Function<StateManagement, StateManagement> statementManagerConverter) |
There was a problem hiding this comment.
The parameter name statementManagerConverter is misleading here (it converts StateManagement, not statements) and is inconsistent with stateManagementConverter used in other persisters in this PR. Rename it (and its uses) to something like stateManagementConverter for clarity.
| final Function<StateManagement, StateManagement> statementManagerConverter) | |
| final Function<StateManagement, StateManagement> stateManagementConverter) |
|
|
||
| stateManagement = persistentClass.getRootClass().getStateManagement(); | ||
| // Hibernate Reactive needs to convert the stateManagement so that it can create reactive coordinators | ||
| stateManagement = statementManagerConverter.apply( persistentClass.getRootClass().getStateManagement() ); |
There was a problem hiding this comment.
statementManagerConverter.apply(...) can return null (or statementManagerConverter itself can be null when called from subclasses), which would leave stateManagement null and likely fail later with a harder-to-diagnose NPE. Consider validating the converter and its result (e.g., Objects.requireNonNull) and/or documenting that the converter must return a non-null StateManagement.
| stateManagement = statementManagerConverter.apply( persistentClass.getRootClass().getStateManagement() ); | |
| stateManagement = Objects.requireNonNull( | |
| Objects.requireNonNull( | |
| statementManagerConverter, | |
| "statementManagerConverter must not be null" | |
| ).apply( persistentClass.getRootClass().getStateManagement() ), | |
| "statementManagerConverter must not return null" | |
| ); |
| final Function<StateManagement, StateManagement> statementManagerConverter) throws HibernateException { | ||
| super( persistentClass, cacheAccessStrategy, naturalIdRegionAccessStrategy, creationContext, statementManagerConverter ); |
There was a problem hiding this comment.
Inconsistent/misleading parameter name: statementManagerConverter converts StateManagement, and the other persister constructors in this PR use stateManagementConverter. Rename this parameter (and the corresponding super(...) argument) to match for readability and consistency.
| final Function<StateManagement, StateManagement> statementManagerConverter) throws HibernateException { | |
| super( persistentClass, cacheAccessStrategy, naturalIdRegionAccessStrategy, creationContext, statementManagerConverter ); | |
| final Function<StateManagement, StateManagement> stateManagementConverter) throws HibernateException { | |
| super( persistentClass, cacheAccessStrategy, naturalIdRegionAccessStrategy, creationContext, stateManagementConverter ); |
Let me know if I need to create a JIRA
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license
and can be relicensed under the terms of the LGPL v2.1 license in the future at the maintainers' discretion.
For more information on licensing, please check here.
Please make sure that the following tasks are completed:
Tasks specific to HHH-20291 (Task):
documentation/src/main/asciidoc/userguidefor all features,documentation/src/main/asciidoc/introductionfor main features, links from existing documentationmigration-guide.adoc(breaking changes) andwhats-new.adoc(new features/improvements)