Skip to content

Metamodel generator: allow implicit repositories for Panache Next#11775

Open
FroMage wants to merge 4 commits intohibernate:mainfrom
FroMage:quarkus-50178
Open

Metamodel generator: allow implicit repositories for Panache Next#11775
FroMage wants to merge 4 commits intohibernate:mainfrom
FroMage:quarkus-50178

Conversation

@FroMage
Copy link
Contributor

@FroMage FroMage commented Feb 6, 2026

This is the processor side of quarkusio/quarkus#50178:

  • Allow Jakarta Data query annotations on nested interface members to implicitely define a repository, even without the @Repository annotation
  • Allow nested interfaces that extend a Panache Next repository type to also define a repository

As it were, we were generating the accessors for these repositories without generating the repositories, leading to a compilation failure.

This is tested in Quarkus in quarkusio/quarkus#52425

I've opened this against main, but a backport to 7.2 would be nice, since that's what we're using in Quarkus ATM.

CC @gavinking


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-20165 (Bug):

  • Add test reproducing the bug
  • Add entries as relevant to migration-guide.adoc OR check there are no breaking changes

Tasks specific to HHH-20164 (Bug):

  • Add test reproducing the bug
  • Add entries as relevant to migration-guide.adoc OR check there are no breaking changes

Tasks specific to HHH-20163 (Bug):

  • Add test reproducing the bug
  • Add entries as relevant to migration-guide.adoc OR check there are no breaking changes

Tasks specific to HHH-20151 (Bug):

  • Add test reproducing the bug
  • Add entries as relevant to migration-guide.adoc OR check there are no breaking changes

https://hibernate.atlassian.net/browse/HHH-20165
https://hibernate.atlassian.net/browse/HHH-20164
https://hibernate.atlassian.net/browse/HHH-20151

@hibernate-github-bot
Copy link

hibernate-github-bot bot commented Feb 6, 2026

Thanks for your pull request!

This pull request appears to follow the contribution rules.

› This message was automatically generated.

@yrodiere
Copy link
Member

yrodiere commented Feb 6, 2026

I've opened this against main, but a backport to 7.2 would be nice, since that's what we're using in Quarkus ATM.

And 7.3. main should be 7.4. 7.3 is there: https://github.com/hibernate/hibernate-orm/tree/7.3

I'll send a PR to update the version on main...

EDIT: #11779

@FroMage
Copy link
Contributor Author

FroMage commented Feb 6, 2026

@gavinking I have more processor changes incoming for Quarkus Panache, do you prefer a separate JIRA and PR, or should I just pile them on here, whatever you prefer.

@yrodiere yrodiere changed the title Metamodel geneartor: allow implicit repositories for Panache Next Metamodel generator: allow implicit repositories for Panache Next Feb 6, 2026
@gavinking
Copy link
Member

Piling them up here sounds fine to me.

@FroMage
Copy link
Contributor Author

FroMage commented Feb 6, 2026

I should have a third one Monday. Perhaps a fourth too.

@FroMage FroMage force-pushed the quarkus-50178 branch 3 times, most recently from 2b2b461 to 6b258df Compare February 12, 2026 14:37
@FroMage
Copy link
Contributor Author

FroMage commented Feb 12, 2026

Alright. This is ready for review and merge @gavinking, I don't have anything else incoming.

@FroMage
Copy link
Contributor Author

FroMage commented Feb 12, 2026

I don't believe the CI failures are related, they don't appear to be :-/

Copy link
Member

@mbellade mbellade left a comment

Choose a reason for hiding this comment

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

@FroMage don't worry about the 3 failing CI checks, they are indeed unrelated.

I only have one comment, other than that I've noticed a few whitespace inconsistencies but overall this looks good.

I added the indexQueryInterfaces method before the elements were
recursively visited to find nested entities. I did not realise we were
visiting nested types twice: once with the primaryEntity set (by
indexQueryInterfaces) and the second time without it, causing issues
with nested repositories losing their primaryEntity in Quarkus Panache.

I'm now removing indexQueryInterfaces in favour of the upstream
recursion, adapted for keeping track of implicit primaryEntity.
…@delete queries

This only happens in Quarkus Panache when we have an implicit JD
repository with a @delete query method, because jakartaDataRepository is
not set, but it should not matter, because this method is only defined
by JD for repositories, so I don't think it makes any sense for it to be
false.

The result was code like this:

@OverRide
public long deleteByTitle(String title) {
        var _builder = session.getCriteriaBuilder();
        var _query = _builder.createCriteriaDelete(Panache2Book.class);
        var _entity = _query.from(Panache2Book.class);
        _query.where(
                        title==null
                                ? _entity.get(Panache2Book_.title).isNull()
                                : _builder.equal(_entity.get(Panache2Book_.title), title)
        );
        try {
                return session.createMutationQuery(_query).executeUpdate();
}

Note the missing catch. This is because the catch is conditional on
jakartaDataRepository while the try is not conditional.
@FroMage
Copy link
Contributor Author

FroMage commented Feb 19, 2026

So… a merge and backport? Please :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Comments