HHH-17460 - Ongoing JPA 32 work

This commit is contained in:
Andrea Boriero 2024-03-23 11:23:13 +01:00 committed by Steve Ebersole
parent c5f1c80040
commit 6183e7e606
5 changed files with 22 additions and 16 deletions

View File

@ -145,7 +145,7 @@ public class InFlightMetadataCollectorImpl implements InFlightMetadataCollector,
private final MetadataBuildingOptions options; private final MetadataBuildingOptions options;
private final GlobalRegistrations globalRegistrations; private final GlobalRegistrations globalRegistrations;
private final PersistenceUnitMetadata persistenceUnitMetadata; private PersistenceUnitMetadata persistenceUnitMetadata;
private final AttributeConverterManager attributeConverterManager = new AttributeConverterManager(); private final AttributeConverterManager attributeConverterManager = new AttributeConverterManager();
@ -204,7 +204,6 @@ public InFlightMetadataCollectorImpl(
this.uuid = UUID.randomUUID(); this.uuid = UUID.randomUUID();
this.globalRegistrations = new GlobalRegistrationsImpl( sourceModelBuildingContext ); this.globalRegistrations = new GlobalRegistrationsImpl( sourceModelBuildingContext );
this.persistenceUnitMetadata = new PersistenceUnitMetadataImpl();
for ( Map.Entry<String, SqmFunctionDescriptor> sqlFunctionEntry : bootstrapContext.getSqlFunctions().entrySet() ) { for ( Map.Entry<String, SqmFunctionDescriptor> sqlFunctionEntry : bootstrapContext.getSqlFunctions().entrySet() ) {
if ( sqlFunctionMap == null ) { if ( sqlFunctionMap == null ) {
@ -729,6 +728,11 @@ public void addIdentifierGenerator(IdentifierGeneratorDefinition generator) {
} }
} }
@Override
public void addPersistenceUnitMetadata(PersistenceUnitMetadata persistenceUnitMetadata) {
this.persistenceUnitMetadata = persistenceUnitMetadata;
}
@Override @Override
public void addDefaultIdentifierGenerator(IdentifierGeneratorDefinition generator) { public void addDefaultIdentifierGenerator(IdentifierGeneratorDefinition generator) {
this.addIdentifierGenerator( generator ); this.addIdentifierGenerator( generator );

View File

@ -424,6 +424,7 @@ public static DomainModelSource processManagedResources(
assert metadataCollector.getPersistenceUnitMetadata() == xmlPreProcessingResult.getPersistenceUnitMetadata(); assert metadataCollector.getPersistenceUnitMetadata() == xmlPreProcessingResult.getPersistenceUnitMetadata();
metadataCollector.addPersistenceUnitMetadata( xmlPreProcessingResult.getPersistenceUnitMetadata() );
//noinspection unchecked //noinspection unchecked
final List<String> allKnownClassNames = mutableJoin( final List<String> allKnownClassNames = mutableJoin(
managedResources.getAnnotatedClassReferences().stream().map( Class::getName ).collect( Collectors.toList() ), managedResources.getAnnotatedClassReferences().stream().map( Class::getName ).collect( Collectors.toList() ),

View File

@ -88,7 +88,6 @@
import org.hibernate.boot.jaxb.mapping.spi.db.JaxbCheckable; import org.hibernate.boot.jaxb.mapping.spi.db.JaxbCheckable;
import org.hibernate.boot.jaxb.mapping.spi.db.JaxbColumnJoined; import org.hibernate.boot.jaxb.mapping.spi.db.JaxbColumnJoined;
import org.hibernate.boot.jaxb.mapping.spi.db.JaxbTableMapping; import org.hibernate.boot.jaxb.mapping.spi.db.JaxbTableMapping;
import org.hibernate.boot.models.JpaAnnotations;
import org.hibernate.boot.models.categorize.spi.JpaEventListener; import org.hibernate.boot.models.categorize.spi.JpaEventListener;
import org.hibernate.boot.models.categorize.spi.JpaEventListenerStyle; import org.hibernate.boot.models.categorize.spi.JpaEventListenerStyle;
import org.hibernate.boot.models.internal.AnnotationUsageHelper; import org.hibernate.boot.models.internal.AnnotationUsageHelper;
@ -985,16 +984,12 @@ public static void applyTable(
JaxbTableImpl jaxbTable, JaxbTableImpl jaxbTable,
MutableAnnotationTarget target, MutableAnnotationTarget target,
XmlDocumentContext xmlDocumentContext) { XmlDocumentContext xmlDocumentContext) {
final MutableAnnotationUsage<Table> tableAnn = XmlProcessingHelper.makeAnnotation( Table.class, target, xmlDocumentContext );
final AnnotationDescriptor<Table> tableDescriptor = xmlDocumentContext.getModelBuildingContext()
.getAnnotationDescriptorRegistry()
.getDescriptor( Table.class );
if ( jaxbTable == null ) { if ( jaxbTable == null ) {
final XmlDocument.Defaults defaults = xmlDocumentContext.getXmlDocument().getDefaults(); final XmlDocument.Defaults defaults = xmlDocumentContext.getXmlDocument().getDefaults();
final String catalog = defaults.getCatalog(); final String catalog = defaults.getCatalog();
final String schema = defaults.getSchema(); final String schema = defaults.getSchema();
if ( StringHelper.isNotEmpty( catalog ) || StringHelper.isNotEmpty( schema ) ) { if ( StringHelper.isNotEmpty( catalog ) || StringHelper.isNotEmpty( schema ) ) {
final MutableAnnotationUsage<Table> tableAnn = XmlProcessingHelper.makeAnnotation( Table.class, target, xmlDocumentContext );
if ( StringHelper.isNotEmpty( catalog ) ) { if ( StringHelper.isNotEmpty( catalog ) ) {
tableAnn.setAttributeValue( "catalog", catalog ); tableAnn.setAttributeValue( "catalog", catalog );
@ -1005,6 +1000,10 @@ public static void applyTable(
} }
} }
else { else {
final MutableAnnotationUsage<Table> tableAnn = XmlProcessingHelper.makeAnnotation( Table.class, target, xmlDocumentContext );
final AnnotationDescriptor<Table> tableDescriptor = xmlDocumentContext.getModelBuildingContext()
.getAnnotationDescriptorRegistry()
.getDescriptor( Table.class );
applyOr( jaxbTable, JaxbTableImpl::getName, "name", tableAnn, tableDescriptor ); applyOr( jaxbTable, JaxbTableImpl::getName, "name", tableAnn, tableDescriptor );
applyTableAttributes( jaxbTable, target, tableAnn, tableDescriptor, xmlDocumentContext ); applyTableAttributes( jaxbTable, target, tableAnn, tableDescriptor, xmlDocumentContext );
} }
@ -1742,9 +1741,9 @@ public static <T, N, A extends Annotation> void applyOrSchema(
XmlDocumentContext xmlDocumentContext) { XmlDocumentContext xmlDocumentContext) {
applyOr( applyOr(
jaxbNode, jaxbNode,
(collectionTable) -> { (table) -> {
if ( StringHelper.isNotEmpty( collectionTable.getSchema() ) ) { if ( StringHelper.isNotEmpty( table.getSchema() ) ) {
return collectionTable.getSchema(); return table.getSchema();
} }
else if ( StringHelper.isNotEmpty( defaultSchema( xmlDocumentContext ) ) ) { else if ( StringHelper.isNotEmpty( defaultSchema( xmlDocumentContext ) ) ) {
return defaultSchema( xmlDocumentContext ); return defaultSchema( xmlDocumentContext );
@ -1770,9 +1769,9 @@ public static <T, N, A extends Annotation> void applyOrCatalog(
XmlDocumentContext xmlDocumentContext) { XmlDocumentContext xmlDocumentContext) {
applyOr( applyOr(
jaxbNode, jaxbNode,
(collectionTable) -> { (table) -> {
if ( StringHelper.isNotEmpty( collectionTable.getCatalog() ) ) { if ( StringHelper.isNotEmpty( table.getCatalog() ) ) {
return collectionTable.getCatalog(); return table.getCatalog();
} }
else if ( StringHelper.isNotEmpty( defaultCatalog( xmlDocumentContext ) ) ) { else if ( StringHelper.isNotEmpty( defaultCatalog( xmlDocumentContext ) ) ) {
return defaultCatalog( xmlDocumentContext ); return defaultCatalog( xmlDocumentContext );

View File

@ -246,8 +246,8 @@ static DefaultsImpl consume(JaxbEntityMappingsImpl jaxbRoot, PersistenceUnitMeta
jaxbRoot.getPackage(), jaxbRoot.getPackage(),
NullnessHelper.coalesce( jaxbRoot.getAccess(), metadata.getAccessType() ), NullnessHelper.coalesce( jaxbRoot.getAccess(), metadata.getAccessType() ),
NullnessHelper.coalesce( jaxbRoot.getAttributeAccessor(), metadata.getDefaultAccessStrategyName() ), NullnessHelper.coalesce( jaxbRoot.getAttributeAccessor(), metadata.getDefaultAccessStrategyName() ),
NullnessHelper.coalesce( jaxbRoot.getCatalog(), metadata.getDefaultCatalog() ), jaxbRoot.getCatalog(),
NullnessHelper.coalesce( jaxbRoot.getSchema(), metadata.getDefaultSchema() ), jaxbRoot.getSchema(),
jaxbRoot.isAutoImport(), jaxbRoot.isAutoImport(),
jaxbRoot.isDefaultLazy() jaxbRoot.isDefaultLazy()
); );

View File

@ -253,6 +253,8 @@ Table addDenormalizedTable(
void addIdentifierGenerator(IdentifierGeneratorDefinition generatorDefinition); void addIdentifierGenerator(IdentifierGeneratorDefinition generatorDefinition);
void addPersistenceUnitMetadata(PersistenceUnitMetadata persistenceUnitMetadata);
/** /**
* Obtain the {@link ConverterRegistry} which may be * Obtain the {@link ConverterRegistry} which may be
* used to register {@link AttributeConverter}s. * used to register {@link AttributeConverter}s.