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

View File

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

View File

@ -88,7 +88,6 @@ import org.hibernate.boot.jaxb.mapping.spi.JaxbUuidGeneratorImpl;
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.JaxbTableMapping;
import org.hibernate.boot.models.JpaAnnotations;
import org.hibernate.boot.models.categorize.spi.JpaEventListener;
import org.hibernate.boot.models.categorize.spi.JpaEventListenerStyle;
import org.hibernate.boot.models.internal.AnnotationUsageHelper;
@ -985,16 +984,12 @@ public class XmlAnnotationHelper {
JaxbTableImpl jaxbTable,
MutableAnnotationTarget target,
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 ) {
final XmlDocument.Defaults defaults = xmlDocumentContext.getXmlDocument().getDefaults();
final String catalog = defaults.getCatalog();
final String schema = defaults.getSchema();
if ( StringHelper.isNotEmpty( catalog ) || StringHelper.isNotEmpty( schema ) ) {
final MutableAnnotationUsage<Table> tableAnn = XmlProcessingHelper.makeAnnotation( Table.class, target, xmlDocumentContext );
if ( StringHelper.isNotEmpty( catalog ) ) {
tableAnn.setAttributeValue( "catalog", catalog );
@ -1005,6 +1000,10 @@ public class XmlAnnotationHelper {
}
}
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 );
applyTableAttributes( jaxbTable, target, tableAnn, tableDescriptor, xmlDocumentContext );
}
@ -1742,9 +1741,9 @@ public class XmlAnnotationHelper {
XmlDocumentContext xmlDocumentContext) {
applyOr(
jaxbNode,
(collectionTable) -> {
if ( StringHelper.isNotEmpty( collectionTable.getSchema() ) ) {
return collectionTable.getSchema();
(table) -> {
if ( StringHelper.isNotEmpty( table.getSchema() ) ) {
return table.getSchema();
}
else if ( StringHelper.isNotEmpty( defaultSchema( xmlDocumentContext ) ) ) {
return defaultSchema( xmlDocumentContext );
@ -1770,9 +1769,9 @@ public class XmlAnnotationHelper {
XmlDocumentContext xmlDocumentContext) {
applyOr(
jaxbNode,
(collectionTable) -> {
if ( StringHelper.isNotEmpty( collectionTable.getCatalog() ) ) {
return collectionTable.getCatalog();
(table) -> {
if ( StringHelper.isNotEmpty( table.getCatalog() ) ) {
return table.getCatalog();
}
else if ( StringHelper.isNotEmpty( defaultCatalog( xmlDocumentContext ) ) ) {
return defaultCatalog( xmlDocumentContext );

View File

@ -246,8 +246,8 @@ public class XmlDocumentImpl implements XmlDocument {
jaxbRoot.getPackage(),
NullnessHelper.coalesce( jaxbRoot.getAccess(), metadata.getAccessType() ),
NullnessHelper.coalesce( jaxbRoot.getAttributeAccessor(), metadata.getDefaultAccessStrategyName() ),
NullnessHelper.coalesce( jaxbRoot.getCatalog(), metadata.getDefaultCatalog() ),
NullnessHelper.coalesce( jaxbRoot.getSchema(), metadata.getDefaultSchema() ),
jaxbRoot.getCatalog(),
jaxbRoot.getSchema(),
jaxbRoot.isAutoImport(),
jaxbRoot.isDefaultLazy()
);

View File

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