Skip to content

Some changes to simplify the integration with Hibernate Reactive#12239

Closed
DavideD wants to merge 58 commits into
hibernate:wip/jpa4from
DavideD:ORM-8-hr
Closed

Some changes to simplify the integration with Hibernate Reactive#12239
DavideD wants to merge 58 commits into
hibernate:wip/jpa4from
DavideD:ORM-8-hr

Conversation

@DavideD
Copy link
Copy Markdown
Member

@DavideD DavideD commented Apr 24, 2026

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):

  • Add test OR check there is no need for a test
  • Update documentation as relevant: javadoc for changed API, documentation/src/main/asciidoc/userguide for all features, documentation/src/main/asciidoc/introduction for main features, links from existing documentation
  • Add entries as relevant to migration-guide.adoc (breaking changes) and whats-new.adoc (new features/improvements)

sebersole and others added 30 commits April 9, 2026 18:46
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
gavinking and others added 21 commits April 9, 2026 18:46
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>
@hibernate-github-bot
Copy link
Copy Markdown

hibernate-github-bot Bot commented Apr 24, 2026

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 HHH-\d+
    ↳ Offending commits: [a850b85]
❌ The pull request description must contain the license agreement text.
    ↳ The description of this pull request must contain the following license agreement text:

----------------------
By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license](https://www.apache.org/licenses/LICENSE-2.0.txt)
and can be relicensed under the terms of the [LGPL v2.1 license](https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt) in the future at the maintainers' discretion.
For more information on licensing, please check [here](https://github.com/hibernate/hibernate-orm/blob/main/CONTRIBUTING.md#legal).

----------------------

› This message was automatically generated.

@hibernate-github-bot hibernate-github-bot Bot added the wip/jpa4 Label for pull requests targeting [wip/jpa4] branch. label Apr 24, 2026
@Sanne Sanne requested a review from Copilot April 25, 2026 14:43
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/protected to enable reuse/override from Hibernate Reactive.
  • Add new protected constructors to key *EntityPersister implementations that accept a Function<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
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in the comment: "teh" should be "the".

Suggested change
// Used by Hibernate Reactive: it needs to override teh StateManagement
// Used by Hibernate Reactive: it needs to override the StateManagement

Copilot uses AI. Check for mistakes.
final EntityDataAccess cacheAccessStrategy,
final NaturalIdDataAccess naturalIdRegionAccessStrategy,
final RuntimeModelCreationContext creationContext,
final Function<StateManagement, StateManagement> statementManagerConverter)
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
final Function<StateManagement, StateManagement> statementManagerConverter)
final Function<StateManagement, StateManagement> stateManagementConverter)

Copilot uses AI. Check for mistakes.

stateManagement = persistentClass.getRootClass().getStateManagement();
// Hibernate Reactive needs to convert the stateManagement so that it can create reactive coordinators
stateManagement = statementManagerConverter.apply( persistentClass.getRootClass().getStateManagement() );
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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"
);

Copilot uses AI. Check for mistakes.
Comment on lines +120 to +121
final Function<StateManagement, StateManagement> statementManagerConverter) throws HibernateException {
super( persistentClass, cacheAccessStrategy, naturalIdRegionAccessStrategy, creationContext, statementManagerConverter );
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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 );

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wip/jpa4 Label for pull requests targeting [wip/jpa4] branch.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants