Skip to content

Resolve AnnotationBasedGenerator type argument through class hierarchy#12871

Merged
beikov merged 1 commit into
hibernate:mainfrom
stewue:main
Jul 1, 2026
Merged

Resolve AnnotationBasedGenerator type argument through class hierarchy#12871
beikov merged 1 commit into
hibernate:mainfrom
stewue:main

Conversation

@stewue

@stewue stewue commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

I wanted to file this as a JIRA issue, but I always get a permission error whentrying to create a ticket, so I'm posting it here instead. -> I reported issue in https://discourse.hibernate.org/t/annotationbasedgenerator-is-not-initialized-when-the-interface-is-implemented-by-an-abstract-superclass-instead-of-the-concrete-class-after-upgrading-to-hibernate-7-3-7-4/12354. Here is the PR with an accompanying test.

Example

Abstract base class implementing the interface:


  public abstract class AbstractGeneration<T extends Annotation> implements BeforeExecutionGenerator, AnnotationBasedGenerator<T> {

      @Override
      public void initialize(T annotation, GeneratorCreationContext context) {
          // ...
      }
  }

Concrete generator referenced by a @ValueGenerationType annotation:

  public class ConcreteFieldGeneration extends AbstractGeneration<CustomAnnotation> {
      // does NOT declare "implements AnnotationBasedGenerator<CustomAnnotation>"
  }

Since 7.3/7.4 Hibernate fails to with AssertionFailure: "Could not find implementing interface". The change was introduced by


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-20614 (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-20614

@hibernate-github-bot

hibernate-github-bot Bot commented Jun 23, 2026

Copy link
Copy Markdown

Thanks for your pull request!

This pull request appears to follow the contribution rules.

› This message was automatically generated.

@beikov beikov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Changes look good to me, but we need

  • Jira ticket
  • Commit message use the Jira key
  • Test refer to the Jira link via @Jira("...")

@stewue
stewue force-pushed the main branch 2 times, most recently from 2dff0b0 to 383ddf8 Compare June 29, 2026 05:10
@stewue

stewue commented Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

@beikov I've addressed the points from your comment. Is there anything I need to do on my end (Jenkins CI is "in progress" after hours)?

@beikov

beikov commented Jun 30, 2026

Copy link
Copy Markdown
Member

Please run ./gradlew spotlessApply to fix the code style errors.

…s hierarchy

Previously  only inspected the generator's direct
generic interfaces, so it failed to find the annotation type argument when
Previously  only inspected the generator's direct
generic interfaces, so it failed to find the annotation type argument when
a generator inherited AnnotationBasedGenerator from an abstract base class.
Use to resolve the argument through the full
class hierarchy.
@beikov
beikov merged commit 114ae9c into hibernate:main Jul 1, 2026
28 of 31 checks passed
This was referenced Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants