Skip to content

Conversation

@boutss
Copy link
Contributor

@boutss boutss commented Oct 2, 2024

For complete the PR : HHH-15722 : @onetomany mappedBy with a @Any
It is proposed to add this feature :
If no @AnyDiscriminatorValue is returned, the entity name is used as the discriminator value.

This follows the discussions we had on Zulip.

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

@hibernate-github-bot
Copy link

hibernate-github-bot bot commented Oct 2, 2024

Thanks for your pull request!

This pull request appears to follow the contribution rules.

› This message was automatically generated.

@boutss boutss changed the title HHH-18684 : If no @AnyDiscriminatorValue is returned, the entity name… HHH-18684 : If no @AnyDiscriminatorValue is returned, the entity name is used as the discriminator value. Oct 2, 2024
Copy link
Member

@sebersole sebersole left a comment

Choose a reason for hiding this comment

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

Looks good to me

final AnyType anyType = any.getType();
final MetaType metaType = (MetaType) anyType.getDiscriminatorType();
final Object discriminatorValue = metaType.getEntityNameToDiscriminatorValueMap().get( ownerPersister.getEntityName() );
Object discriminatorValue = metaType.resolveDiscriminatorValue( ownerPersister.getEntityName() );
Copy link
Member

Choose a reason for hiding this comment

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

Please add the final back to match the rest of the code.

Suggested change
Object discriminatorValue = metaType.resolveDiscriminatorValue( ownerPersister.getEntityName() );
final Object discriminatorValue = metaType.resolveDiscriminatorValue( ownerPersister.getEntityName() );

Copy link
Member

Choose a reason for hiding this comment

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

Actually, as we discussed on Zulip, I think this shoud pass in the persister rather than "just" the name. That would open up the possibility for the other things we discussed (short name, etc).

… is used as the discriminator value.

-> Pass in the persister rather than "just" the name
@yrodiere
Copy link
Member

yrodiere commented Oct 3, 2025

https://hibernate.atlassian.net/browse/HHH-18684 was closed with an indication that the problem was fixed in https://hibernate.atlassian.net/browse/HHH-18728. So, I'm going to close this PR.

@boutss feel free to ping me if you think there is a mistake!

@yrodiere yrodiere closed this Oct 3, 2025
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.

3 participants