Skip to content

HHH-19610 make GraphParser support subTypeSubGraph #10521

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Asanio06
Copy link
Contributor

@Asanio06 Asanio06 commented Jul 12, 2025

Today, Jpa's NamedEntityGraph annotation supports the use of subclassSubgraphs to define graphs linked to the subtypes of an Entity. It is also possible, via the entityManager, to do the same thing via the addTreatedSubgraph function.

The goal of this ticket is to improve GraphParser so that it supports a syntax that does the same thing. In this way, Hibernate's own NamedEntityGraph annotation will have 100% of the same functionality as Jpa’s.

I suggest the following syntax for defining a subclassSubgraphs:

(GraphParsingTestSubEntity:sub), name, description

Here we have a sub-graph specific to the GraphParsingTestSubEntity type, which is a sub-type of GraphParsingTestEntity.

The ticket related to my proposal: https://hibernate.atlassian.net/browse/HHH-19610


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.


https://hibernate.atlassian.net/browse/HHH-19610

@sebersole
Copy link
Member

sebersole commented Jul 14, 2025

Hi @Asanio06, thanks for the PR!

Overall it's a good feature to add :)

I'm not a fan of using parenthesis here though - those are already used for sub-graphs so it introduces a bit of syntatic ambiguity. Sure, the use of the colon disambiguites it, but it also does so on its own:

GraphParsingTestSubEntity:sub, name, description

Bacause otherwise, something like this just looks odd -

(GraphParsingTestSubEntity:sub(subName, subOtherStuff)), name, description

whereas this is a little bit better:

GraphParsingTestSubEntity:sub(subName, subOtherStuff), name, description

@sebersole
Copy link
Member

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