-
Notifications
You must be signed in to change notification settings - Fork 3k
ISSUE-32936 | Allow plugging in Hibernate ORM's TypeContributor and FunctionContributor #51323
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
Draft
NickBeginner
wants to merge
4
commits into
quarkusio:main
Choose a base branch
from
NickBeginner:nbelcastro/issue-32936
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+156
−6
Draft
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
3fde94a
feat: issue-32936 add support for TypeContributor and FunctionContrib…
NickBeginner 2bc8557
feat: wip ISSUE-32936 adding support for AdditionalMappingContributions
NickBeginner 42ed098
Revert "feat: wip ISSUE-32936 adding support for AdditionalMappingCon…
NickBeginner 69d402c
wip tests
NickBeginner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -29,6 +29,7 @@ | |||
| import java.util.concurrent.ConcurrentHashMap; | ||||
| import java.util.stream.Collectors; | ||||
|
|
||||
| import io.quarkus.hibernate.orm.runtime.PersistenceUnitUtil; | ||||
| import jakarta.persistence.PersistenceException; | ||||
| import jakarta.persistence.PersistenceUnitTransactionType; | ||||
|
|
||||
|
|
@@ -39,6 +40,8 @@ | |||
| import org.hibernate.boot.archive.scan.spi.Scanner; | ||||
| import org.hibernate.boot.beanvalidation.BeanValidationIntegrator; | ||||
| import org.hibernate.boot.internal.MetadataImpl; | ||||
| import org.hibernate.boot.model.FunctionContributor; | ||||
| import org.hibernate.boot.model.TypeContributor; | ||||
| import org.hibernate.boot.model.process.spi.ManagedResources; | ||||
| import org.hibernate.boot.model.process.spi.MetadataBuildingProcess; | ||||
| import org.hibernate.boot.registry.StandardServiceRegistry; | ||||
|
|
@@ -162,19 +165,23 @@ public FastBootMetadataBuilder(final QuarkusPersistenceUnitDefinition puDefiniti | |||
| * of the destroyed service registry in PreconfiguredServiceRegistryBuilder. | ||||
| * | ||||
| */ | ||||
| for (Class<? extends Service> postBuildProvidedService : ssrBuilder.getPostBuildProvidedServices()) { | ||||
| providedServices.add(new ProvidedService(postBuildProvidedService, | ||||
| standardServiceRegistry.getService(postBuildProvidedService))); | ||||
| } | ||||
| ssrBuilder.getPostBuildProvidedServices() | ||||
| .forEach(serviceClass -> providedServices.add( | ||||
| new ProvidedService( | ||||
| serviceClass, | ||||
| standardServiceRegistry.getService(serviceClass) | ||||
| ))); | ||||
NickBeginner marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||
|
|
||||
| final MetadataSources metadataSources = new MetadataSources(ssrBuilder.getBootstrapServiceRegistry()); | ||||
|
|
||||
| applyMappingContributors(metadataSources); | ||||
|
|
||||
| // No need to populate annotatedClassNames/annotatedPackages: they are populated through scanning | ||||
| // XML mappings, however, cannot be contributed through the scanner, | ||||
| // which only allows specifying mappings as files/resources, | ||||
| // and we really don't want any XML parsing here... | ||||
| for (RecordableXmlMapping mapping : puDefinition.getXmlMappings()) { | ||||
| metadataSources.addXmlBinding(mapping.toHibernateOrmBinding()); | ||||
| } | ||||
| puDefinition.getXmlMappings() | ||||
| .forEach(mapping -> metadataSources.addXmlBinding(mapping.toHibernateOrmBinding())); | ||||
NickBeginner marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||
|
|
||||
| this.metamodelBuilder = (MetadataBuilderImplementor) metadataSources | ||||
| .getMetadataBuilder(standardServiceRegistry); | ||||
|
|
@@ -188,6 +195,9 @@ public FastBootMetadataBuilder(final QuarkusPersistenceUnitDefinition puDefiniti | |||
|
|
||||
| applyMetadataBuilderContributor(); | ||||
|
|
||||
| applyTypeContributors(); | ||||
| applyFunctionContributors(); | ||||
|
|
||||
| // Unable to automatically handle: | ||||
| // AvailableSettings.ENHANCER_ENABLE_DIRTY_TRACKING, | ||||
| // AvailableSettings.ENHANCER_ENABLE_LAZY_INITIALIZATION, | ||||
|
|
@@ -645,6 +655,10 @@ protected void populate(MetadataBuilder metamodelBuilder, List<CacheRegionDefini | |||
| } | ||||
| } | ||||
|
|
||||
| private void applyMappingContributors(MetadataSources metadataSources) { | ||||
|
|
||||
| } | ||||
|
|
||||
| private void applyMetadataBuilderContributor() { | ||||
| Object metadataBuilderContributorSetting = buildTimeSettings | ||||
| .get(JpaSettings.METADATA_BUILDER_CONTRIBUTOR); | ||||
|
Comment on lines
654
to
656
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remember to deprecate the metadata build contributor, now that you're introducing an alternative. A Line 141 in 02cb12f
|
||||
|
|
@@ -663,6 +677,16 @@ private void applyMetadataBuilderContributor() { | |||
| } | ||||
| } | ||||
|
|
||||
| private void applyTypeContributors() { | ||||
| PersistenceUnitUtil.extensionInstancesForPersistenceUnit(TypeContributor.class, persistenceUnit.getName()) | ||||
| .stream().forEach(metamodelBuilder::applyTypes); | ||||
| } | ||||
|
|
||||
| private void applyFunctionContributors() { | ||||
| PersistenceUnitUtil.extensionInstancesForPersistenceUnit(FunctionContributor.class, persistenceUnit.getName()) | ||||
| .stream().forEach(metamodelBuilder::applyFunctions); | ||||
| } | ||||
|
|
||||
| @SuppressWarnings("unchecked") | ||||
| private <T> T loadSettingInstance(String settingName, Object settingValue, Class<T> clazz) { | ||||
| T instance = null; | ||||
|
|
||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note you'll need to update docs as well, to mention the new component types in that list:
quarkus/docs/src/main/asciidoc/hibernate-orm.adoc
Lines 543 to 561 in 206858a