HHH-17504 - Ongoing JPA 32 work
HHH-17350 - Work on hibernate-models, XSD and JAXB HHH-16114 - Improve boot metamodel binding HHH-15996 - Develop an abstraction for Annotation in annotation processing HHH-16012 - Develop an abstraction for domain model Class refs HHH-15997 - Support for dynamic models in orm.xml HHH-15698 - Support for entity-name in mapping.xsd
This commit is contained in:
parent
6869dbb1f9
commit
540b87e78a
|
@ -85,7 +85,7 @@ public class CacheableFileXmlSource extends XmlSource {
|
|||
else {
|
||||
if ( !isSerfileObsolete() ) {
|
||||
try {
|
||||
return readSerFile();
|
||||
return new Binding( readSerFile(), getOrigin() );
|
||||
}
|
||||
catch ( SerializationException e ) {
|
||||
log.unableToDeserializeCache( serFile.getName(), e );
|
||||
|
@ -117,6 +117,9 @@ public class CacheableFileXmlSource extends XmlSource {
|
|||
}
|
||||
|
||||
private static void writeSerFile(Serializable binding, File xmlFile, File serFile) {
|
||||
if ( binding instanceof Binding<?> bindingWrapper ) {
|
||||
binding = (Serializable) bindingWrapper.getRoot();
|
||||
}
|
||||
try ( FileOutputStream fos = new FileOutputStream( serFile ) ) {
|
||||
if ( log.isDebugEnabled() ) {
|
||||
log.debugf( "Writing cache file for: %s to: %s", xmlFile.getAbsolutePath(), serFile.getAbsolutePath() );
|
||||
|
|
|
@ -11,6 +11,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import org.hibernate.AnnotationException;
|
||||
import org.hibernate.Internal;
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.annotations.CollectionTypeRegistration;
|
||||
import org.hibernate.annotations.CollectionTypeRegistrations;
|
||||
|
@ -388,7 +389,7 @@ public final class AnnotationBinder {
|
|||
|
||||
bindQueries( annotatedClass, context );
|
||||
handleImport( annotatedClass, context );
|
||||
bindFilterDefs( annotatedClass, context );
|
||||
//bindFilterDefs( annotatedClass, context );
|
||||
bindTypeDescriptorRegistrations( annotatedClass, context );
|
||||
bindEmbeddableInstantiatorRegistrations( annotatedClass, context );
|
||||
bindUserTypeRegistrations( annotatedClass, context );
|
||||
|
|
|
@ -21,7 +21,9 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.hibernate.Internal;
|
||||
import org.hibernate.boot.MetadataSources;
|
||||
import org.hibernate.boot.internal.InFlightMetadataCollectorImpl;
|
||||
import org.hibernate.boot.internal.MetadataBuildingContextRootImpl;
|
||||
|
@ -30,8 +32,8 @@ import org.hibernate.boot.jaxb.SourceType;
|
|||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmHibernateMapping;
|
||||
import org.hibernate.boot.jaxb.internal.MappingBinder;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityMappingsImpl;
|
||||
import org.hibernate.boot.jaxb.spi.JaxbBindableMappingDescriptor;
|
||||
import org.hibernate.boot.jaxb.spi.Binding;
|
||||
import org.hibernate.boot.jaxb.spi.JaxbBindableMappingDescriptor;
|
||||
import org.hibernate.boot.model.TypeContributions;
|
||||
import org.hibernate.boot.model.TypeContributor;
|
||||
import org.hibernate.boot.model.process.internal.ManagedResourcesImpl;
|
||||
|
@ -40,14 +42,24 @@ import org.hibernate.boot.model.relational.AuxiliaryDatabaseObject;
|
|||
import org.hibernate.boot.model.relational.Namespace;
|
||||
import org.hibernate.boot.model.relational.Sequence;
|
||||
import org.hibernate.boot.model.source.internal.annotations.AnnotationMetadataSourceProcessorImpl;
|
||||
import org.hibernate.boot.model.source.internal.annotations.DomainModelSource;
|
||||
import org.hibernate.boot.model.source.internal.hbm.EntityHierarchyBuilder;
|
||||
import org.hibernate.boot.model.source.internal.hbm.EntityHierarchySourceImpl;
|
||||
import org.hibernate.boot.model.source.internal.hbm.HbmMetadataSourceProcessorImpl;
|
||||
import org.hibernate.boot.model.source.internal.hbm.MappingDocument;
|
||||
import org.hibernate.boot.model.source.internal.hbm.ModelBinder;
|
||||
import org.hibernate.boot.model.source.spi.MetadataSourceProcessor;
|
||||
import org.hibernate.boot.models.categorize.internal.ClassLoaderServiceLoading;
|
||||
import org.hibernate.boot.models.categorize.internal.DomainModelCategorizationCollector;
|
||||
import org.hibernate.boot.models.categorize.internal.OrmAnnotationHelper;
|
||||
import org.hibernate.boot.models.categorize.spi.ManagedResourcesProcessor;
|
||||
import org.hibernate.boot.models.xml.spi.XmlPreProcessingResult;
|
||||
import org.hibernate.boot.models.xml.spi.XmlPreProcessor;
|
||||
import org.hibernate.boot.models.xml.spi.XmlProcessingResult;
|
||||
import org.hibernate.boot.models.xml.spi.XmlProcessor;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
|
||||
import org.hibernate.boot.spi.AdditionalJaxbMappingProducer;
|
||||
import org.hibernate.boot.spi.AdditionalMappingContributions;
|
||||
import org.hibernate.boot.spi.AdditionalMappingContributor;
|
||||
|
@ -63,6 +75,16 @@ import org.hibernate.engine.config.spi.ConfigurationService;
|
|||
import org.hibernate.engine.config.spi.StandardConverters;
|
||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||
import org.hibernate.mapping.Table;
|
||||
import org.hibernate.models.internal.SourceModelBuildingContextImpl;
|
||||
import org.hibernate.models.internal.jandex.JandexClassDetails;
|
||||
import org.hibernate.models.internal.jandex.JandexIndexerHelper;
|
||||
import org.hibernate.models.internal.jdk.JdkBuilders;
|
||||
import org.hibernate.models.spi.AnnotationDescriptorRegistry;
|
||||
import org.hibernate.models.spi.ClassDetails;
|
||||
import org.hibernate.models.spi.ClassDetailsRegistry;
|
||||
import org.hibernate.models.spi.ClassLoading;
|
||||
import org.hibernate.models.spi.RegistryPrimer;
|
||||
import org.hibernate.models.spi.SourceModelBuildingContext;
|
||||
import org.hibernate.type.BasicType;
|
||||
import org.hibernate.type.BasicTypeRegistry;
|
||||
import org.hibernate.type.SqlTypes;
|
||||
|
@ -82,11 +104,15 @@ import org.hibernate.type.internal.NamedBasicTypeImpl;
|
|||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
import org.hibernate.usertype.CompositeUserType;
|
||||
|
||||
import org.jboss.jandex.ClassInfo;
|
||||
import org.jboss.jandex.CompositeIndex;
|
||||
import org.jboss.jandex.IndexView;
|
||||
import org.jboss.jandex.Indexer;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import jakarta.persistence.AttributeConverter;
|
||||
|
||||
import static org.hibernate.internal.util.collections.CollectionHelper.mutableJoin;
|
||||
import static org.hibernate.internal.util.config.ConfigurationHelper.getPreferredSqlTypeCodeForArray;
|
||||
import static org.hibernate.internal.util.config.ConfigurationHelper.getPreferredSqlTypeCodeForDuration;
|
||||
import static org.hibernate.internal.util.config.ConfigurationHelper.getPreferredSqlTypeCodeForInstant;
|
||||
|
@ -175,8 +201,7 @@ public class MetadataBuildingProcess {
|
|||
|
||||
handleTypes( bootstrapContext, options, metadataCollector );
|
||||
|
||||
final ClassLoaderService classLoaderService =
|
||||
options.getServiceRegistry().requireService( ClassLoaderService.class );
|
||||
final DomainModelSource domainModelSource = processManagedResources( managedResources, bootstrapContext );
|
||||
|
||||
final MetadataBuildingContextRootImpl rootMetadataBuildingContext = new MetadataBuildingContextRootImpl(
|
||||
"orm",
|
||||
|
@ -189,13 +214,12 @@ public class MetadataBuildingProcess {
|
|||
|
||||
bootstrapContext.getTypeConfiguration().scope( rootMetadataBuildingContext );
|
||||
|
||||
|
||||
final IndexView jandexView = bootstrapContext.getJandexView();
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Set up the processors and start binding
|
||||
// NOTE : this becomes even more simplified after we move purely
|
||||
// to unified model
|
||||
final ClassLoaderService classLoaderService = options.getServiceRegistry().getService( ClassLoaderService.class );
|
||||
final IndexView jandexView = domainModelSource.getJandexIndex();
|
||||
|
||||
final MetadataSourceProcessor processor = new MetadataSourceProcessor() {
|
||||
private final MetadataSourceProcessor hbmProcessor =
|
||||
|
@ -205,13 +229,15 @@ public class MetadataBuildingProcess {
|
|||
|
||||
private final AnnotationMetadataSourceProcessorImpl annotationProcessor = new AnnotationMetadataSourceProcessorImpl(
|
||||
managedResources,
|
||||
rootMetadataBuildingContext,
|
||||
jandexView
|
||||
domainModelSource,
|
||||
rootMetadataBuildingContext
|
||||
);
|
||||
|
||||
@Override
|
||||
public void prepare() {
|
||||
hbmProcessor.prepare();
|
||||
|
||||
|
||||
annotationProcessor.prepare();
|
||||
}
|
||||
|
||||
|
@ -346,6 +372,195 @@ public class MetadataBuildingProcess {
|
|||
return metadataCollector.buildMetadataInstance( rootMetadataBuildingContext );
|
||||
}
|
||||
|
||||
@Internal
|
||||
public static DomainModelSource processManagedResources(
|
||||
ManagedResources managedResources,
|
||||
BootstrapContext bootstrapContext) {
|
||||
final ClassLoaderService classLoaderService = bootstrapContext.getServiceRegistry().getService( ClassLoaderService.class );
|
||||
final ClassLoaderServiceLoading classLoading = new ClassLoaderServiceLoading( classLoaderService );
|
||||
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// - pre-process the XML
|
||||
// - collect all known classes
|
||||
// - resolve (possibly building) Jandex index
|
||||
// - build the SourceModelBuildingContext
|
||||
//
|
||||
// INPUTS:
|
||||
// - serviceRegistry
|
||||
// - managedResources
|
||||
// - bootstrapContext (supplied Jandex index, if one)
|
||||
//
|
||||
// OUTPUTS:
|
||||
// - xmlPreProcessingResult
|
||||
// - allKnownClassNames (technically could be included in xmlPreProcessingResult)
|
||||
// - sourceModelBuildingContext
|
||||
|
||||
final XmlPreProcessingResult xmlPreProcessingResult = XmlPreProcessor.preProcessXmlResources( managedResources );
|
||||
|
||||
//noinspection unchecked
|
||||
final List<String> allKnownClassNames = mutableJoin(
|
||||
managedResources.getAnnotatedClassReferences().stream().map( Class::getName ).collect( Collectors.toList() ),
|
||||
managedResources.getAnnotatedClassNames(),
|
||||
xmlPreProcessingResult.getMappedClasses()
|
||||
);
|
||||
managedResources.getAnnotatedPackageNames().forEach( (packageName) -> {
|
||||
try {
|
||||
final Class<?> packageInfoClass = classLoading.classForName( packageName + ".package-info" );
|
||||
allKnownClassNames.add( packageInfoClass.getName() );
|
||||
}
|
||||
catch (ClassLoadingException classLoadingException) {
|
||||
// no package-info, so there can be no annotations... just skip it
|
||||
}
|
||||
} );
|
||||
managedResources.getAnnotatedClassReferences().forEach( (clazz) -> allKnownClassNames.add( clazz.getName() ) );
|
||||
|
||||
// At this point we know all managed class names across all sources.
|
||||
// Resolve the Jandex Index and build the SourceModelBuildingContext.
|
||||
final IndexView jandexIndex = resolveJandexIndex( allKnownClassNames, bootstrapContext.getJandexView(), classLoading );
|
||||
final SourceModelBuildingContextImpl sourceModelBuildingContext = new SourceModelBuildingContextImpl(
|
||||
classLoading,
|
||||
jandexIndex,
|
||||
ManagedResourcesProcessor::preFillRegistries
|
||||
);
|
||||
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// - process metadata-complete XML
|
||||
// - collect overlay XML
|
||||
// - process annotations (including those from metadata-complete XML)
|
||||
// - apply overlay XML
|
||||
//
|
||||
// INPUTS:
|
||||
// - "options" (areIdGeneratorsGlobal, etc)
|
||||
// - xmlPreProcessingResult
|
||||
// - sourceModelBuildingContext
|
||||
//
|
||||
// OUTPUTS
|
||||
// - rootEntities
|
||||
// - mappedSuperClasses
|
||||
// - embeddables
|
||||
|
||||
// JPA id generator global-ity thing
|
||||
final boolean areIdGeneratorsGlobal = true;
|
||||
final ClassDetailsRegistry classDetailsRegistry = sourceModelBuildingContext.getClassDetailsRegistry();
|
||||
final AnnotationDescriptorRegistry descriptorRegistry = sourceModelBuildingContext.getAnnotationDescriptorRegistry();
|
||||
final DomainModelCategorizationCollector modelCategorizationCollector = new DomainModelCategorizationCollector(
|
||||
areIdGeneratorsGlobal,
|
||||
classDetailsRegistry,
|
||||
descriptorRegistry,
|
||||
jandexIndex
|
||||
);
|
||||
|
||||
final XmlProcessingResult xmlProcessingResult = XmlProcessor.processXml( xmlPreProcessingResult, modelCategorizationCollector, sourceModelBuildingContext );
|
||||
|
||||
final HashSet<String> categorizedClassNames = new HashSet<>();
|
||||
allKnownClassNames.forEach( (className) -> applyKnownClass(
|
||||
className,
|
||||
categorizedClassNames,
|
||||
classDetailsRegistry,
|
||||
modelCategorizationCollector
|
||||
) );
|
||||
xmlPreProcessingResult.getMappedNames().forEach( (className) -> applyKnownClass(
|
||||
className,
|
||||
categorizedClassNames,
|
||||
classDetailsRegistry,
|
||||
modelCategorizationCollector
|
||||
) );
|
||||
|
||||
xmlProcessingResult.apply( xmlPreProcessingResult.getPersistenceUnitMetadata() );
|
||||
|
||||
return new DomainModelSource(
|
||||
classDetailsRegistry.makeImmutableCopy(),
|
||||
jandexIndex,
|
||||
modelCategorizationCollector.getGlobalRegistrations(),
|
||||
xmlPreProcessingResult.getPersistenceUnitMetadata()
|
||||
);
|
||||
}
|
||||
|
||||
private static void applyKnownClass(
|
||||
String className,
|
||||
HashSet<String> categorizedClassNames,
|
||||
ClassDetailsRegistry classDetailsRegistry,
|
||||
DomainModelCategorizationCollector modelCategorizationCollector) {
|
||||
if ( categorizedClassNames.add( className ) ) {
|
||||
final ClassDetails classDetails = classDetailsRegistry.resolveClassDetails( className );
|
||||
applyKnownClass( classDetails, categorizedClassNames,classDetailsRegistry, modelCategorizationCollector );
|
||||
}
|
||||
}
|
||||
|
||||
private static void applyKnownClass(
|
||||
ClassDetails classDetails,
|
||||
HashSet<String> categorizedClassNames,
|
||||
ClassDetailsRegistry classDetailsRegistry,
|
||||
DomainModelCategorizationCollector modelCategorizationCollector) {
|
||||
modelCategorizationCollector.apply( classDetails );
|
||||
if ( classDetails.getSuperType() != null ) {
|
||||
if ( categorizedClassNames.add( classDetails.getSuperType().getClassName() ) ) {
|
||||
applyKnownClass( classDetails.getSuperType(), categorizedClassNames, classDetailsRegistry, modelCategorizationCollector );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static IndexView resolveJandexIndex(
|
||||
List<String> allKnownClassNames,
|
||||
IndexView suppliedJandexIndex,
|
||||
ClassLoading classLoading) {
|
||||
// todo : we could build a new Jandex (Composite)Index that includes the `managedResources#getAnnotatedClassNames`
|
||||
// and all classes from `managedResources#getXmlMappingBindings`. Only really worth it in the case
|
||||
// of runtime enhancement. This would definitely need to be toggle-able.
|
||||
// +
|
||||
// For now, let's not as it does not matter for this PoC
|
||||
if ( 1 == 1 ) {
|
||||
return suppliedJandexIndex;
|
||||
}
|
||||
|
||||
final Indexer jandexIndexer = new Indexer();
|
||||
for ( String knownClassName : allKnownClassNames ) {
|
||||
JandexIndexerHelper.apply( knownClassName, jandexIndexer, classLoading );
|
||||
}
|
||||
|
||||
if ( suppliedJandexIndex == null ) {
|
||||
return jandexIndexer.complete();
|
||||
}
|
||||
|
||||
return CompositeIndex.create( suppliedJandexIndex, jandexIndexer.complete() );
|
||||
}
|
||||
|
||||
public static void preFillRegistries(RegistryPrimer.Contributions contributions, SourceModelBuildingContext buildingContext) {
|
||||
OrmAnnotationHelper.forEachOrmAnnotation( contributions::registerAnnotation );
|
||||
|
||||
final IndexView jandexIndex = buildingContext.getJandexIndex();
|
||||
if ( jandexIndex == null ) {
|
||||
return;
|
||||
}
|
||||
|
||||
final ClassDetailsRegistry classDetailsRegistry = buildingContext.getClassDetailsRegistry();
|
||||
final AnnotationDescriptorRegistry annotationDescriptorRegistry = buildingContext.getAnnotationDescriptorRegistry();
|
||||
|
||||
for ( ClassInfo knownClass : jandexIndex.getKnownClasses() ) {
|
||||
final String className = knownClass.name().toString();
|
||||
|
||||
if ( knownClass.isAnnotation() ) {
|
||||
// it is always safe to load the annotation classes - we will never be enhancing them
|
||||
//noinspection rawtypes
|
||||
final Class annotationClass = buildingContext
|
||||
.getClassLoading()
|
||||
.classForName( className );
|
||||
//noinspection unchecked
|
||||
annotationDescriptorRegistry.resolveDescriptor(
|
||||
annotationClass,
|
||||
(t) -> JdkBuilders.buildAnnotationDescriptor( annotationClass, buildingContext.getAnnotationDescriptorRegistry() )
|
||||
);
|
||||
}
|
||||
|
||||
classDetailsRegistry.resolveClassDetails(
|
||||
className,
|
||||
(name) -> new JandexClassDetails( knownClass, buildingContext )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private static void processAdditionalMappingContributions(
|
||||
InFlightMetadataCollectorImpl metadataCollector,
|
||||
MetadataBuildingOptions options,
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.orm.test.boot.models;
|
||||
package org.hibernate.boot.model.source.internal.annotations;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
@ -23,12 +23,12 @@ import org.hibernate.boot.model.process.spi.ManagedResources;
|
|||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class ManagedResourcesImpl implements ManagedResources {
|
||||
public class AdditionalManagedResourcesImpl implements ManagedResources {
|
||||
private final Collection<Class<?>> knownClasses;
|
||||
private final Collection<String> packageNames;
|
||||
private final Collection<Binding<JaxbBindableMappingDescriptor>> xmlMappings;
|
||||
|
||||
public ManagedResourcesImpl(
|
||||
public AdditionalManagedResourcesImpl(
|
||||
Collection<Class<?>> knownClasses,
|
||||
Collection<String> packageNames,
|
||||
Collection<Binding<JaxbBindableMappingDescriptor>> xmlMappings) {
|
||||
|
@ -80,27 +80,39 @@ public class ManagedResourcesImpl implements ManagedResources {
|
|||
private Collection<Binding<JaxbBindableMappingDescriptor>> xmlMappings;
|
||||
|
||||
public Builder() {
|
||||
this( new MappingBinder.Options() {
|
||||
@Override
|
||||
public boolean validateMappings() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean transformHbmMappings() {
|
||||
return false;
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
public Builder(MappingBinder.Options options) {
|
||||
mappingBinder = new MappingBinder(
|
||||
(resourceName) -> Builder.class.getClassLoader().getResourceAsStream( resourceName ),
|
||||
new MappingBinder.Options() {
|
||||
@Override
|
||||
public boolean validateMappings() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean transformHbmMappings() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
public Builder addLoadedClasses(Class<?>... classes) {
|
||||
public Builder addLoadedClasses(List<Class<?>> additionalClasses) {
|
||||
if ( this.classes == null ) {
|
||||
this.classes = new ArrayList<>();
|
||||
}
|
||||
Collections.addAll( this.classes, classes );
|
||||
this.classes.addAll( additionalClasses );
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder addLoadedClasses(Class<?>... additionalClasses) {
|
||||
if ( this.classes == null ) {
|
||||
this.classes = new ArrayList<>();
|
||||
}
|
||||
Collections.addAll( this.classes, additionalClasses );
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -113,14 +125,21 @@ public class ManagedResourcesImpl implements ManagedResources {
|
|||
}
|
||||
|
||||
public ManagedResources build() {
|
||||
return new ManagedResourcesImpl( classes, packageNames, xmlMappings );
|
||||
return new AdditionalManagedResourcesImpl( classes, packageNames, xmlMappings );
|
||||
}
|
||||
|
||||
public Builder addXmlMappings(String resourceName) {
|
||||
final Binding<JaxbBindableMappingDescriptor> binding = mappingBinder.bind(
|
||||
return addXmlMappings( resourceName, new Origin( SourceType.RESOURCE, resourceName ) );
|
||||
}
|
||||
|
||||
public Builder addXmlMappings(String resourceName, Origin origin) {
|
||||
return addXmlBinding( mappingBinder.bind(
|
||||
Builder.class.getClassLoader().getResourceAsStream( resourceName ),
|
||||
new Origin( SourceType.RESOURCE, resourceName )
|
||||
);
|
||||
origin
|
||||
) );
|
||||
}
|
||||
|
||||
public Builder addXmlBinding(Binding<JaxbBindableMappingDescriptor> binding) {
|
||||
if ( xmlMappings == null ) {
|
||||
xmlMappings = new ArrayList<>();
|
||||
}
|
|
@ -7,6 +7,7 @@
|
|||
package org.hibernate.boot.model.source.internal.annotations;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -16,69 +17,106 @@ import org.hibernate.annotations.common.reflection.MetadataProviderInjector;
|
|||
import org.hibernate.annotations.common.reflection.ReflectionManager;
|
||||
import org.hibernate.annotations.common.reflection.XClass;
|
||||
import org.hibernate.boot.internal.MetadataBuildingContextRootImpl;
|
||||
import org.hibernate.boot.jaxb.Origin;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityMappingsImpl;
|
||||
import org.hibernate.boot.jaxb.spi.Binding;
|
||||
import org.hibernate.boot.model.convert.internal.ClassBasedConverterDescriptor;
|
||||
import org.hibernate.boot.model.convert.spi.ConverterRegistry;
|
||||
import org.hibernate.boot.model.convert.spi.RegisteredConversion;
|
||||
import org.hibernate.boot.model.internal.AnnotationBinder;
|
||||
import org.hibernate.boot.model.internal.InheritanceState;
|
||||
import org.hibernate.boot.model.internal.JPAXMLOverriddenMetadataProvider;
|
||||
import org.hibernate.boot.model.process.spi.ManagedResources;
|
||||
import org.hibernate.boot.model.process.spi.MetadataBuildingProcess;
|
||||
import org.hibernate.boot.model.source.spi.MetadataSourceProcessor;
|
||||
import org.hibernate.boot.models.categorize.spi.FilterDefRegistration;
|
||||
import org.hibernate.boot.models.xml.spi.PersistenceUnitMetadata;
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.boot.spi.JpaOrmXmlPersistenceUnitDefaultAware;
|
||||
import org.hibernate.boot.spi.JpaOrmXmlPersistenceUnitDefaultAware.JpaOrmXmlPersistenceUnitDefaults;
|
||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||
import org.hibernate.boot.spi.MetadataBuildingOptions;
|
||||
import org.hibernate.engine.spi.FilterDefinition;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||
import org.jboss.jandex.IndexView;
|
||||
import org.hibernate.metamodel.mapping.JdbcMapping;
|
||||
import org.hibernate.models.spi.ClassDetails;
|
||||
import org.hibernate.type.descriptor.java.JavaType;
|
||||
import org.hibernate.usertype.UserType;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import jakarta.persistence.AttributeConverter;
|
||||
import jakarta.persistence.Converter;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.MappedSuperclass;
|
||||
|
||||
import static org.hibernate.boot.jaxb.SourceType.OTHER;
|
||||
import static org.hibernate.boot.model.internal.AnnotationBinder.resolveAttributeConverter;
|
||||
import static org.hibernate.boot.model.internal.AnnotationBinder.resolveBasicType;
|
||||
import static org.hibernate.boot.model.internal.AnnotationBinder.resolveFilterParamType;
|
||||
import static org.hibernate.boot.model.internal.AnnotationBinder.resolveJavaType;
|
||||
import static org.hibernate.boot.model.internal.AnnotationBinder.resolveUserType;
|
||||
import static org.hibernate.models.internal.jdk.VoidClassDetails.VOID_CLASS_DETAILS;
|
||||
import static org.hibernate.models.internal.jdk.VoidClassDetails.VOID_OBJECT_CLASS_DETAILS;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class AnnotationMetadataSourceProcessorImpl implements MetadataSourceProcessor {
|
||||
private static final Logger log = Logger.getLogger( AnnotationMetadataSourceProcessorImpl.class );
|
||||
|
||||
private final MetadataBuildingContextRootImpl rootMetadataBuildingContext;
|
||||
// NOTE : we de-categorize the classes into a single collection (xClasses) here to work with the
|
||||
// existing "binder" infrastructure.
|
||||
// todo : once we move to the phased binding approach, come back and handle that
|
||||
|
||||
@SuppressWarnings({ "FieldCanBeLocal", "unused" })
|
||||
private final IndexView jandexView;
|
||||
private final DomainModelSource domainModelSource;
|
||||
|
||||
private final MetadataBuildingContextRootImpl rootMetadataBuildingContext;
|
||||
private final ClassLoaderService classLoaderService;
|
||||
|
||||
private final ReflectionManager reflectionManager;
|
||||
|
||||
private final LinkedHashSet<String> annotatedPackages = new LinkedHashSet<>();
|
||||
|
||||
private final List<XClass> xClasses = new ArrayList<>();
|
||||
private final ClassLoaderService classLoaderService;
|
||||
|
||||
/**
|
||||
* Normal constructor used while processing {@linkplain org.hibernate.boot.MetadataSources mapping sources}
|
||||
*/
|
||||
public AnnotationMetadataSourceProcessorImpl(
|
||||
ManagedResources managedResources,
|
||||
final MetadataBuildingContextRootImpl rootMetadataBuildingContext,
|
||||
IndexView jandexView) {
|
||||
DomainModelSource domainModelSource,
|
||||
MetadataBuildingContextRootImpl rootMetadataBuildingContext) {
|
||||
this.domainModelSource = domainModelSource;
|
||||
this.rootMetadataBuildingContext = rootMetadataBuildingContext;
|
||||
this.jandexView = jandexView;
|
||||
|
||||
this.reflectionManager = rootMetadataBuildingContext.getBootstrapContext().getReflectionManager();
|
||||
|
||||
if ( CollectionHelper.isNotEmpty( managedResources.getAnnotatedPackageNames() ) ) {
|
||||
annotatedPackages.addAll( managedResources.getAnnotatedPackageNames() );
|
||||
}
|
||||
final MetadataBuildingOptions metadataBuildingOptions = rootMetadataBuildingContext.getBuildingOptions();
|
||||
this.classLoaderService = metadataBuildingOptions.getServiceRegistry().getService( ClassLoaderService.class );
|
||||
|
||||
final ConverterRegistry converterRegistry = rootMetadataBuildingContext.getMetadataCollector().getConverterRegistry();
|
||||
domainModelSource.getConversionRegistrations().forEach( (registration) -> {
|
||||
final Class<?> domainType;
|
||||
if ( registration.getExplicitDomainType() == VOID_CLASS_DETAILS || registration.getExplicitDomainType() == VOID_OBJECT_CLASS_DETAILS ) {
|
||||
domainType = void.class;
|
||||
}
|
||||
else {
|
||||
domainType = classLoaderService.classForName( registration.getExplicitDomainType().getClassName() );
|
||||
}
|
||||
converterRegistry.addRegisteredConversion( new RegisteredConversion(
|
||||
domainType,
|
||||
classLoaderService.classForName( registration.getConverterType().getClassName() ),
|
||||
registration.isAutoApply(),
|
||||
rootMetadataBuildingContext
|
||||
) );
|
||||
} );
|
||||
domainModelSource.getConverterRegistrations().forEach( (registration) -> {
|
||||
converterRegistry.addAttributeConverter( new ClassBasedConverterDescriptor(
|
||||
classLoaderService.classForName( registration.converterClass().getClassName() ),
|
||||
registration.autoApply(),
|
||||
rootMetadataBuildingContext.getBootstrapContext().getClassmateContext()
|
||||
) );
|
||||
} );
|
||||
|
||||
final ConverterRegistry converterRegistry =
|
||||
rootMetadataBuildingContext.getMetadataCollector().getConverterRegistry();
|
||||
this.classLoaderService =
|
||||
rootMetadataBuildingContext.getBuildingOptions().getServiceRegistry()
|
||||
.requireService( ClassLoaderService.class );
|
||||
|
||||
MetadataBuildingOptions metadataBuildingOptions = rootMetadataBuildingContext.getBuildingOptions();
|
||||
if ( metadataBuildingOptions.isXmlMappingEnabled() ) {
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Ewww. This is temporary until we migrate to Jandex + StAX for annotation binding
|
||||
|
@ -90,111 +128,77 @@ public class AnnotationMetadataSourceProcessorImpl implements MetadataSourceProc
|
|||
continue;
|
||||
}
|
||||
final JaxbEntityMappingsImpl entityMappings = (JaxbEntityMappingsImpl) xmlBinding.getRoot();
|
||||
|
||||
final List<String> classNames = jpaMetadataProvider.getXMLContext().addDocument( entityMappings );
|
||||
for ( String className : classNames ) {
|
||||
xClasses.add( toXClass( className, reflectionManager, classLoaderService ) );
|
||||
xClasses.add( toXClass( className ) );
|
||||
}
|
||||
}
|
||||
jpaMetadataProvider.getXMLContext().applyDiscoveredAttributeConverters( converterRegistry );
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
}
|
||||
|
||||
for ( String className : managedResources.getAnnotatedClassNames() ) {
|
||||
final Class<?> annotatedClass = classLoaderService.classForName( className );
|
||||
categorizeAnnotatedClass( annotatedClass, converterRegistry );
|
||||
xClasses.add( toXClass( annotatedClass ) );
|
||||
}
|
||||
|
||||
for ( Class<?> annotatedClass : managedResources.getAnnotatedClassReferences() ) {
|
||||
categorizeAnnotatedClass( annotatedClass, converterRegistry );
|
||||
xClasses.add( toXClass( annotatedClass ) );
|
||||
}
|
||||
|
||||
annotatedPackages.addAll( managedResources.getAnnotatedPackageNames() );
|
||||
}
|
||||
|
||||
private XClass toXClass(String className) {
|
||||
return reflectionManager.toXClass( classLoaderService.classForName( className ) );
|
||||
}
|
||||
|
||||
private XClass toXClass(Class<?> classRef) {
|
||||
return reflectionManager.toXClass( classRef );
|
||||
}
|
||||
|
||||
/**
|
||||
* Used as part of processing
|
||||
* {@linkplain org.hibernate.boot.spi.AdditionalMappingContributions#contributeEntity(Class)} "additional" mappings}
|
||||
* {@linkplain org.hibernate.boot.spi.AdditionalMappingContributions#contributeEntity(Class) "additional" mappings}
|
||||
*/
|
||||
public static void processAdditionalMappings(
|
||||
List<Class<?>> additionalClasses,
|
||||
List<JaxbEntityMappingsImpl> additionalJaxbMappings,
|
||||
MetadataBuildingContextRootImpl rootMetadataBuildingContext) {
|
||||
final AnnotationMetadataSourceProcessorImpl processor = new AnnotationMetadataSourceProcessorImpl( rootMetadataBuildingContext );
|
||||
|
||||
if ( additionalJaxbMappings != null && rootMetadataBuildingContext.getBuildingOptions().isXmlMappingEnabled() ) {
|
||||
final ConverterRegistry converterRegistry = rootMetadataBuildingContext.getMetadataCollector().getConverterRegistry();
|
||||
final MetadataProviderInjector injector = (MetadataProviderInjector) processor.reflectionManager;
|
||||
final JPAXMLOverriddenMetadataProvider metadataProvider = (JPAXMLOverriddenMetadataProvider) injector.getMetadataProvider();
|
||||
|
||||
for ( int i = 0; i < additionalJaxbMappings.size(); i++ ) {
|
||||
final List<String> classNames = metadataProvider.getXMLContext().addDocument( additionalJaxbMappings.get( i ) );
|
||||
for ( String className : classNames ) {
|
||||
final XClass xClass = processor.toXClass( className, processor.reflectionManager, processor.classLoaderService );
|
||||
processor.xClasses.add( xClass );
|
||||
}
|
||||
}
|
||||
metadataProvider.getXMLContext().applyDiscoveredAttributeConverters( converterRegistry );
|
||||
}
|
||||
|
||||
for ( int i = 0; i < additionalClasses.size(); i++ ) {
|
||||
final XClass xClass = processor.reflectionManager.toXClass( additionalClasses.get( i ) );
|
||||
if ( !xClass.isAnnotationPresent( Entity.class ) ) {
|
||||
log.debugf( "@Entity not found on additional entity class - `%s`" );
|
||||
continue;
|
||||
}
|
||||
processor.xClasses.add( xClass );
|
||||
final AdditionalManagedResourcesImpl.Builder mrBuilder = new AdditionalManagedResourcesImpl.Builder();
|
||||
mrBuilder.addLoadedClasses( additionalClasses );
|
||||
for ( JaxbEntityMappingsImpl additionalJaxbMapping : additionalJaxbMappings ) {
|
||||
mrBuilder.addXmlBinding( new Binding<>( additionalJaxbMapping, new Origin( OTHER, "additional" ) ) );
|
||||
}
|
||||
|
||||
final ManagedResources mr = mrBuilder.build();
|
||||
final DomainModelSource additionalDomainModelSource = MetadataBuildingProcess.processManagedResources(
|
||||
mr,
|
||||
rootMetadataBuildingContext.getBootstrapContext()
|
||||
);
|
||||
final AnnotationMetadataSourceProcessorImpl processor = new AnnotationMetadataSourceProcessorImpl( mr, additionalDomainModelSource, rootMetadataBuildingContext );
|
||||
processor.processEntityHierarchies( new LinkedHashSet<>() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Form used from {@link #processAdditionalMappings}
|
||||
*/
|
||||
private AnnotationMetadataSourceProcessorImpl(MetadataBuildingContextRootImpl rootMetadataBuildingContext) {
|
||||
this.rootMetadataBuildingContext = rootMetadataBuildingContext;
|
||||
this.jandexView = null;
|
||||
|
||||
this.reflectionManager = rootMetadataBuildingContext.getBootstrapContext().getReflectionManager();
|
||||
this.classLoaderService = rootMetadataBuildingContext.getBuildingOptions().getServiceRegistry().getService( ClassLoaderService.class );
|
||||
}
|
||||
|
||||
private void categorizeAnnotatedClass(Class<?> annotatedClass, ConverterRegistry converterRegistry) {
|
||||
final XClass xClass = reflectionManager.toXClass( annotatedClass );
|
||||
// categorize it, based on assumption it does not fall into multiple categories
|
||||
if ( xClass.isAnnotationPresent( Converter.class ) ) {
|
||||
//noinspection unchecked
|
||||
converterRegistry.addAttributeConverter( (Class<? extends AttributeConverter<?,?>>) annotatedClass );
|
||||
}
|
||||
else {
|
||||
xClasses.add( xClass );
|
||||
}
|
||||
}
|
||||
|
||||
private XClass toXClass(String className, ReflectionManager reflectionManager, ClassLoaderService cls) {
|
||||
return reflectionManager.toXClass( cls.classForName( className ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepare() {
|
||||
// use any persistence-unit-defaults defined in orm.xml
|
||||
// todo : invert this to use the PersistenceUnitMetadata directly (defaulting to the settings)
|
||||
( (JpaOrmXmlPersistenceUnitDefaultAware) rootMetadataBuildingContext.getBuildingOptions() ).apply(
|
||||
new JpaOrmXmlPersistenceUnitDefaults() {
|
||||
final Map<?,?> persistenceUnitDefaults = reflectionManager.getDefaults();
|
||||
final PersistenceUnitMetadata persistenceUnitMetadata = domainModelSource.getPersistenceUnitMetadata();
|
||||
|
||||
@Override
|
||||
public String getDefaultSchemaName() {
|
||||
return StringHelper.nullIfEmpty( (String) persistenceUnitDefaults.get( "schema" ) );
|
||||
return StringHelper.nullIfEmpty( persistenceUnitMetadata.getDefaultSchema() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultCatalogName() {
|
||||
return StringHelper.nullIfEmpty( (String) persistenceUnitDefaults.get( "catalog" ) );
|
||||
return StringHelper.nullIfEmpty( persistenceUnitMetadata.getDefaultCatalog() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldImplicitlyQuoteIdentifiers() {
|
||||
final Object isDelimited = persistenceUnitDefaults.get( "delimited-identifier" );
|
||||
return isDelimited == Boolean.TRUE;
|
||||
return persistenceUnitMetadata.useQuotedIdentifiers();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -232,6 +236,50 @@ public class AnnotationMetadataSourceProcessorImpl implements MetadataSourceProc
|
|||
|
||||
@Override
|
||||
public void processFilterDefinitions() {
|
||||
final Map<String, FilterDefRegistration> filterDefRegistrations = domainModelSource.getGlobalRegistrations().getFilterDefRegistrations();
|
||||
for ( Map.Entry<String, FilterDefRegistration> filterDefRegistrationEntry : filterDefRegistrations.entrySet() ) {
|
||||
final Map<String, JdbcMapping> parameterJdbcMappings = new HashMap<>();
|
||||
final Map<String, ClassDetails> parameterDefinitions = filterDefRegistrationEntry.getValue().getParameters();
|
||||
if ( CollectionHelper.isNotEmpty( parameterDefinitions ) ) {
|
||||
for ( Map.Entry<String, ClassDetails> parameterEntry : parameterDefinitions.entrySet() ) {
|
||||
final String parameterClassName = parameterEntry.getValue().getClassName();
|
||||
final ClassDetails parameterClassDetails = domainModelSource.getClassDetailsRegistry().resolveClassDetails( parameterClassName );
|
||||
parameterJdbcMappings.put(
|
||||
parameterEntry.getKey(),
|
||||
resolveFilterParamType( parameterClassDetails, rootMetadataBuildingContext )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
rootMetadataBuildingContext.getMetadataCollector().addFilterDefinition( new FilterDefinition(
|
||||
filterDefRegistrationEntry.getValue().getName(),
|
||||
filterDefRegistrationEntry.getValue().getDefaultCondition(),
|
||||
parameterJdbcMappings
|
||||
) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static JdbcMapping resolveFilterParamType(
|
||||
ClassDetails classDetails,
|
||||
MetadataBuildingContext context) {
|
||||
if ( classDetails.isImplementor( UserType.class ) ) {
|
||||
final Class<UserType<?>> impl = classDetails.toJavaClass();
|
||||
return resolveUserType( impl, context );
|
||||
|
||||
}
|
||||
|
||||
if ( classDetails.isImplementor( AttributeConverter.class ) ) {
|
||||
final Class<AttributeConverter<?,?>> impl = classDetails.toJavaClass();
|
||||
return resolveAttributeConverter( impl, context );
|
||||
}
|
||||
|
||||
if ( classDetails.isImplementor( JavaType.class ) ) {
|
||||
final Class<JavaType<?>> impl = classDetails.toJavaClass();
|
||||
return resolveJavaType( impl, context );
|
||||
}
|
||||
|
||||
return resolveBasicType( classDetails.toJavaClass(), context );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.boot.model.source.internal.annotations;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hibernate.boot.models.categorize.spi.ConversionRegistration;
|
||||
import org.hibernate.boot.models.categorize.spi.ConverterRegistration;
|
||||
import org.hibernate.boot.models.categorize.spi.GlobalRegistrations;
|
||||
import org.hibernate.boot.models.xml.spi.PersistenceUnitMetadata;
|
||||
import org.hibernate.models.spi.ClassDetailsRegistry;
|
||||
|
||||
import org.jboss.jandex.IndexView;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class DomainModelSource {
|
||||
private final ClassDetailsRegistry classDetailsRegistry;
|
||||
private final IndexView jandexIndex;
|
||||
private final GlobalRegistrations globalRegistrations;
|
||||
private final PersistenceUnitMetadata persistenceUnitMetadata;
|
||||
|
||||
public DomainModelSource(
|
||||
ClassDetailsRegistry classDetailsRegistry,
|
||||
IndexView jandexIndex,
|
||||
GlobalRegistrations globalRegistrations,
|
||||
PersistenceUnitMetadata persistenceUnitMetadata) {
|
||||
this.classDetailsRegistry = classDetailsRegistry;
|
||||
this.jandexIndex = jandexIndex;
|
||||
this.globalRegistrations = globalRegistrations;
|
||||
this.persistenceUnitMetadata = persistenceUnitMetadata;
|
||||
}
|
||||
|
||||
public ClassDetailsRegistry getClassDetailsRegistry() {
|
||||
return classDetailsRegistry;
|
||||
}
|
||||
|
||||
public IndexView getJandexIndex() {
|
||||
return jandexIndex;
|
||||
}
|
||||
|
||||
public GlobalRegistrations getGlobalRegistrations() {
|
||||
return globalRegistrations;
|
||||
}
|
||||
|
||||
public List<ConversionRegistration> getConversionRegistrations() {
|
||||
return globalRegistrations.getConverterRegistrations();
|
||||
}
|
||||
|
||||
public Set<ConverterRegistration> getConverterRegistrations() {
|
||||
return globalRegistrations.getJpaConverters();
|
||||
}
|
||||
|
||||
public PersistenceUnitMetadata getPersistenceUnitMetadata() {
|
||||
return persistenceUnitMetadata;
|
||||
}
|
||||
}
|
|
@ -6,10 +6,12 @@
|
|||
*/
|
||||
package org.hibernate.boot.models;
|
||||
|
||||
import org.hibernate.MappingException;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class AnnotationPlacementException extends RuntimeException {
|
||||
public class AnnotationPlacementException extends MappingException {
|
||||
public AnnotationPlacementException(String message) {
|
||||
super( message );
|
||||
}
|
||||
|
|
|
@ -6,12 +6,14 @@
|
|||
*/
|
||||
package org.hibernate.boot.models;
|
||||
|
||||
import org.hibernate.MappingException;
|
||||
|
||||
/**
|
||||
* Indicates a problem resolving a member from {@linkplain org.hibernate.models.spi.ClassDetails}
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class MemberResolutionException extends RuntimeException {
|
||||
public class MemberResolutionException extends MappingException {
|
||||
public MemberResolutionException(String message) {
|
||||
super( message );
|
||||
}
|
||||
|
|
|
@ -34,7 +34,12 @@ public class MultipleAttributeNaturesException extends MappingException {
|
|||
final StringBuilder buffer = new StringBuilder( "Attribute `" )
|
||||
.append( attributeName )
|
||||
.append( "` expressed multiple natures [" );
|
||||
natures.forEach( buffer::append );
|
||||
String separator = "";
|
||||
for ( AttributeMetadata.AttributeNature nature : natures ) {
|
||||
buffer.append( separator );
|
||||
buffer.append( nature.name() );
|
||||
separator = ",";
|
||||
}
|
||||
return buffer.append( "]" ).toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,10 +12,12 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.hibernate.boot.models.categorize.spi.ClassAttributeAccessType;
|
||||
import org.hibernate.boot.models.categorize.spi.EntityHierarchy;
|
||||
import org.hibernate.boot.models.categorize.spi.IdentifiableTypeMetadata;
|
||||
import org.hibernate.boot.models.categorize.spi.JpaEventListener;
|
||||
import org.hibernate.boot.models.categorize.spi.JpaEventListenerStyle;
|
||||
import org.hibernate.boot.models.categorize.spi.MappedSuperclassTypeMetadata;
|
||||
import org.hibernate.boot.models.categorize.spi.ModelCategorizationContext;
|
||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||
import org.hibernate.models.spi.AnnotationUsage;
|
||||
|
@ -35,33 +37,34 @@ public abstract class AbstractIdentifiableTypeMetadata
|
|||
extends AbstractManagedTypeMetadata
|
||||
implements IdentifiableTypeMetadata {
|
||||
private final EntityHierarchy hierarchy;
|
||||
private final AbstractIdentifiableTypeMetadata superType;
|
||||
private final IdentifiableTypeMetadata superType;
|
||||
private final Set<IdentifiableTypeMetadata> subTypes = new HashSet<>();
|
||||
private final AccessType accessType;
|
||||
private final ClassAttributeAccessType classLevelAccessType;
|
||||
|
||||
/**
|
||||
* Used when creating the hierarchy root-root
|
||||
*
|
||||
* @param accessType This is the hierarchy default
|
||||
* @param implicitAccessType This is the hierarchy default
|
||||
*/
|
||||
public AbstractIdentifiableTypeMetadata(
|
||||
ClassDetails classDetails,
|
||||
EntityHierarchy hierarchy,
|
||||
AccessType accessType,
|
||||
MappedSuperclassTypeMetadata superTypeMetadata,
|
||||
AccessType implicitAccessType,
|
||||
ModelCategorizationContext processingContext) {
|
||||
super( classDetails, processingContext );
|
||||
|
||||
this.hierarchy = hierarchy;
|
||||
this.superType = null;
|
||||
this.superType = superTypeMetadata;
|
||||
|
||||
this.accessType = CategorizationHelper.determineAccessType( classDetails, accessType );
|
||||
this.classLevelAccessType = CategorizationHelper.determineAccessType( classDetails, implicitAccessType );
|
||||
}
|
||||
|
||||
|
||||
public AbstractIdentifiableTypeMetadata(
|
||||
ClassDetails classDetails,
|
||||
EntityHierarchy hierarchy,
|
||||
AbstractIdentifiableTypeMetadata superType,
|
||||
IdentifiableTypeMetadata superType,
|
||||
ModelCategorizationContext processingContext) {
|
||||
super( classDetails, processingContext );
|
||||
|
||||
|
@ -70,14 +73,20 @@ public abstract class AbstractIdentifiableTypeMetadata
|
|||
this.hierarchy = hierarchy;
|
||||
this.superType = superType;
|
||||
|
||||
this.accessType = CategorizationHelper.determineAccessType( classDetails, superType.getAccessType() );
|
||||
// this is arguably more logical, but the specification is very clear that this should come
|
||||
// from the hierarchy default not the super in section _2.3.2 Explicit Access Type_
|
||||
//this.accessType = CategorizationHelper.determineAccessType( classDetails, superType.getAccessType() );
|
||||
this.classLevelAccessType = CategorizationHelper.determineAccessType( classDetails, hierarchy.getDefaultAccessType() );
|
||||
}
|
||||
|
||||
protected void postInstantiate(HierarchyTypeConsumer typeConsumer) {
|
||||
protected void postInstantiate(boolean rootEntityOrSubclass, HierarchyTypeConsumer typeConsumer) {
|
||||
typeConsumer.acceptType( this );
|
||||
|
||||
// now we can effectively walk subs
|
||||
walkSubclasses( typeConsumer );
|
||||
// now we can effectively walk subs, although we skip that for the mapped-superclasses
|
||||
// "above" the root entity
|
||||
if ( rootEntityOrSubclass ) {
|
||||
walkSubclasses( typeConsumer );
|
||||
}
|
||||
|
||||
// the idea here is to collect up class-level annotations and to apply
|
||||
// the maps from supers
|
||||
|
@ -122,7 +131,7 @@ public abstract class AbstractIdentifiableTypeMetadata
|
|||
|
||||
}
|
||||
|
||||
private void addSubclass(IdentifiableTypeMetadata subclass) {
|
||||
protected void addSubclass(IdentifiableTypeMetadata subclass) {
|
||||
subTypes.add( subclass );
|
||||
}
|
||||
|
||||
|
@ -165,8 +174,8 @@ public abstract class AbstractIdentifiableTypeMetadata
|
|||
}
|
||||
|
||||
@Override
|
||||
public AccessType getAccessType() {
|
||||
return accessType;
|
||||
public ClassAttributeAccessType getClassLevelAccessType() {
|
||||
return classLevelAccessType;
|
||||
}
|
||||
|
||||
protected void collectConversionInfo() {
|
||||
|
|
|
@ -134,14 +134,14 @@ public abstract class AbstractManagedTypeMetadata implements ManagedTypeMetadata
|
|||
protected List<AttributeMetadata> resolveAttributes(AllMemberConsumer memberConsumer) {
|
||||
final List<MemberDetails> backingMembers = getModelContext()
|
||||
.getPersistentAttributeMemberResolver()
|
||||
.resolveAttributesMembers( classDetails, getAccessType(), memberConsumer );
|
||||
.resolveAttributesMembers( classDetails, getClassLevelAccessType(), memberConsumer );
|
||||
|
||||
final List<AttributeMetadata> attributeList = arrayList( backingMembers.size() );
|
||||
|
||||
for ( MemberDetails backingMember : backingMembers ) {
|
||||
final AttributeMetadata attribute = new AttributeMetadataImpl(
|
||||
backingMember.resolveAttributeName(),
|
||||
CategorizationHelper.determineAttributeNature( backingMember ),
|
||||
CategorizationHelper.determineAttributeNature( classDetails, backingMember ),
|
||||
backingMember
|
||||
);
|
||||
attributeList.add( attribute );
|
||||
|
|
|
@ -14,14 +14,13 @@ import java.util.function.Function;
|
|||
|
||||
import org.hibernate.boot.models.JpaAnnotations;
|
||||
import org.hibernate.boot.models.categorize.spi.AllMemberConsumer;
|
||||
import org.hibernate.boot.models.categorize.spi.ClassAttributeAccessType;
|
||||
import org.hibernate.boot.models.categorize.spi.PersistentAttributeMemberResolver;
|
||||
import org.hibernate.models.spi.ClassDetails;
|
||||
import org.hibernate.models.spi.FieldDetails;
|
||||
import org.hibernate.models.spi.MemberDetails;
|
||||
import org.hibernate.models.spi.MethodDetails;
|
||||
|
||||
import jakarta.persistence.AccessType;
|
||||
|
||||
/**
|
||||
* "Template" support for writing PersistentAttributeMemberResolver
|
||||
* implementations.
|
||||
|
@ -49,12 +48,12 @@ public abstract class AbstractPersistentAttributeMemberResolver implements Persi
|
|||
Function<FieldDetails,Boolean> transientFieldChecker,
|
||||
Function<MethodDetails,Boolean> transientMethodChecker,
|
||||
ClassDetails classDetails,
|
||||
AccessType classLevelAccessType);
|
||||
ClassAttributeAccessType classLevelAccessType);
|
||||
|
||||
@Override
|
||||
public List<MemberDetails> resolveAttributesMembers(
|
||||
ClassDetails classDetails,
|
||||
AccessType classLevelAccessType,
|
||||
ClassAttributeAccessType classLevelAccessType,
|
||||
AllMemberConsumer memberConsumer) {
|
||||
|
||||
final Set<FieldDetails> transientFields = new HashSet<>();
|
||||
|
|
|
@ -13,8 +13,9 @@ import org.hibernate.annotations.ManyToAny;
|
|||
import org.hibernate.boot.models.HibernateAnnotations;
|
||||
import org.hibernate.boot.models.JpaAnnotations;
|
||||
import org.hibernate.boot.models.MultipleAttributeNaturesException;
|
||||
import org.hibernate.boot.models.categorize.ModelCategorizationLogging;
|
||||
import org.hibernate.boot.models.categorize.spi.AttributeMetadata;
|
||||
import org.hibernate.boot.models.categorize.spi.ClassAttributeAccessType;
|
||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||
import org.hibernate.models.spi.AnnotationUsage;
|
||||
import org.hibernate.models.spi.ClassDetails;
|
||||
import org.hibernate.models.spi.MemberDetails;
|
||||
|
@ -30,6 +31,14 @@ import jakarta.persistence.ManyToOne;
|
|||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.OneToOne;
|
||||
|
||||
import static org.hibernate.boot.models.categorize.ModelCategorizationLogging.MODEL_CATEGORIZATION_LOGGER;
|
||||
import static org.hibernate.boot.models.categorize.spi.AttributeMetadata.AttributeNature.BASIC;
|
||||
import static org.hibernate.boot.models.categorize.spi.AttributeMetadata.AttributeNature.ELEMENT_COLLECTION;
|
||||
import static org.hibernate.boot.models.categorize.spi.AttributeMetadata.AttributeNature.EMBEDDED;
|
||||
import static org.hibernate.boot.models.categorize.spi.AttributeMetadata.AttributeNature.MANY_TO_ANY;
|
||||
import static org.hibernate.boot.models.categorize.spi.AttributeMetadata.AttributeNature.MANY_TO_MANY;
|
||||
import static org.hibernate.boot.models.categorize.spi.AttributeMetadata.AttributeNature.ONE_TO_MANY;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
|
@ -46,13 +55,19 @@ public class CategorizationHelper {
|
|||
return isEntity( classDetails ) || isMappedSuperclass( classDetails );
|
||||
}
|
||||
|
||||
public static AccessType determineAccessType(ClassDetails classDetails, AccessType defaultAccessType) {
|
||||
public static ClassAttributeAccessType determineAccessType(ClassDetails classDetails, AccessType implicitAccessType) {
|
||||
final AnnotationUsage<Access> annotation = classDetails.getAnnotationUsage( JpaAnnotations.ACCESS );
|
||||
if ( annotation != null ) {
|
||||
return annotation.getAttributeValue( "value" );
|
||||
final AccessType explicitValue = annotation.getAttributeValue( "value" );
|
||||
assert explicitValue != null;
|
||||
return explicitValue == AccessType.FIELD
|
||||
? ClassAttributeAccessType.EXPLICIT_FIELD
|
||||
: ClassAttributeAccessType.EXPLICIT_PROPERTY;
|
||||
}
|
||||
|
||||
return defaultAccessType;
|
||||
return implicitAccessType == AccessType.FIELD
|
||||
? ClassAttributeAccessType.IMPLICIT_FIELD
|
||||
: ClassAttributeAccessType.IMPLICIT_PROPERTY;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,7 +75,7 @@ public class CategorizationHelper {
|
|||
* </p>
|
||||
* Also performs some simple validation around multiple natures being indicated
|
||||
*/
|
||||
public static AttributeMetadata.AttributeNature determineAttributeNature(MemberDetails backingMember) {
|
||||
public static AttributeMetadata.AttributeNature determineAttributeNature(ClassDetails declarer, MemberDetails backingMember) {
|
||||
final EnumSet<AttributeMetadata.AttributeNature> natures = EnumSet.noneOf( AttributeMetadata.AttributeNature.class );
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
@ -84,78 +99,114 @@ public class CategorizationHelper {
|
|||
if ( embedded != null
|
||||
|| embeddedId != null
|
||||
|| ( backingMember.getType() != null && backingMember.getType().getAnnotationUsage( JpaAnnotations.EMBEDDABLE ) != null ) ) {
|
||||
natures.add( AttributeMetadata.AttributeNature.EMBEDDED );
|
||||
natures.add( EMBEDDED );
|
||||
}
|
||||
|
||||
if ( any != null ) {
|
||||
natures.add( AttributeMetadata.AttributeNature.ANY );
|
||||
}
|
||||
|
||||
if ( oneToOne != null
|
||||
|| manyToOne != null ) {
|
||||
if ( oneToOne != null || manyToOne != null ) {
|
||||
natures.add( AttributeMetadata.AttributeNature.TO_ONE );
|
||||
}
|
||||
|
||||
if ( elementCollection != null ) {
|
||||
natures.add( ELEMENT_COLLECTION );
|
||||
}
|
||||
|
||||
if ( oneToMany != null ) {
|
||||
natures.add( ONE_TO_MANY );
|
||||
}
|
||||
|
||||
if ( manyToMany != null ) {
|
||||
natures.add( MANY_TO_MANY );
|
||||
}
|
||||
|
||||
if ( manyToAny != null ) {
|
||||
natures.add( MANY_TO_ANY );
|
||||
}
|
||||
|
||||
// look at annotations that imply a nature
|
||||
|
||||
final boolean plural = oneToMany != null
|
||||
|| manyToMany != null
|
||||
|| elementCollection != null
|
||||
|| manyToAny != null;
|
||||
if ( plural ) {
|
||||
natures.add( AttributeMetadata.AttributeNature.PLURAL );
|
||||
}
|
||||
|
||||
// look at annotations that imply a nature
|
||||
// NOTE : these could apply to the element or index of collection, so
|
||||
// only do these if it is not a collection
|
||||
final boolean implicitlyBasic = backingMember.getAnnotationUsage( JpaAnnotations.TEMPORAL ) != null
|
||||
|| backingMember.getAnnotationUsage( JpaAnnotations.LOB ) != null
|
||||
|| backingMember.getAnnotationUsage( JpaAnnotations.ENUMERATED ) != null
|
||||
|| backingMember.getAnnotationUsage( JpaAnnotations.VERSION ) != null
|
||||
|| backingMember.getAnnotationUsage( HibernateAnnotations.GENERATED ) != null
|
||||
|| backingMember.getAnnotationUsage( HibernateAnnotations.NATIONALIZED ) != null
|
||||
|| backingMember.getAnnotationUsage( HibernateAnnotations.TZ_COLUMN ) != null
|
||||
|| backingMember.getAnnotationUsage( HibernateAnnotations.TZ_STORAGE ) != null
|
||||
|| backingMember.getAnnotationUsage( HibernateAnnotations.TYPE ) != null
|
||||
|| backingMember.getAnnotationUsage( HibernateAnnotations.TENANT_ID ) != null
|
||||
|| backingMember.getAnnotationUsage( HibernateAnnotations.JAVA_TYPE ) != null
|
||||
|| backingMember.getAnnotationUsage( HibernateAnnotations.JDBC_TYPE_CODE ) != null
|
||||
|| backingMember.getAnnotationUsage( HibernateAnnotations.JDBC_TYPE ) != null;
|
||||
|
||||
final boolean implicitlyEmbedded = backingMember.getAnnotationUsage( HibernateAnnotations.EMBEDDABLE_INSTANTIATOR ) != null
|
||||
|| backingMember.getAnnotationUsage( HibernateAnnotations.COMPOSITE_TYPE ) != null;
|
||||
|
||||
final boolean implicitlyAny = backingMember.getAnnotationUsage( HibernateAnnotations.ANY_DISCRIMINATOR ) != null
|
||||
|| CollectionHelper.isNotEmpty( backingMember.getRepeatedAnnotationUsages( HibernateAnnotations.ANY_DISCRIMINATOR_VALUE ) )
|
||||
|| backingMember.getAnnotationUsage( HibernateAnnotations.ANY_DISCRIMINATOR_VALUES ) != null
|
||||
|| backingMember.getAnnotationUsage( HibernateAnnotations.ANY_KEY_JAVA_TYPE ) != null
|
||||
|| backingMember.getAnnotationUsage( HibernateAnnotations.ANY_KEY_JAVA_CLASS ) != null
|
||||
|| backingMember.getAnnotationUsage( HibernateAnnotations.ANY_KEY_JDBC_TYPE ) != null
|
||||
|| backingMember.getAnnotationUsage( HibernateAnnotations.ANY_KEY_JDBC_TYPE_CODE ) != null;
|
||||
|
||||
if ( !plural ) {
|
||||
// first implicit basic nature
|
||||
if ( backingMember.getAnnotationUsage( JpaAnnotations.TEMPORAL ) != null
|
||||
|| backingMember.getAnnotationUsage( JpaAnnotations.LOB ) != null
|
||||
|| backingMember.getAnnotationUsage( JpaAnnotations.ENUMERATED ) != null
|
||||
|| backingMember.getAnnotationUsage( JpaAnnotations.CONVERT ) != null
|
||||
|| backingMember.getAnnotationUsage( JpaAnnotations.VERSION ) != null
|
||||
|| backingMember.getAnnotationUsage( HibernateAnnotations.GENERATED ) != null
|
||||
|| backingMember.getAnnotationUsage( HibernateAnnotations.NATIONALIZED ) != null
|
||||
|| backingMember.getAnnotationUsage( HibernateAnnotations.TZ_COLUMN ) != null
|
||||
|| backingMember.getAnnotationUsage( HibernateAnnotations.TZ_STORAGE ) != null
|
||||
|| backingMember.getAnnotationUsage( HibernateAnnotations.TYPE ) != null
|
||||
|| backingMember.getAnnotationUsage( HibernateAnnotations.TENANT_ID ) != null
|
||||
|| backingMember.getAnnotationUsage( HibernateAnnotations.JAVA_TYPE ) != null
|
||||
|| backingMember.getAnnotationUsage( HibernateAnnotations.JDBC_TYPE_CODE ) != null
|
||||
|| backingMember.getAnnotationUsage( HibernateAnnotations.JDBC_TYPE ) != null ) {
|
||||
if ( implicitlyBasic ) {
|
||||
natures.add( AttributeMetadata.AttributeNature.BASIC );
|
||||
}
|
||||
|
||||
// then embedded
|
||||
if ( backingMember.getAnnotationUsage( HibernateAnnotations.EMBEDDABLE_INSTANTIATOR ) != null
|
||||
|| backingMember.getAnnotationUsage( HibernateAnnotations.COMPOSITE_TYPE ) != null ) {
|
||||
natures.add( AttributeMetadata.AttributeNature.EMBEDDED );
|
||||
if ( implicitlyEmbedded ) {
|
||||
natures.add( EMBEDDED );
|
||||
}
|
||||
|
||||
// and any
|
||||
if ( backingMember.getAnnotationUsage( HibernateAnnotations.ANY_DISCRIMINATOR ) != null
|
||||
|| backingMember.getAnnotationUsage( HibernateAnnotations.ANY_DISCRIMINATOR_VALUE ) != null
|
||||
|| backingMember.getAnnotationUsage( HibernateAnnotations.ANY_DISCRIMINATOR_VALUES ) != null
|
||||
|| backingMember.getAnnotationUsage( HibernateAnnotations.ANY_KEY_JAVA_TYPE ) != null
|
||||
|| backingMember.getAnnotationUsage( HibernateAnnotations.ANY_KEY_JAVA_CLASS ) != null
|
||||
|| backingMember.getAnnotationUsage( HibernateAnnotations.ANY_KEY_JDBC_TYPE ) != null
|
||||
|| backingMember.getAnnotationUsage( HibernateAnnotations.ANY_KEY_JDBC_TYPE_CODE ) != null ) {
|
||||
if ( implicitlyAny ) {
|
||||
natures.add( AttributeMetadata.AttributeNature.ANY );
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( elementCollection != null ) {
|
||||
// for @ElementCollection, allow `@Basic` or `@Embedded` (though not both)
|
||||
if ( natures.contains( BASIC ) ) {
|
||||
if ( natures.contains( EMBEDDED ) ) {
|
||||
// don't do anything, this is still an error
|
||||
}
|
||||
else {
|
||||
MODEL_CATEGORIZATION_LOGGER.debugf( "Ignoring @Basic on @ElementCollection - %s", backingMember.resolveAttributeName() );
|
||||
natures.remove( BASIC );
|
||||
}
|
||||
}
|
||||
else if ( natures.contains( EMBEDDED ) ) {
|
||||
MODEL_CATEGORIZATION_LOGGER.debugf( "Ignoring @Embedded on @ElementCollection - %s", backingMember.resolveAttributeName() );
|
||||
natures.remove( EMBEDDED );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int size = natures.size();
|
||||
return switch ( size ) {
|
||||
case 0 -> {
|
||||
ModelCategorizationLogging.MODEL_CATEGORIZATION_LOGGER.debugf(
|
||||
MODEL_CATEGORIZATION_LOGGER.debugf(
|
||||
"Implicitly interpreting attribute `%s` as BASIC",
|
||||
backingMember.resolveAttributeName()
|
||||
);
|
||||
yield AttributeMetadata.AttributeNature.BASIC;
|
||||
}
|
||||
case 1 -> natures.iterator().next();
|
||||
default -> throw new MultipleAttributeNaturesException( backingMember.resolveAttributeName(), natures );
|
||||
default -> throw new MultipleAttributeNaturesException(
|
||||
declarer.getName() + "#" + backingMember.resolveAttributeName(),
|
||||
natures
|
||||
);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,34 +12,44 @@ import java.util.Set;
|
|||
import org.hibernate.boot.models.categorize.spi.CategorizedDomainModel;
|
||||
import org.hibernate.boot.models.categorize.spi.EntityHierarchy;
|
||||
import org.hibernate.boot.models.categorize.spi.GlobalRegistrations;
|
||||
import org.hibernate.boot.models.xml.spi.PersistenceUnitMetadata;
|
||||
import org.hibernate.models.spi.AnnotationDescriptorRegistry;
|
||||
import org.hibernate.models.spi.ClassDetails;
|
||||
import org.hibernate.models.spi.ClassDetailsRegistry;
|
||||
|
||||
import org.jboss.jandex.IndexView;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class CategorizedDomainModelImpl implements CategorizedDomainModel {
|
||||
private final ClassDetailsRegistry classDetailsRegistry;
|
||||
private final AnnotationDescriptorRegistry annotationDescriptorRegistry;
|
||||
private final Set<EntityHierarchy> entityHierarchies;
|
||||
private final Map<String, ClassDetails> mappedSuperclasses;
|
||||
private final Map<String, ClassDetails> embeddables;
|
||||
private final GlobalRegistrations globalRegistrations;
|
||||
|
||||
private final ClassDetailsRegistry classDetailsRegistry;
|
||||
private final AnnotationDescriptorRegistry annotationDescriptorRegistry;
|
||||
private final IndexView jandexIndex;
|
||||
private final PersistenceUnitMetadata persistenceUnitMetadata;
|
||||
|
||||
public CategorizedDomainModelImpl(
|
||||
ClassDetailsRegistry classDetailsRegistry,
|
||||
AnnotationDescriptorRegistry annotationDescriptorRegistry,
|
||||
IndexView jandexIndex,
|
||||
PersistenceUnitMetadata persistenceUnitMetadata,
|
||||
Set<EntityHierarchy> entityHierarchies,
|
||||
Map<String, ClassDetails> mappedSuperclasses,
|
||||
Map<String, ClassDetails> embeddables,
|
||||
GlobalRegistrations globalRegistrations) {
|
||||
this.classDetailsRegistry = classDetailsRegistry;
|
||||
this.annotationDescriptorRegistry = annotationDescriptorRegistry;
|
||||
this.persistenceUnitMetadata = persistenceUnitMetadata;
|
||||
this.entityHierarchies = entityHierarchies;
|
||||
this.mappedSuperclasses = mappedSuperclasses;
|
||||
this.embeddables = embeddables;
|
||||
this.globalRegistrations = globalRegistrations;
|
||||
this.jandexIndex = jandexIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -52,6 +62,21 @@ public class CategorizedDomainModelImpl implements CategorizedDomainModel {
|
|||
return annotationDescriptorRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IndexView getJandexIndex() {
|
||||
return jandexIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PersistenceUnitMetadata getPersistenceUnitMetadata() {
|
||||
return persistenceUnitMetadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GlobalRegistrations getGlobalRegistrations() {
|
||||
return globalRegistrations;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<EntityHierarchy> getEntityHierarchies() {
|
||||
return entityHierarchies;
|
||||
|
@ -65,9 +90,4 @@ public class CategorizedDomainModelImpl implements CategorizedDomainModel {
|
|||
public Map<String, ClassDetails> getEmbeddables() {
|
||||
return embeddables;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GlobalRegistrations getGlobalRegistrations() {
|
||||
return globalRegistrations;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,10 +18,15 @@ import org.hibernate.boot.jaxb.mapping.spi.JaxbPersistenceUnitMetadataImpl;
|
|||
import org.hibernate.boot.models.categorize.spi.CategorizedDomainModel;
|
||||
import org.hibernate.boot.models.categorize.spi.EntityHierarchy;
|
||||
import org.hibernate.boot.models.categorize.spi.ManagedResourcesProcessor;
|
||||
import org.hibernate.boot.models.xml.spi.PersistenceUnitMetadata;
|
||||
import org.hibernate.models.spi.AnnotationDescriptorRegistry;
|
||||
import org.hibernate.models.spi.ClassDetails;
|
||||
import org.hibernate.models.spi.ClassDetailsRegistry;
|
||||
|
||||
import org.jboss.jandex.IndexView;
|
||||
|
||||
import jakarta.persistence.AttributeConverter;
|
||||
import jakarta.persistence.Converter;
|
||||
import jakarta.persistence.Embeddable;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.MappedSuperclass;
|
||||
|
@ -36,19 +41,28 @@ import jakarta.persistence.MappedSuperclass;
|
|||
|
||||
public class DomainModelCategorizationCollector {
|
||||
private final boolean areIdGeneratorsGlobal;
|
||||
private final IndexView jandexIndex;
|
||||
|
||||
private final GlobalRegistrationsImpl globalRegistrations;
|
||||
|
||||
private final Set<ClassDetails> rootEntities = new HashSet<>();
|
||||
private final Map<String,ClassDetails> mappedSuperclasses = new HashMap<>();
|
||||
private final Map<String,ClassDetails> embeddables = new HashMap<>();
|
||||
private final GlobalRegistrationsImpl globalRegistrations;
|
||||
|
||||
public DomainModelCategorizationCollector(
|
||||
boolean areIdGeneratorsGlobal,
|
||||
ClassDetailsRegistry classDetailsRegistry,
|
||||
AnnotationDescriptorRegistry descriptorRegistry) {
|
||||
AnnotationDescriptorRegistry descriptorRegistry,
|
||||
IndexView jandexIndex) {
|
||||
this.areIdGeneratorsGlobal = areIdGeneratorsGlobal;
|
||||
this.jandexIndex = jandexIndex;
|
||||
this.globalRegistrations = new GlobalRegistrationsImpl( classDetailsRegistry, descriptorRegistry );
|
||||
}
|
||||
|
||||
public GlobalRegistrationsImpl getGlobalRegistrations() {
|
||||
return globalRegistrations;
|
||||
}
|
||||
|
||||
public Set<ClassDetails> getRootEntities() {
|
||||
return rootEntities;
|
||||
}
|
||||
|
@ -61,15 +75,11 @@ public class DomainModelCategorizationCollector {
|
|||
return embeddables;
|
||||
}
|
||||
|
||||
public GlobalRegistrationsImpl getGlobalRegistrations() {
|
||||
return globalRegistrations;
|
||||
}
|
||||
|
||||
|
||||
public void apply(JaxbEntityMappingsImpl jaxbRoot) {
|
||||
getGlobalRegistrations().collectJavaTypeRegistrations( jaxbRoot.getJavaTypeRegistrations() );
|
||||
getGlobalRegistrations().collectJdbcTypeRegistrations( jaxbRoot.getJdbcTypeRegistrations() );
|
||||
getGlobalRegistrations().collectConverterRegistrations( jaxbRoot.getConverterRegistrations() );
|
||||
getGlobalRegistrations().collectConverters( jaxbRoot.getConverters() );
|
||||
getGlobalRegistrations().collectUserTypeRegistrations( jaxbRoot.getUserTypeRegistrations() );
|
||||
getGlobalRegistrations().collectCompositeUserTypeRegistrations( jaxbRoot.getCompositeUserTypeRegistrations() );
|
||||
getGlobalRegistrations().collectCollectionTypeRegistrations( jaxbRoot.getCollectionUserTypeRegistrations() );
|
||||
|
@ -79,9 +89,11 @@ public class DomainModelCategorizationCollector {
|
|||
final JaxbPersistenceUnitMetadataImpl persistenceUnitMetadata = jaxbRoot.getPersistenceUnitMetadata();
|
||||
if ( persistenceUnitMetadata != null ) {
|
||||
final JaxbPersistenceUnitDefaultsImpl persistenceUnitDefaults = persistenceUnitMetadata.getPersistenceUnitDefaults();
|
||||
final JaxbEntityListenerContainerImpl listenerContainer = persistenceUnitDefaults.getEntityListenerContainer();
|
||||
if ( listenerContainer != null ) {
|
||||
getGlobalRegistrations().collectEntityListenerRegistrations( listenerContainer.getEntityListeners() );
|
||||
if ( persistenceUnitDefaults != null ) {
|
||||
final JaxbEntityListenerContainerImpl listenerContainer = persistenceUnitDefaults.getEntityListenerContainer();
|
||||
if ( listenerContainer != null ) {
|
||||
getGlobalRegistrations().collectEntityListenerRegistrations( listenerContainer.getEntityListeners() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,6 +117,8 @@ public class DomainModelCategorizationCollector {
|
|||
getGlobalRegistrations().collectIdGenerators( classDetails );
|
||||
}
|
||||
|
||||
getGlobalRegistrations().collectImportRename( classDetails );
|
||||
|
||||
// todo : named queries
|
||||
// todo : named graphs
|
||||
|
||||
|
@ -124,7 +138,10 @@ public class DomainModelCategorizationCollector {
|
|||
}
|
||||
}
|
||||
|
||||
// todo : converters? - @Converter / AttributeConverter, as opposed to @ConverterRegistration which is already collected
|
||||
if ( ( classDetails.getClassName() != null && classDetails.isImplementor( AttributeConverter.class ) )
|
||||
|| classDetails.getAnnotationUsage( Converter.class ) != null ) {
|
||||
globalRegistrations.collectConverter( classDetails );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -138,11 +155,14 @@ public class DomainModelCategorizationCollector {
|
|||
*/
|
||||
public CategorizedDomainModel createResult(
|
||||
Set<EntityHierarchy> entityHierarchies,
|
||||
PersistenceUnitMetadata persistenceUnitMetadata,
|
||||
ClassDetailsRegistry classDetailsRegistry,
|
||||
AnnotationDescriptorRegistry annotationDescriptorRegistry) {
|
||||
return new CategorizedDomainModelImpl(
|
||||
classDetailsRegistry,
|
||||
annotationDescriptorRegistry,
|
||||
jandexIndex,
|
||||
persistenceUnitMetadata,
|
||||
entityHierarchies,
|
||||
mappedSuperclasses,
|
||||
embeddables,
|
||||
|
|
|
@ -97,15 +97,46 @@ public class EntityHierarchyBuilder {
|
|||
private AccessType determineDefaultAccessTypeForHierarchy(ClassDetails rootEntityType) {
|
||||
assert rootEntityType != null;
|
||||
|
||||
// // look for `@Access` at class level
|
||||
// final AccessType classAnnotationValue = resolveDefaultAccessTypeFromClassAnnotation( rootEntityType );
|
||||
// if ( classAnnotationValue != null ) {
|
||||
// return classAnnotationValue;
|
||||
// }
|
||||
|
||||
// look for `@Id` or `@EmbeddedId`
|
||||
// todo (jpa32) : technically we could probably look for member with any "mapping" annotation
|
||||
final AccessType accessFromAttribute = resolveDefaultAccessTypeFromMembers( rootEntityType );
|
||||
if ( accessFromAttribute != null ) {
|
||||
return accessFromAttribute;
|
||||
}
|
||||
|
||||
|
||||
// // 2.3.1 Default Access Type
|
||||
// // It is an error if a default access type cannot be determined and an access type is not explicitly specified
|
||||
// // by means of annotations or the XML descriptor.
|
||||
// throw new AccessTypeDeterminationException( rootEntityType );
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private AccessType resolveDefaultAccessTypeFromClassAnnotation(ClassDetails rootEntityType) {
|
||||
ClassDetails current = rootEntityType;
|
||||
while ( current != null ) {
|
||||
// look for `@Access` on the class
|
||||
final AnnotationUsage<Access> accessAnnotation = current.getAnnotationUsage( JpaAnnotations.ACCESS );
|
||||
if ( accessAnnotation != null ) {
|
||||
return accessAnnotation.getAttributeValue( "value" );
|
||||
}
|
||||
|
||||
// look for `@Id` or `@EmbeddedId`
|
||||
current = current.getSuperType();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private AccessType resolveDefaultAccessTypeFromMembers(ClassDetails rootEntityType) {
|
||||
ClassDetails current = rootEntityType;
|
||||
while ( current != null ) {
|
||||
// look for `@Id` or `@EmbeddedId` (w/o `@Access`)
|
||||
final AnnotationTarget idMember = determineIdMember( current );
|
||||
if ( idMember != null ) {
|
||||
switch ( idMember.getKind() ) {
|
||||
|
@ -124,11 +155,7 @@ public class EntityHierarchyBuilder {
|
|||
current = current.getSuperType();
|
||||
}
|
||||
|
||||
// 2.3.1 Default Access Type
|
||||
// It is an error if a default access type cannot be determined and an access type is not explicitly specified
|
||||
// by means of annotations or the XML descriptor.
|
||||
|
||||
throw new AccessTypeDeterminationException( rootEntityType );
|
||||
return null;
|
||||
}
|
||||
|
||||
private AnnotationTarget determineIdMember(ClassDetails current) {
|
||||
|
@ -137,7 +164,9 @@ public class EntityHierarchyBuilder {
|
|||
final MethodDetails methodDetails = methods.get( i );
|
||||
if ( methodDetails.getAnnotationUsage( JpaAnnotations.ID ) != null
|
||||
|| methodDetails.getAnnotationUsage( JpaAnnotations.EMBEDDED_ID ) != null ) {
|
||||
return methodDetails;
|
||||
if ( methodDetails.getAnnotationUsage( Access.class ) == null ) {
|
||||
return methodDetails;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -146,7 +175,9 @@ public class EntityHierarchyBuilder {
|
|||
final FieldDetails fieldDetails = fields.get( i );
|
||||
if ( fieldDetails.getAnnotationUsage( JpaAnnotations.ID ) != null
|
||||
|| fieldDetails.getAnnotationUsage( JpaAnnotations.EMBEDDED_ID ) != null ) {
|
||||
return fieldDetails;
|
||||
if ( fieldDetails.getAnnotationUsage( Access.class ) == null ) {
|
||||
return fieldDetails;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -183,8 +214,8 @@ public class EntityHierarchyBuilder {
|
|||
|
||||
ClassDetails current = classInfo.getSuperType();
|
||||
while ( current != null ) {
|
||||
if ( current.getAnnotationUsage( JpaAnnotations.ENTITY ) != null ) {
|
||||
// a super type has `@Entity`, cannot be root
|
||||
if ( current.getAnnotationUsage( JpaAnnotations.ENTITY ) != null && !current.isAbstract() ) {
|
||||
// a non-abstract super type has `@Entity` -> classInfo cannot be a root entity
|
||||
return false;
|
||||
}
|
||||
current = current.getSuperType();
|
||||
|
|
|
@ -38,6 +38,7 @@ public class EntityHierarchyImpl implements EntityHierarchy {
|
|||
private final EntityTypeMetadata rootEntityTypeMetadata;
|
||||
|
||||
private final InheritanceType inheritanceType;
|
||||
private final jakarta.persistence.AccessType defaultAccessType;
|
||||
private final OptimisticLockStyle optimisticLockStyle;
|
||||
|
||||
private final KeyMapping idMapping;
|
||||
|
@ -54,32 +55,39 @@ public class EntityHierarchyImpl implements EntityHierarchy {
|
|||
AccessType defaultCacheAccessType,
|
||||
HierarchyTypeConsumer typeConsumer,
|
||||
ModelCategorizationContext modelBuildingContext) {
|
||||
this.defaultAccessType = defaultAccessType;
|
||||
|
||||
final ClassDetails absoluteRootClassDetails = findRootRoot( rootEntityClassDetails );
|
||||
final HierarchyMetadataCollector metadataCollector = new HierarchyMetadataCollector( this, rootEntityClassDetails, typeConsumer );
|
||||
|
||||
if ( CategorizationHelper.isEntity( absoluteRootClassDetails ) ) {
|
||||
this.absoluteRootTypeMetadata = new EntityTypeMetadataImpl(
|
||||
this.rootEntityTypeMetadata = new EntityTypeMetadataImpl(
|
||||
absoluteRootClassDetails,
|
||||
this,
|
||||
defaultAccessType,
|
||||
metadataCollector,
|
||||
modelBuildingContext
|
||||
);
|
||||
this.absoluteRootTypeMetadata = rootEntityTypeMetadata;
|
||||
}
|
||||
else {
|
||||
assert CategorizationHelper.isMappedSuperclass( absoluteRootClassDetails );
|
||||
this.absoluteRootTypeMetadata = new MappedSuperclassTypeMetadataImpl(
|
||||
this.absoluteRootTypeMetadata = processRootMappedSuperclasses(
|
||||
absoluteRootClassDetails,
|
||||
this,
|
||||
defaultAccessType,
|
||||
metadataCollector,
|
||||
modelBuildingContext
|
||||
);
|
||||
this.rootEntityTypeMetadata = new EntityTypeMetadataImpl(
|
||||
rootEntityClassDetails,
|
||||
this,
|
||||
(AbstractIdentifiableTypeMetadata) absoluteRootTypeMetadata,
|
||||
metadataCollector,
|
||||
modelBuildingContext
|
||||
);
|
||||
}
|
||||
|
||||
this.rootEntityTypeMetadata = metadataCollector.getRootEntityMetadata();
|
||||
assert rootEntityTypeMetadata != null;
|
||||
|
||||
this.inheritanceType = determineInheritanceType( metadataCollector );
|
||||
this.optimisticLockStyle = determineOptimisticLockStyle( metadataCollector );
|
||||
|
||||
|
@ -92,6 +100,22 @@ public class EntityHierarchyImpl implements EntityHierarchy {
|
|||
this.naturalIdCacheRegion = determineNaturalIdCacheRegion( metadataCollector, cacheRegion );
|
||||
}
|
||||
|
||||
private static IdentifiableTypeMetadata processRootMappedSuperclasses(
|
||||
ClassDetails absoluteRootClassDetails,
|
||||
EntityHierarchyImpl entityHierarchy,
|
||||
jakarta.persistence.AccessType defaultAccessType,
|
||||
HierarchyMetadataCollector metadataCollector,
|
||||
ModelCategorizationContext modelBuildingContext) {
|
||||
return new MappedSuperclassTypeMetadataImpl(
|
||||
absoluteRootClassDetails,
|
||||
entityHierarchy,
|
||||
null,
|
||||
defaultAccessType,
|
||||
metadataCollector,
|
||||
modelBuildingContext
|
||||
);
|
||||
}
|
||||
|
||||
private ClassDetails findRootRoot(ClassDetails rootEntityClassDetails) {
|
||||
if ( rootEntityClassDetails.getSuperType() != null ) {
|
||||
final ClassDetails match = walkSupers( rootEntityClassDetails.getSuperType() );
|
||||
|
@ -134,6 +158,11 @@ public class EntityHierarchyImpl implements EntityHierarchy {
|
|||
return inheritanceType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public jakarta.persistence.AccessType getDefaultAccessType() {
|
||||
return defaultAccessType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyMapping getIdMapping() {
|
||||
return idMapping;
|
||||
|
|
|
@ -6,7 +6,11 @@
|
|||
*/
|
||||
package org.hibernate.boot.models.categorize.internal;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.annotations.BatchSize;
|
||||
import org.hibernate.annotations.DynamicInsert;
|
||||
|
@ -28,6 +32,7 @@ import org.hibernate.boot.models.categorize.spi.EntityTypeMetadata;
|
|||
import org.hibernate.boot.models.categorize.spi.JpaEventListener;
|
||||
import org.hibernate.boot.models.categorize.spi.ModelCategorizationContext;
|
||||
import org.hibernate.engine.spi.ExecuteUpdateResultCheckStyle;
|
||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||
import org.hibernate.models.spi.AnnotationUsage;
|
||||
import org.hibernate.models.spi.ClassDetails;
|
||||
|
||||
|
@ -60,21 +65,24 @@ public class EntityTypeMetadataImpl
|
|||
private final boolean isSelectBeforeUpdate;
|
||||
private final boolean isDynamicInsert;
|
||||
private final boolean isDynamicUpdate;
|
||||
private final CustomSql customInsert;
|
||||
private final CustomSql customUpdate;
|
||||
private final CustomSql customDelete;
|
||||
private final Map<String,CustomSql> customInsertMap;
|
||||
private final Map<String,CustomSql> customUpdateMap;
|
||||
private final Map<String,CustomSql> customDeleteMap;
|
||||
private final String[] synchronizedTableNames;
|
||||
|
||||
private List<JpaEventListener> hierarchyEventListeners;
|
||||
private List<JpaEventListener> completeEventListeners;
|
||||
|
||||
/**
|
||||
* Form used when the entity is the absolute-root (no mapped-super) of the hierarchy
|
||||
*/
|
||||
public EntityTypeMetadataImpl(
|
||||
ClassDetails classDetails,
|
||||
EntityHierarchy hierarchy,
|
||||
AccessType defaultAccessType,
|
||||
HierarchyTypeConsumer typeConsumer,
|
||||
ModelCategorizationContext modelContext) {
|
||||
super( classDetails, hierarchy, defaultAccessType, modelContext );
|
||||
super( classDetails, hierarchy, null, defaultAccessType, modelContext );
|
||||
|
||||
// NOTE: There is no annotation for `entity-name` - it comes exclusively from XML
|
||||
// mappings. By default, the `entityName` is simply the entity class name.
|
||||
|
@ -96,9 +104,9 @@ public class EntityTypeMetadataImpl
|
|||
this.isSelectBeforeUpdate = decodeSelectBeforeUpdate();
|
||||
this.isDynamicInsert = decodeDynamicInsert();
|
||||
this.isDynamicUpdate = decodeDynamicUpdate();
|
||||
this.customInsert = extractCustomSql( classDetails.getAnnotationUsage( SQLInsert.class ) );
|
||||
this.customUpdate = extractCustomSql( classDetails.getAnnotationUsage( SQLUpdate.class ) );
|
||||
this.customDelete = extractCustomSql( classDetails.getAnnotationUsage( SQLDelete.class ) );
|
||||
this.customInsertMap = extractCustomSql( classDetails, SQLInsert.class );
|
||||
this.customUpdateMap = extractCustomSql( classDetails, SQLUpdate.class );
|
||||
this.customDeleteMap = extractCustomSql( classDetails, SQLDelete.class );
|
||||
|
||||
//noinspection deprecation
|
||||
final AnnotationUsage<Proxy> proxyAnnotation = classDetails.getAnnotationUsage( Proxy.class );
|
||||
|
@ -133,9 +141,12 @@ public class EntityTypeMetadataImpl
|
|||
this.discriminatorMatchValue = null;
|
||||
}
|
||||
|
||||
postInstantiate( typeConsumer );
|
||||
postInstantiate( true, typeConsumer );
|
||||
}
|
||||
|
||||
/**
|
||||
* Form used when the entity is NOT the absolute-root of the hierarchy
|
||||
*/
|
||||
public EntityTypeMetadataImpl(
|
||||
ClassDetails classDetails,
|
||||
EntityHierarchy hierarchy,
|
||||
|
@ -164,9 +175,9 @@ public class EntityTypeMetadataImpl
|
|||
this.isSelectBeforeUpdate = decodeSelectBeforeUpdate();
|
||||
this.isDynamicInsert = decodeDynamicInsert();
|
||||
this.isDynamicUpdate = decodeDynamicUpdate();
|
||||
this.customInsert = extractCustomSql( classDetails.getAnnotationUsage( SQLInsert.class ) );
|
||||
this.customUpdate = extractCustomSql( classDetails.getAnnotationUsage( SQLUpdate.class ) );
|
||||
this.customDelete = extractCustomSql( classDetails.getAnnotationUsage( SQLDelete.class ) );
|
||||
this.customInsertMap = extractCustomSql( classDetails, SQLInsert.class );
|
||||
this.customUpdateMap = extractCustomSql( classDetails, SQLUpdate.class );
|
||||
this.customDeleteMap = extractCustomSql( classDetails, SQLDelete.class );
|
||||
|
||||
//noinspection deprecation
|
||||
final AnnotationUsage<Proxy> proxyAnnotation = classDetails.getAnnotationUsage( Proxy.class );
|
||||
|
@ -201,7 +212,7 @@ public class EntityTypeMetadataImpl
|
|||
this.discriminatorMatchValue = null;
|
||||
}
|
||||
|
||||
postInstantiate( typeConsumer );
|
||||
postInstantiate( true, typeConsumer );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -260,18 +271,18 @@ public class EntityTypeMetadataImpl
|
|||
}
|
||||
|
||||
@Override
|
||||
public CustomSql getCustomInsert() {
|
||||
return customInsert;
|
||||
public Map<String, CustomSql> getCustomInserts() {
|
||||
return customInsertMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomSql getCustomUpdate() {
|
||||
return customUpdate;
|
||||
public Map<String, CustomSql> getCustomUpdates() {
|
||||
return customUpdateMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomSql getCustomDelete() {
|
||||
return customDelete;
|
||||
public Map<String, CustomSql> getCustomDeletes() {
|
||||
return customDeleteMap;
|
||||
}
|
||||
|
||||
public String getDiscriminatorMatchValue() {
|
||||
|
@ -355,26 +366,34 @@ public class EntityTypeMetadataImpl
|
|||
* {@link SQLUpdate}, {@link SQLDelete}
|
||||
* or {@link org.hibernate.annotations.SQLDeleteAll} annotations
|
||||
*/
|
||||
public static CustomSql extractCustomSql(AnnotationUsage<?> customSqlAnnotation) {
|
||||
if ( customSqlAnnotation == null ) {
|
||||
return null;
|
||||
public static <A extends Annotation> Map<String,CustomSql> extractCustomSql(ClassDetails classDetails, Class<A> annotationType) {
|
||||
final List<AnnotationUsage<A>> annotationUsages = classDetails.getRepeatedAnnotationUsages( annotationType );
|
||||
if ( CollectionHelper.isEmpty( annotationUsages ) ) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
final String sql = customSqlAnnotation.getAttributeValue( "sql" );
|
||||
final boolean isCallable = customSqlAnnotation.getAttributeValue( "callable" );
|
||||
final Map<String, CustomSql> result = new HashMap<>();
|
||||
annotationUsages.forEach( (customSqlAnnotation) -> {
|
||||
final String sql = customSqlAnnotation.getAttributeValue( "sql" );
|
||||
final boolean isCallable = customSqlAnnotation.getAttributeValue( "callable" );
|
||||
|
||||
final ResultCheckStyle checkValue = customSqlAnnotation.getAttributeValue( "check" );
|
||||
final ExecuteUpdateResultCheckStyle checkStyle;
|
||||
if ( checkValue == null ) {
|
||||
checkStyle = isCallable
|
||||
? ExecuteUpdateResultCheckStyle.NONE
|
||||
: ExecuteUpdateResultCheckStyle.COUNT;
|
||||
}
|
||||
else {
|
||||
checkStyle = ExecuteUpdateResultCheckStyle.fromResultCheckStyle( checkValue );
|
||||
}
|
||||
final ResultCheckStyle checkValue = customSqlAnnotation.getAttributeValue( "check" );
|
||||
final ExecuteUpdateResultCheckStyle checkStyle;
|
||||
if ( checkValue == null ) {
|
||||
checkStyle = isCallable
|
||||
? ExecuteUpdateResultCheckStyle.NONE
|
||||
: ExecuteUpdateResultCheckStyle.COUNT;
|
||||
}
|
||||
else {
|
||||
checkStyle = ExecuteUpdateResultCheckStyle.fromResultCheckStyle( checkValue );
|
||||
}
|
||||
|
||||
return new CustomSql( sql, isCallable, checkStyle );
|
||||
result.put(
|
||||
customSqlAnnotation.getString( "table" ),
|
||||
new CustomSql( sql, isCallable, checkStyle )
|
||||
);
|
||||
} );
|
||||
return result;
|
||||
}
|
||||
|
||||
private String[] determineSynchronizedTableNames() {
|
||||
|
|
|
@ -10,17 +10,20 @@ import java.lang.annotation.Annotation;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hibernate.AnnotationException;
|
||||
import org.hibernate.annotations.FilterDef;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.Imported;
|
||||
import org.hibernate.annotations.ParamDef;
|
||||
import org.hibernate.annotations.Parameter;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbCollectionUserTypeRegistrationImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbCompositeUserTypeRegistrationImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbConfigurationParameterImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbConverterImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbConverterRegistrationImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEmbeddableInstantiatorRegistrationImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityListenerImpl;
|
||||
|
@ -35,6 +38,7 @@ import org.hibernate.boot.jaxb.mapping.spi.JaxbUserTypeRegistrationImpl;
|
|||
import org.hibernate.boot.models.categorize.spi.CollectionTypeRegistration;
|
||||
import org.hibernate.boot.models.categorize.spi.CompositeUserTypeRegistration;
|
||||
import org.hibernate.boot.models.categorize.spi.ConversionRegistration;
|
||||
import org.hibernate.boot.models.categorize.spi.ConverterRegistration;
|
||||
import org.hibernate.boot.models.categorize.spi.EmbeddableInstantiatorRegistration;
|
||||
import org.hibernate.boot.models.categorize.spi.FilterDefRegistration;
|
||||
import org.hibernate.boot.models.categorize.spi.GenericGeneratorRegistration;
|
||||
|
@ -46,7 +50,7 @@ import org.hibernate.boot.models.categorize.spi.JpaEventListenerStyle;
|
|||
import org.hibernate.boot.models.categorize.spi.SequenceGeneratorRegistration;
|
||||
import org.hibernate.boot.models.categorize.spi.TableGeneratorRegistration;
|
||||
import org.hibernate.boot.models.categorize.spi.UserTypeRegistration;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.XmlAnnotationHelper;
|
||||
import org.hibernate.boot.models.xml.internal.XmlAnnotationHelper;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||
import org.hibernate.metamodel.CollectionClassification;
|
||||
|
@ -65,6 +69,7 @@ import jakarta.persistence.TableGenerator;
|
|||
|
||||
import static java.util.Collections.emptyList;
|
||||
import static java.util.Collections.emptyMap;
|
||||
import static java.util.Collections.emptySet;
|
||||
import static org.hibernate.boot.models.HibernateAnnotations.COLLECTION_TYPE_REG;
|
||||
import static org.hibernate.boot.models.HibernateAnnotations.COMPOSITE_TYPE_REG;
|
||||
import static org.hibernate.boot.models.HibernateAnnotations.CONVERTER_REG;
|
||||
|
@ -91,11 +96,14 @@ public class GlobalRegistrationsImpl implements GlobalRegistrations {
|
|||
private List<CollectionTypeRegistration> collectionTypeRegistrations;
|
||||
private List<EmbeddableInstantiatorRegistration> embeddableInstantiatorRegistrations;
|
||||
private Map<String, FilterDefRegistration> filterDefRegistrations;
|
||||
private Map<String,String> importedRenameMap;
|
||||
|
||||
private Map<String, SequenceGeneratorRegistration> sequenceGeneratorRegistrations;
|
||||
private Map<String, TableGeneratorRegistration> tableGeneratorRegistrations;
|
||||
private Map<String, GenericGeneratorRegistration> genericGeneratorRegistrations;
|
||||
|
||||
private Set<ConverterRegistration> jpaConverters;
|
||||
|
||||
public GlobalRegistrationsImpl(SourceModelContext sourceModelContext) {
|
||||
this( sourceModelContext.getClassDetailsRegistry(), sourceModelContext.getAnnotationDescriptorRegistry() );
|
||||
}
|
||||
|
@ -150,6 +158,11 @@ public class GlobalRegistrationsImpl implements GlobalRegistrations {
|
|||
return filterDefRegistrations == null ? emptyMap() : filterDefRegistrations;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getImportedRenames() {
|
||||
return importedRenameMap == null ? emptyMap() : importedRenameMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, SequenceGeneratorRegistration> getSequenceGeneratorRegistrations() {
|
||||
return sequenceGeneratorRegistrations == null ? emptyMap() : sequenceGeneratorRegistrations;
|
||||
|
@ -165,6 +178,12 @@ public class GlobalRegistrationsImpl implements GlobalRegistrations {
|
|||
return genericGeneratorRegistrations == null ? emptyMap() : genericGeneratorRegistrations;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<ConverterRegistration> getJpaConverters() {
|
||||
return jpaConverters == null ? emptySet() : jpaConverters;
|
||||
}
|
||||
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// JavaTypeRegistration
|
||||
|
||||
|
@ -472,11 +491,40 @@ public class GlobalRegistrationsImpl implements GlobalRegistrations {
|
|||
filterDefRegistrations = new HashMap<>();
|
||||
}
|
||||
|
||||
if ( filterDefRegistrations.put( name, new FilterDefRegistration( name, defaultCondition, parameters ) ) != null ) {
|
||||
throw new AnnotationException( "Multiple '@FilterDef' annotations define a filter named '" + name + "'" );
|
||||
final FilterDefRegistration previousEntry = filterDefRegistrations.put(
|
||||
name,
|
||||
new FilterDefRegistration( name, defaultCondition, parameters )
|
||||
);
|
||||
if ( previousEntry != null ) {
|
||||
// legacy code simply allows the collision overwriting the previous
|
||||
// todo (jpa32) : re-enable this, especially if the conditions differ
|
||||
//throw new AnnotationException( "Multiple '@FilterDef' annotations define a filter named '" + name + "'" );
|
||||
}
|
||||
}
|
||||
|
||||
public void collectImportRename(ClassDetails classDetails) {
|
||||
final AnnotationUsage<Imported> importedUsage = classDetails.getAnnotationUsage( Imported.class );
|
||||
|
||||
if ( importedUsage == null ) {
|
||||
return;
|
||||
}
|
||||
|
||||
final String explicitRename = importedUsage.getString( "rename" );
|
||||
final String rename = StringHelper.isNotEmpty( explicitRename )
|
||||
? explicitRename
|
||||
: StringHelper.unqualify( classDetails.getName() );
|
||||
|
||||
collectImportRename( rename, classDetails.getName() );
|
||||
}
|
||||
|
||||
public void collectImportRename(String rename, String name) {
|
||||
if ( importedRenameMap == null ) {
|
||||
importedRenameMap = new HashMap<>();
|
||||
}
|
||||
|
||||
importedRenameMap.put( rename, name );
|
||||
}
|
||||
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// EntityListenerRegistration
|
||||
|
@ -630,4 +678,35 @@ public class GlobalRegistrationsImpl implements GlobalRegistrations {
|
|||
|
||||
genericGeneratorRegistrations.put( generatorRegistration.getName(), generatorRegistration );
|
||||
}
|
||||
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Converters
|
||||
|
||||
public void collectConverter(ClassDetails converterClassDetails) {
|
||||
if ( jpaConverters == null ) {
|
||||
jpaConverters = new HashSet<>();
|
||||
}
|
||||
|
||||
jpaConverters.add( new ConverterRegistration( converterClassDetails, null ) );
|
||||
}
|
||||
|
||||
public void collectConverters(List<JaxbConverterImpl> converters) {
|
||||
if ( CollectionHelper.isEmpty( converters ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( jpaConverters == null ) {
|
||||
jpaConverters = CollectionHelper.setOfSize( converters.size() );
|
||||
}
|
||||
|
||||
converters.forEach( (jaxbConverter) -> {
|
||||
final String converterClassName = jaxbConverter.getClazz();
|
||||
assert converterClassName != null;
|
||||
final ClassDetails converterType = classDetailsRegistry.resolveClassDetails( converterClassName );
|
||||
final boolean autoApply = jaxbConverter.isAutoApply();
|
||||
|
||||
jpaConverters.add( new ConverterRegistration( converterType, autoApply ) );
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.hibernate.AnnotationException;
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.NaturalId;
|
||||
import org.hibernate.annotations.NaturalIdCache;
|
||||
|
@ -109,6 +110,10 @@ public class HierarchyMetadataCollector implements HierarchyTypeConsumer {
|
|||
}
|
||||
|
||||
private KeyMapping buildIdMapping() {
|
||||
if ( collectedIdAttributes == null ) {
|
||||
throw new AnnotationException( "Unable to determine id attribute(s) - " + rootEntityClassDetails.getName() );
|
||||
}
|
||||
|
||||
if ( collectedIdAttributes instanceof List ) {
|
||||
//noinspection unchecked
|
||||
final List<AttributeMetadata> idAttributes = (List<AttributeMetadata>) collectedIdAttributes;
|
||||
|
@ -132,6 +137,18 @@ public class HierarchyMetadataCollector implements HierarchyTypeConsumer {
|
|||
return new AggregatedKeyMappingImpl( idAttribute );
|
||||
}
|
||||
|
||||
if ( idAttribute.getNature() == AttributeMetadata.AttributeNature.TO_ONE ) {
|
||||
final List<AttributeMetadata> idAttributes = List.of( idAttribute );
|
||||
final ClassDetails idClassDetails;
|
||||
if ( idClassAnnotation == null ) {
|
||||
idClassDetails = null;
|
||||
}
|
||||
else {
|
||||
idClassDetails = idClassAnnotation.getAttributeValue( "value" );
|
||||
}
|
||||
return new NonAggregatedKeyMappingImpl( idAttributes, idClassDetails );
|
||||
}
|
||||
|
||||
throw new ModelsException(
|
||||
String.format(
|
||||
Locale.ROOT,
|
||||
|
@ -163,6 +180,10 @@ public class HierarchyMetadataCollector implements HierarchyTypeConsumer {
|
|||
return new AggregatedKeyMappingImpl( attribute );
|
||||
}
|
||||
|
||||
if ( attribute.getNature() == AttributeMetadata.AttributeNature.TO_ONE ) {
|
||||
return new BasicKeyMappingImpl( attribute );
|
||||
}
|
||||
|
||||
throw new ModelsException(
|
||||
String.format(
|
||||
Locale.ROOT,
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright: Red Hat Inc. and Hibernate Authors
|
||||
*/
|
||||
package org.hibernate.boot.models.categorize.internal;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class HierarchyTypeHandling {
|
||||
|
||||
}
|
|
@ -28,22 +28,35 @@ public class MappedSuperclassTypeMetadataImpl
|
|||
private final List<JpaEventListener> hierarchyEventListeners;
|
||||
private final List<JpaEventListener> completeEventListeners;
|
||||
|
||||
/**
|
||||
* Form used when the mapped-superclass is the absolute-root of the hierarchy ("above" the root entity)
|
||||
*/
|
||||
public MappedSuperclassTypeMetadataImpl(
|
||||
ClassDetails classDetails,
|
||||
EntityHierarchy hierarchy,
|
||||
MappedSuperclassTypeMetadataImpl superTypeMetadata,
|
||||
AccessType defaultAccessType,
|
||||
HierarchyTypeConsumer typeConsumer,
|
||||
ModelCategorizationContext modelContext) {
|
||||
super( classDetails, hierarchy, defaultAccessType, modelContext );
|
||||
super( classDetails, hierarchy, superTypeMetadata, defaultAccessType, modelContext );
|
||||
|
||||
final LifecycleCallbackCollector lifecycleCallbackCollector = new LifecycleCallbackCollector( classDetails, modelContext );
|
||||
this.attributeList = resolveAttributes( lifecycleCallbackCollector );
|
||||
this.hierarchyEventListeners = collectHierarchyEventListeners( lifecycleCallbackCollector.resolve() );
|
||||
this.completeEventListeners = collectCompleteEventListeners( modelContext );
|
||||
|
||||
postInstantiate( typeConsumer );
|
||||
if ( superTypeMetadata != null ) {
|
||||
superTypeMetadata.addSubclass( this );
|
||||
}
|
||||
|
||||
postInstantiate( false, typeConsumer );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Form used when the mapped-superclass is NOT the absolute-root of the hierarchy
|
||||
*/
|
||||
public MappedSuperclassTypeMetadataImpl(
|
||||
ClassDetails classDetails,
|
||||
EntityHierarchy hierarchy,
|
||||
|
@ -57,7 +70,7 @@ public class MappedSuperclassTypeMetadataImpl
|
|||
this.hierarchyEventListeners = collectHierarchyEventListeners( lifecycleCallbackCollector.resolve() );
|
||||
this.completeEventListeners = collectCompleteEventListeners( modelContext );
|
||||
|
||||
postInstantiate( typeConsumer );
|
||||
postInstantiate( true, typeConsumer );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -9,20 +9,56 @@ package org.hibernate.boot.models.categorize.internal;
|
|||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.hibernate.annotations.Any;
|
||||
import org.hibernate.annotations.AnyDiscriminator;
|
||||
import org.hibernate.annotations.AnyDiscriminatorValue;
|
||||
import org.hibernate.annotations.AnyDiscriminatorValues;
|
||||
import org.hibernate.annotations.AnyKeyJavaClass;
|
||||
import org.hibernate.annotations.AnyKeyJavaType;
|
||||
import org.hibernate.annotations.AnyKeyJdbcType;
|
||||
import org.hibernate.annotations.AnyKeyJdbcTypeCode;
|
||||
import org.hibernate.annotations.JavaType;
|
||||
import org.hibernate.annotations.JdbcType;
|
||||
import org.hibernate.annotations.JdbcTypeCode;
|
||||
import org.hibernate.annotations.ManyToAny;
|
||||
import org.hibernate.annotations.Nationalized;
|
||||
import org.hibernate.annotations.TenantId;
|
||||
import org.hibernate.annotations.TimeZoneColumn;
|
||||
import org.hibernate.annotations.TimeZoneStorage;
|
||||
import org.hibernate.annotations.Type;
|
||||
import org.hibernate.boot.internal.AnyKeyType;
|
||||
import org.hibernate.boot.models.AccessTypePlacementException;
|
||||
import org.hibernate.boot.models.AnnotationPlacementException;
|
||||
import org.hibernate.boot.models.JpaAnnotations;
|
||||
import org.hibernate.boot.models.categorize.spi.ModelCategorizationContext;
|
||||
import org.hibernate.boot.models.categorize.spi.ClassAttributeAccessType;
|
||||
import org.hibernate.models.spi.AnnotationTarget;
|
||||
import org.hibernate.models.spi.AnnotationUsage;
|
||||
import org.hibernate.models.spi.ClassDetails;
|
||||
import org.hibernate.models.spi.FieldDetails;
|
||||
import org.hibernate.models.spi.MemberDetails;
|
||||
import org.hibernate.models.spi.MethodDetails;
|
||||
|
||||
import jakarta.annotation.Generated;
|
||||
import jakarta.persistence.Access;
|
||||
import jakarta.persistence.AccessType;
|
||||
import jakarta.persistence.Basic;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.ElementCollection;
|
||||
import jakarta.persistence.Embedded;
|
||||
import jakarta.persistence.EmbeddedId;
|
||||
import jakarta.persistence.Enumerated;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Lob;
|
||||
import jakarta.persistence.ManyToMany;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.OneToOne;
|
||||
import jakarta.persistence.Temporal;
|
||||
import jakarta.persistence.Version;
|
||||
|
||||
/**
|
||||
* Standard implementation of the PersistentAttributeMemberResolver contract
|
||||
|
@ -41,16 +77,15 @@ public class StandardPersistentAttributeMemberResolver extends AbstractPersisten
|
|||
Function<FieldDetails,Boolean> transientFieldChecker,
|
||||
Function<MethodDetails,Boolean> transientMethodChecker,
|
||||
ClassDetails classDetails,
|
||||
AccessType classLevelAccessType) {
|
||||
assert classLevelAccessType != null;
|
||||
|
||||
ClassAttributeAccessType classLevelAccessType) {
|
||||
final LinkedHashMap<String,MemberDetails> results = new LinkedHashMap<>();
|
||||
|
||||
processAttributeLevelAccess(
|
||||
results::put,
|
||||
transientFieldChecker,
|
||||
transientMethodChecker,
|
||||
classDetails
|
||||
classDetails,
|
||||
classLevelAccessType
|
||||
);
|
||||
|
||||
processClassLevelAccess(
|
||||
|
@ -69,17 +104,18 @@ public class StandardPersistentAttributeMemberResolver extends AbstractPersisten
|
|||
BiConsumer<String,MemberDetails> memberConsumer,
|
||||
Function<FieldDetails,Boolean> transientFieldChecker,
|
||||
Function<MethodDetails,Boolean> transientMethodChecker,
|
||||
ClassDetails classDetails) {
|
||||
ClassDetails classDetails,
|
||||
ClassAttributeAccessType classLevelAccessType) {
|
||||
final List<FieldDetails> fields = classDetails.getFields();
|
||||
for ( int i = 0; i < fields.size(); i++ ) {
|
||||
final FieldDetails fieldDetails = fields.get( i );
|
||||
processAttributeLevelAccessMember( fieldDetails, memberConsumer, transientFieldChecker, classDetails );
|
||||
processAttributeLevelAccessMember( fieldDetails, memberConsumer, transientFieldChecker, classDetails, classLevelAccessType );
|
||||
}
|
||||
|
||||
final List<MethodDetails> methods = classDetails.getMethods();
|
||||
for ( int i = 0; i < methods.size(); i++ ) {
|
||||
final MethodDetails methodDetails = methods.get( i );
|
||||
processAttributeLevelAccessMember( methodDetails, memberConsumer, transientMethodChecker, classDetails );
|
||||
processAttributeLevelAccessMember( methodDetails, memberConsumer, transientMethodChecker, classDetails, classLevelAccessType );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,22 +123,115 @@ public class StandardPersistentAttributeMemberResolver extends AbstractPersisten
|
|||
M memberDetails,
|
||||
BiConsumer<String,MemberDetails> memberConsumer,
|
||||
Function<M,Boolean> transiencyChecker,
|
||||
ClassDetails classDetails) {
|
||||
ClassDetails classDetails,
|
||||
ClassAttributeAccessType classLevelAccessType) {
|
||||
if ( transiencyChecker.apply( memberDetails ) ) {
|
||||
// the field is transient
|
||||
return;
|
||||
}
|
||||
|
||||
final AnnotationUsage<Access> access = memberDetails.getAnnotationUsage( JpaAnnotations.ACCESS );
|
||||
if ( access == null ) {
|
||||
checkForMisplacedAnnotations( classDetails, memberDetails, classLevelAccessType );
|
||||
return;
|
||||
}
|
||||
|
||||
final AccessType attributeAccessType = access.getAttributeValue( "value" );
|
||||
|
||||
validateAttributeLevelAccess( memberDetails, attributeAccessType, classDetails );
|
||||
|
||||
if ( transiencyChecker.apply( memberDetails ) ) {
|
||||
// the field is @Transient
|
||||
memberConsumer.accept( memberDetails.resolveAttributeName(), memberDetails );
|
||||
}
|
||||
|
||||
private <M extends MemberDetails> void checkForMisplacedAnnotations(
|
||||
ClassDetails classDetails,
|
||||
M memberDetails,
|
||||
ClassAttributeAccessType classLevelAccessType) {
|
||||
// We have a case where the member did not define `@Access`.
|
||||
//
|
||||
// In such a case the member would only be an attribute backer if the member
|
||||
// kind matched the class access-type. If the member kind does *not* match
|
||||
// the class access-type, validate that it does not declare any mapping annotations
|
||||
|
||||
if ( classLevelAccessType == null ) {
|
||||
// nothing to check
|
||||
return;
|
||||
}
|
||||
|
||||
memberConsumer.accept( memberDetails.resolveAttributeName(), memberDetails );
|
||||
if ( !matchesAccessType( memberDetails, classLevelAccessType ) ) {
|
||||
if ( containsMappingAnnotations( memberDetails ) ) {
|
||||
if ( memberDetails.getKind() == AnnotationTarget.Kind.FIELD ) {
|
||||
throw new AnnotationPlacementException(
|
||||
String.format(
|
||||
Locale.ROOT,
|
||||
"Field `%s#%s` declared mapping annotations even though it is not a persistent attribute",
|
||||
classDetails.getName(),
|
||||
memberDetails.getName()
|
||||
)
|
||||
);
|
||||
}
|
||||
else {
|
||||
assert memberDetails.getKind() == AnnotationTarget.Kind.METHOD;
|
||||
throw new AnnotationPlacementException(
|
||||
String.format(
|
||||
Locale.ROOT,
|
||||
"Method `%s#%s` declared mapping annotations even though it is not a persistent attribute",
|
||||
classDetails.getName(),
|
||||
memberDetails.getName()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private <M extends MemberDetails> boolean matchesAccessType(
|
||||
M memberDetails,
|
||||
ClassAttributeAccessType classLevelAccessType) {
|
||||
assert classLevelAccessType != null;
|
||||
if ( classLevelAccessType.getJpaAccessType() == AccessType.FIELD ) {
|
||||
return memberDetails.getKind() == AnnotationTarget.Kind.FIELD;
|
||||
}
|
||||
else {
|
||||
return memberDetails.getKind() == AnnotationTarget.Kind.METHOD
|
||||
&& ( (MethodDetails) memberDetails ).getMethodKind() == MethodDetails.MethodKind.GETTER;
|
||||
}
|
||||
}
|
||||
|
||||
private <M extends MemberDetails> boolean containsMappingAnnotations(M memberDetails) {
|
||||
// todo (jpa32) : better way to do this?
|
||||
return memberDetails.hasAnnotationUsage( Id.class )
|
||||
|| memberDetails.hasAnnotationUsage( EmbeddedId.class )
|
||||
|| memberDetails.hasAnnotationUsage( Version.class )
|
||||
|| memberDetails.hasAnnotationUsage( Basic.class )
|
||||
|| memberDetails.hasAnnotationUsage( Embedded.class )
|
||||
|| memberDetails.hasAnnotationUsage( ManyToOne.class )
|
||||
|| memberDetails.hasAnnotationUsage( OneToOne.class )
|
||||
|| memberDetails.hasAnnotationUsage( ElementCollection.class )
|
||||
|| memberDetails.hasAnnotationUsage( ManyToMany.class )
|
||||
|| memberDetails.hasAnnotationUsage( OneToMany.class )
|
||||
|| memberDetails.hasAnnotationUsage( Any.class )
|
||||
|| memberDetails.hasAnnotationUsage( ManyToAny.class )
|
||||
|| memberDetails.hasAnnotationUsage( AnyKeyJavaClass.class )
|
||||
|| memberDetails.hasAnnotationUsage( AnyKeyJavaType.class )
|
||||
|| memberDetails.hasAnnotationUsage( AnyKeyJdbcType.class )
|
||||
|| memberDetails.hasAnnotationUsage( AnyKeyJdbcTypeCode.class )
|
||||
|| memberDetails.hasAnnotationUsage( AnyKeyType.class )
|
||||
|| memberDetails.hasAnnotationUsage( AnyDiscriminator.class )
|
||||
|| memberDetails.hasAnnotationUsage( AnyDiscriminatorValue.class )
|
||||
|| memberDetails.hasAnnotationUsage( AnyDiscriminatorValues.class )
|
||||
|| memberDetails.hasAnnotationUsage( Column.class )
|
||||
|| memberDetails.hasAnnotationUsage( Enumerated.class )
|
||||
|| memberDetails.hasAnnotationUsage( Lob.class )
|
||||
|| memberDetails.hasAnnotationUsage( Temporal.class )
|
||||
|| memberDetails.hasAnnotationUsage( Nationalized.class )
|
||||
|| memberDetails.hasAnnotationUsage( TenantId.class )
|
||||
|| memberDetails.hasAnnotationUsage( Generated.class )
|
||||
|| memberDetails.hasAnnotationUsage( TimeZoneColumn.class )
|
||||
|| memberDetails.hasAnnotationUsage( TimeZoneStorage.class )
|
||||
|| memberDetails.hasAnnotationUsage( Type.class )
|
||||
|| memberDetails.hasAnnotationUsage( JavaType.class )
|
||||
|| memberDetails.hasAnnotationUsage( JdbcType.class )
|
||||
|| memberDetails.hasAnnotationUsage( JdbcTypeCode.class );
|
||||
}
|
||||
|
||||
private void validateAttributeLevelAccess(
|
||||
|
@ -115,20 +244,34 @@ public class StandardPersistentAttributeMemberResolver extends AbstractPersisten
|
|||
// 1. specify @Access(FIELD) on a getter
|
||||
// 2. specify @Access(PROPERTY) on a field
|
||||
|
||||
// todo (jpa32) : pass along access to JpaCompliance and use a new `JpaCompliance#isAnnotationPlacementComplianceEnabled` method here
|
||||
// - for now, just allow it as we interpret the actual attribute AccessType value to dictate the state access
|
||||
if ( !isAnnotationPlacementComplianceEnabled() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ( attributeAccessType == AccessType.FIELD && !annotationTarget.isField() )
|
||||
|| ( attributeAccessType == AccessType.PROPERTY && annotationTarget.isField() ) ) {
|
||||
throw new AccessTypePlacementException( classDetails, annotationTarget );
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isAnnotationPlacementComplianceEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void processClassLevelAccess(
|
||||
Function<String,Boolean> alreadyProcessedChecker,
|
||||
BiConsumer<String, MemberDetails> memberConsumer,
|
||||
Function<FieldDetails,Boolean> transientFieldChecker,
|
||||
Function<MethodDetails,Boolean> transientMethodChecker,
|
||||
ClassDetails classDetails,
|
||||
AccessType classLevelAccessType) {
|
||||
if ( classLevelAccessType == AccessType.FIELD ) {
|
||||
ClassAttributeAccessType classLevelAccessType) {
|
||||
if ( classLevelAccessType == null ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( classLevelAccessType.getJpaAccessType() == AccessType.FIELD ) {
|
||||
final List<FieldDetails> fields = classDetails.getFields();
|
||||
for ( int i = 0; i < fields.size(); i++ ) {
|
||||
final FieldDetails fieldDetails = fields.get( i );
|
||||
|
@ -151,7 +294,7 @@ public class StandardPersistentAttributeMemberResolver extends AbstractPersisten
|
|||
}
|
||||
}
|
||||
else {
|
||||
assert classLevelAccessType == AccessType.PROPERTY;
|
||||
assert classLevelAccessType.getJpaAccessType() == AccessType.PROPERTY;
|
||||
final List<MethodDetails> methods = classDetails.getMethods();
|
||||
for ( int i = 0; i < methods.size(); i++ ) {
|
||||
final MethodDetails methodDetails = methods.get( i );
|
||||
|
|
|
@ -32,12 +32,17 @@ public interface AttributeMetadata extends TableOwner {
|
|||
|
||||
/**
|
||||
* An enum defining the nature (categorization) of a persistent attribute.
|
||||
*
|
||||
* @see jakarta.persistence.metamodel.Attribute.PersistentAttributeType
|
||||
*/
|
||||
enum AttributeNature {
|
||||
BASIC,
|
||||
EMBEDDED,
|
||||
ANY,
|
||||
TO_ONE,
|
||||
PLURAL
|
||||
ELEMENT_COLLECTION,
|
||||
MANY_TO_ANY,
|
||||
MANY_TO_MANY,
|
||||
ONE_TO_MANY
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,12 +9,15 @@ package org.hibernate.boot.models.categorize.spi;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hibernate.boot.models.xml.spi.PersistenceUnitMetadata;
|
||||
import org.hibernate.internal.util.IndexedConsumer;
|
||||
import org.hibernate.internal.util.KeyedConsumer;
|
||||
import org.hibernate.models.spi.AnnotationDescriptorRegistry;
|
||||
import org.hibernate.models.spi.ClassDetails;
|
||||
import org.hibernate.models.spi.ClassDetailsRegistry;
|
||||
|
||||
import org.jboss.jandex.IndexView;
|
||||
|
||||
/**
|
||||
* The application's domain model, understood at a very rudimentary level - we know
|
||||
* a class is an entity, a mapped-superclass, ... And we know about persistent attributes,
|
||||
|
@ -36,6 +39,15 @@ public interface CategorizedDomainModel {
|
|||
*/
|
||||
AnnotationDescriptorRegistry getAnnotationDescriptorRegistry();
|
||||
|
||||
IndexView getJandexIndex();
|
||||
|
||||
PersistenceUnitMetadata getPersistenceUnitMetadata();
|
||||
|
||||
/**
|
||||
* Global registrations collected while processing the persistence-unit.
|
||||
*/
|
||||
GlobalRegistrations getGlobalRegistrations();
|
||||
|
||||
/**
|
||||
* All entity hierarchies defined in the persistence unit
|
||||
*/
|
||||
|
@ -91,9 +103,4 @@ public interface CategorizedDomainModel {
|
|||
|
||||
embeddables.forEach( consumer::accept );
|
||||
}
|
||||
|
||||
/**
|
||||
* Global registrations collected while processing the persistence-unit.
|
||||
*/
|
||||
GlobalRegistrations getGlobalRegistrations();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.boot.models.categorize.spi;
|
||||
|
||||
import jakarta.persistence.AccessType;
|
||||
|
||||
/**
|
||||
* Possible class-level {@linkplain jakarta.persistence.AccessType} values.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public enum ClassAttributeAccessType {
|
||||
/**
|
||||
* The class explicitly defined field access via {@linkplain jakarta.persistence.Access}
|
||||
*/
|
||||
EXPLICIT_FIELD(true, AccessType.FIELD),
|
||||
|
||||
/**
|
||||
* The class explicitly defined property access via {@linkplain jakarta.persistence.Access}
|
||||
*/
|
||||
EXPLICIT_PROPERTY(true, AccessType.PROPERTY),
|
||||
|
||||
/**
|
||||
* The class implicitly defined field access.
|
||||
*/
|
||||
IMPLICIT_FIELD(false, AccessType.FIELD),
|
||||
|
||||
/**
|
||||
* The class implicitly defined property access.
|
||||
*/
|
||||
IMPLICIT_PROPERTY(false, AccessType.PROPERTY);
|
||||
|
||||
private final boolean explicit;
|
||||
private final AccessType jpaAccessType;
|
||||
|
||||
ClassAttributeAccessType(boolean explicit, AccessType jpaAccessType) {
|
||||
this.explicit = explicit;
|
||||
this.jpaAccessType = jpaAccessType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the access-type was explicitly specified
|
||||
*/
|
||||
public boolean isExplicit() {
|
||||
return explicit;
|
||||
}
|
||||
|
||||
/**
|
||||
* The corresponding {@linkplain jakarta.persistence.AccessType}
|
||||
*/
|
||||
public AccessType getJpaAccessType() {
|
||||
return jpaAccessType;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.boot.models.categorize.spi;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import org.hibernate.models.spi.ClassDetails;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public record ConverterRegistration(ClassDetails converterClass, Boolean autoApply) {
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if ( this == o ) {
|
||||
return true;
|
||||
}
|
||||
if ( o == null || getClass() != o.getClass() ) {
|
||||
return false;
|
||||
}
|
||||
ConverterRegistration that = (ConverterRegistration) o;
|
||||
return Objects.equals( converterClass, that.converterClass );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash( converterClass );
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ package org.hibernate.boot.models.categorize.spi;
|
|||
|
||||
import org.hibernate.engine.OptimisticLockStyle;
|
||||
|
||||
import jakarta.persistence.AccessType;
|
||||
import jakarta.persistence.InheritanceType;
|
||||
|
||||
/**
|
||||
|
@ -33,6 +34,12 @@ public interface EntityHierarchy {
|
|||
*/
|
||||
void forEachType(HierarchyTypeVisitor typeVisitor);
|
||||
|
||||
/**
|
||||
* The default access-type for the hierarchy. See section <i>2.3.1 Default Access Type</i>
|
||||
* of the Jakarta Persistence specification.
|
||||
*/
|
||||
AccessType getDefaultAccessType();
|
||||
|
||||
/**
|
||||
* The inheritance strategy for the hierarchy.
|
||||
*/
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
*/
|
||||
package org.hibernate.boot.models.categorize.spi;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.boot.model.CustomSql;
|
||||
import org.hibernate.boot.model.naming.EntityNaming;
|
||||
|
||||
|
@ -81,15 +83,15 @@ public interface EntityTypeMetadata extends IdentifiableTypeMetadata, EntityNami
|
|||
/**
|
||||
* Custom SQL to perform an INSERT of this entity
|
||||
*/
|
||||
CustomSql getCustomInsert();
|
||||
Map<String, CustomSql> getCustomInserts();
|
||||
|
||||
/**
|
||||
* Custom SQL to perform an UPDATE of this entity
|
||||
*/
|
||||
CustomSql getCustomUpdate();
|
||||
Map<String, CustomSql> getCustomUpdates();
|
||||
|
||||
/**
|
||||
* Custom SQL to perform an DELETE of this entity
|
||||
*/
|
||||
CustomSql getCustomDelete();
|
||||
Map<String, CustomSql> getCustomDeletes();
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ package org.hibernate.boot.models.categorize.spi;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -35,12 +36,16 @@ public interface GlobalRegistrations {
|
|||
|
||||
Map<String, FilterDefRegistration> getFilterDefRegistrations();
|
||||
|
||||
Map<String, String> getImportedRenames();
|
||||
|
||||
Map<String, SequenceGeneratorRegistration> getSequenceGeneratorRegistrations();
|
||||
|
||||
Map<String, TableGeneratorRegistration> getTableGeneratorRegistrations();
|
||||
|
||||
Map<String, GenericGeneratorRegistration> getGenericGeneratorRegistrations();
|
||||
|
||||
Set<ConverterRegistration> getJpaConverters();
|
||||
|
||||
// todo : named entity graphs
|
||||
// todo : named queries
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ import jakarta.persistence.PreUpdate;
|
|||
*
|
||||
* Represents a global entity listener defined in the persistence unit
|
||||
*
|
||||
* @see JaxbPersistenceUnitDefaultsImpl#getEntityListeners()
|
||||
* @see JaxbPersistenceUnitDefaultsImpl#getEntityListenerContainer()
|
||||
* @see JaxbEntityListenerImpl
|
||||
* @see GlobalRegistrations#getEntityListenerRegistrations()
|
||||
*
|
||||
|
@ -109,9 +109,9 @@ public class JpaEventListener {
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a listener descriptor from XML (with explicitly named methods)
|
||||
* Create a listener descriptor from XML
|
||||
*
|
||||
* @see JaxbPersistenceUnitDefaultsImpl#getEntityListeners()
|
||||
* @see JaxbPersistenceUnitDefaultsImpl#getEntityListenerContainer()
|
||||
* @see JaxbEntityListenerImpl
|
||||
* @see GlobalRegistrations#getEntityListenerRegistrations()
|
||||
*/
|
||||
|
@ -127,13 +127,17 @@ public class JpaEventListener {
|
|||
final MutableObject<MethodDetails> postUpdateMethod = new MutableObject<>();
|
||||
final MutableObject<MethodDetails> postLoadMethod = new MutableObject<>();
|
||||
|
||||
if ( isImplicitMethodMappings( jaxbMapping ) ) {
|
||||
return from( consumerType, listenerClassDetails );
|
||||
}
|
||||
|
||||
listenerClassDetails.forEachMethod( (index, methodDetails) -> {
|
||||
if ( jaxbMapping.getPrePersist() != null
|
||||
&& methodDetails.getName().equals( jaxbMapping.getPrePersist().getMethodName() )
|
||||
&& matchesSignature( consumerType, methodDetails ) ) {
|
||||
prePersistMethod.set( methodDetails );
|
||||
}
|
||||
else if ( jaxbMapping.getPostPersist().getMethodName() != null
|
||||
else if ( jaxbMapping.getPostPersist() != null
|
||||
&& methodDetails.getName().equals( jaxbMapping.getPostPersist().getMethodName() )
|
||||
&& matchesSignature( consumerType, methodDetails ) ) {
|
||||
postPersistMethod.set( methodDetails );
|
||||
|
@ -182,6 +186,16 @@ public class JpaEventListener {
|
|||
return jpaEventListener;
|
||||
}
|
||||
|
||||
private static boolean isImplicitMethodMappings(JaxbEntityListenerImpl jaxbMapping) {
|
||||
return jaxbMapping.getPrePersist() == null
|
||||
&& jaxbMapping.getPreUpdate() == null
|
||||
&& jaxbMapping.getPreRemove() == null
|
||||
&& jaxbMapping.getPostLoad() == null
|
||||
&& jaxbMapping.getPostPersist() == null
|
||||
&& jaxbMapping.getPostUpdate() == null
|
||||
&& jaxbMapping.getPostRemove() == null;
|
||||
}
|
||||
|
||||
private static void errorIfEmpty(JpaEventListener jpaEventListener) {
|
||||
if ( jpaEventListener.prePersistMethod == null
|
||||
&& jpaEventListener.postPersistMethod == null
|
||||
|
@ -194,6 +208,12 @@ public class JpaEventListener {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a listener descriptor from annotations
|
||||
*
|
||||
* @see jakarta.persistence.EntityListeners
|
||||
* @see GlobalRegistrations#getEntityListenerRegistrations()
|
||||
*/
|
||||
public static JpaEventListener from(JpaEventListenerStyle consumerType, ClassDetails listenerClassDetails) {
|
||||
final MutableObject<MethodDetails> prePersistMethod = new MutableObject<>();
|
||||
final MutableObject<MethodDetails> postPersistMethod = new MutableObject<>();
|
||||
|
|
|
@ -10,6 +10,7 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.hibernate.boot.model.process.spi.ManagedResources;
|
||||
import org.hibernate.boot.models.categorize.ModelCategorizationLogging;
|
||||
|
@ -17,10 +18,10 @@ import org.hibernate.boot.models.categorize.internal.ClassLoaderServiceLoading;
|
|||
import org.hibernate.boot.models.categorize.internal.DomainModelCategorizationCollector;
|
||||
import org.hibernate.boot.models.categorize.internal.ModelCategorizationContextImpl;
|
||||
import org.hibernate.boot.models.categorize.internal.OrmAnnotationHelper;
|
||||
import org.hibernate.boot.models.categorize.xml.spi.XmlPreProcessingResult;
|
||||
import org.hibernate.boot.models.categorize.xml.spi.XmlPreProcessor;
|
||||
import org.hibernate.boot.models.categorize.xml.spi.XmlProcessingResult;
|
||||
import org.hibernate.boot.models.categorize.xml.spi.XmlProcessor;
|
||||
import org.hibernate.boot.models.xml.spi.XmlPreProcessingResult;
|
||||
import org.hibernate.boot.models.xml.spi.XmlPreProcessor;
|
||||
import org.hibernate.boot.models.xml.spi.XmlProcessingResult;
|
||||
import org.hibernate.boot.models.xml.spi.XmlProcessor;
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
|
||||
import org.hibernate.boot.spi.BootstrapContext;
|
||||
|
@ -41,7 +42,7 @@ import org.jboss.jandex.IndexView;
|
|||
import org.jboss.jandex.Indexer;
|
||||
|
||||
import static org.hibernate.boot.models.categorize.internal.EntityHierarchyBuilder.createEntityHierarchies;
|
||||
import static org.hibernate.models.internal.util.CollectionHelper.mutableJoin;
|
||||
import static org.hibernate.internal.util.collections.CollectionHelper.mutableJoin;
|
||||
|
||||
/**
|
||||
* Processes a {@linkplain ManagedResources} (classes, mapping, etc.) and
|
||||
|
@ -75,7 +76,9 @@ public class ManagedResourcesProcessor {
|
|||
|
||||
final XmlPreProcessingResult xmlPreProcessingResult = XmlPreProcessor.preProcessXmlResources( managedResources );
|
||||
|
||||
//noinspection unchecked
|
||||
final List<String> allKnownClassNames = mutableJoin(
|
||||
managedResources.getAnnotatedClassReferences().stream().map( Class::getName ).collect( Collectors.toList() ),
|
||||
managedResources.getAnnotatedClassNames(),
|
||||
xmlPreProcessingResult.getMappedClasses()
|
||||
);
|
||||
|
@ -118,22 +121,23 @@ public class ManagedResourcesProcessor {
|
|||
|
||||
// JPA id generator global-ity thing
|
||||
final boolean areIdGeneratorsGlobal = true;
|
||||
final ClassDetailsRegistry mutableClassDetailsRegistry = sourceModelBuildingContext.getClassDetailsRegistry();
|
||||
final ClassDetailsRegistry classDetailsRegistry = sourceModelBuildingContext.getClassDetailsRegistry();
|
||||
final AnnotationDescriptorRegistry descriptorRegistry = sourceModelBuildingContext.getAnnotationDescriptorRegistry();
|
||||
final DomainModelCategorizationCollector modelCategorizationCollector = new DomainModelCategorizationCollector(
|
||||
areIdGeneratorsGlobal,
|
||||
mutableClassDetailsRegistry,
|
||||
descriptorRegistry
|
||||
classDetailsRegistry,
|
||||
descriptorRegistry,
|
||||
jandexIndex
|
||||
);
|
||||
|
||||
final XmlProcessingResult xmlProcessingResult = XmlProcessor.processXml( xmlPreProcessingResult, modelCategorizationCollector, sourceModelBuildingContext );
|
||||
|
||||
allKnownClassNames.forEach( (className) -> {
|
||||
final ClassDetails classDetails = mutableClassDetailsRegistry.resolveClassDetails( className );
|
||||
final ClassDetails classDetails = classDetailsRegistry.resolveClassDetails( className );
|
||||
modelCategorizationCollector.apply( classDetails );
|
||||
} );
|
||||
xmlPreProcessingResult.getMappedNames().forEach( (className) -> {
|
||||
final ClassDetails classDetails = mutableClassDetailsRegistry.resolveClassDetails( className );
|
||||
final ClassDetails classDetails = classDetailsRegistry.resolveClassDetails( className );
|
||||
modelCategorizationCollector.apply( classDetails );
|
||||
} );
|
||||
|
||||
|
@ -152,7 +156,7 @@ public class ManagedResourcesProcessor {
|
|||
// OUTPUTS:
|
||||
// - CategorizedDomainModel
|
||||
|
||||
final ClassDetailsRegistry classDetailsRegistryImmutable = mutableClassDetailsRegistry
|
||||
final ClassDetailsRegistry classDetailsRegistryImmutable = classDetailsRegistry
|
||||
.makeImmutableCopy();
|
||||
|
||||
final AnnotationDescriptorRegistry annotationDescriptorRegistryImmutable = descriptorRegistry
|
||||
|
@ -187,7 +191,12 @@ public class ManagedResourcesProcessor {
|
|||
);
|
||||
}
|
||||
|
||||
return modelCategorizationCollector.createResult( entityHierarchies, classDetailsRegistryImmutable, annotationDescriptorRegistryImmutable );
|
||||
return modelCategorizationCollector.createResult(
|
||||
entityHierarchies,
|
||||
xmlPreProcessingResult.getPersistenceUnitMetadata(),
|
||||
classDetailsRegistryImmutable,
|
||||
annotationDescriptorRegistryImmutable
|
||||
);
|
||||
}
|
||||
|
||||
private static void ignore(IdentifiableTypeMetadata identifiableTypeMetadata) {
|
||||
|
|
|
@ -32,7 +32,7 @@ public interface ManagedTypeMetadata {
|
|||
/**
|
||||
* The class-level access type
|
||||
*/
|
||||
AccessType getAccessType();
|
||||
ClassAttributeAccessType getClassLevelAccessType();
|
||||
|
||||
/**
|
||||
* Get the number of declared attributes
|
||||
|
|
|
@ -38,7 +38,7 @@ public interface PersistentAttributeMemberResolver {
|
|||
*/
|
||||
List<MemberDetails> resolveAttributesMembers(
|
||||
ClassDetails classDetails,
|
||||
AccessType classLevelAccessType,
|
||||
ClassAttributeAccessType classLevelAccessType,
|
||||
AllMemberConsumer allMemberConsumer);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright: Red Hat Inc. and Hibernate Authors
|
||||
*/
|
||||
package org.hibernate.boot.models.categorize.xml.internal.attr;
|
||||
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbManyToManyImpl;
|
||||
import org.hibernate.boot.models.categorize.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.models.internal.MutableClassDetails;
|
||||
import org.hibernate.models.internal.MutableMemberDetails;
|
||||
|
||||
import jakarta.persistence.AccessType;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class ManyToManyAttributeProcessing {
|
||||
|
||||
@SuppressWarnings("UnusedReturnValue")
|
||||
public static MutableMemberDetails processManyToManyAttribute(
|
||||
JaxbManyToManyImpl jaxbManyToMany,
|
||||
MutableClassDetails mutableClassDetails,
|
||||
AccessType classAccessType,
|
||||
XmlDocumentContext xmlDocumentContext) {
|
||||
throw new UnsupportedOperationException( "Support for many-to-many attributes not yet implemented" );
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright: Red Hat Inc. and Hibernate Authors
|
||||
*/
|
||||
package org.hibernate.boot.models.categorize.xml.internal.attr;
|
||||
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbOneToOneImpl;
|
||||
import org.hibernate.boot.models.categorize.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.models.internal.MutableClassDetails;
|
||||
import org.hibernate.models.internal.MutableMemberDetails;
|
||||
|
||||
import jakarta.persistence.AccessType;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class OneToOneAttributeProcessing {
|
||||
|
||||
@SuppressWarnings("UnusedReturnValue")
|
||||
public static MutableMemberDetails processOneToOneAttribute(
|
||||
JaxbOneToOneImpl jaxbOneToOne,
|
||||
MutableClassDetails mutableClassDetails,
|
||||
AccessType classAccessType,
|
||||
XmlDocumentContext xmlDocumentContext) {
|
||||
throw new UnsupportedOperationException( "Support for one-to-one attributes not yet implemented" );
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright: Red Hat Inc. and Hibernate Authors
|
||||
*/
|
||||
package org.hibernate.boot.models.categorize.xml.spi;
|
||||
|
||||
import org.hibernate.models.spi.SourceModelBuildingContext;
|
||||
|
||||
/**
|
||||
* Context to a specific XML mapping file
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface XmlDocumentContext {
|
||||
XmlDocument getXmlDocument();
|
||||
|
||||
PersistenceUnitMetadata getPersistenceUnitMetadata();
|
||||
|
||||
SourceModelBuildingContext getModelBuildingContext();
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.boot.models.xml;
|
||||
|
||||
import org.hibernate.Internal;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@Internal
|
||||
public interface XmlProcessLogging {
|
||||
String NAME = "org.hibernate.models.xml";
|
||||
|
||||
Logger XML_PROCESS_LOGGER = Logger.getLogger( NAME );
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright: Red Hat Inc. and Hibernate Authors
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.boot.models.categorize.xml;
|
||||
package org.hibernate.boot.models.xml;
|
||||
|
||||
/**
|
||||
* Generally indicates a problem locating or table an XML resource
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright: Red Hat Inc. and Hibernate Authors
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.boot.models.categorize.xml.internal;
|
||||
package org.hibernate.boot.models.xml.internal;
|
||||
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbAnyMappingImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbAttributesContainer;
|
||||
|
@ -19,16 +19,16 @@ import org.hibernate.boot.jaxb.mapping.spi.JaxbOneToManyImpl;
|
|||
import org.hibernate.boot.jaxb.mapping.spi.JaxbOneToOneImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbPersistentAttribute;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbPluralAnyMappingImpl;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.attr.AnyMappingAttributeProcessing;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.attr.BasicAttributeProcessing;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.attr.ElementCollectionAttributeProcessing;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.attr.EmbeddedAttributeProcessing;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.attr.ManyToManyAttributeProcessing;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.attr.ManyToOneAttributeProcessing;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.attr.OneToManyAttributeProcessing;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.attr.OneToOneAttributeProcessing;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.attr.PluralAnyMappingAttributeProcessing;
|
||||
import org.hibernate.boot.models.categorize.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.boot.models.xml.internal.attr.AnyMappingAttributeProcessing;
|
||||
import org.hibernate.boot.models.xml.internal.attr.BasicAttributeProcessing;
|
||||
import org.hibernate.boot.models.xml.internal.attr.ElementCollectionAttributeProcessing;
|
||||
import org.hibernate.boot.models.xml.internal.attr.EmbeddedAttributeProcessing;
|
||||
import org.hibernate.boot.models.xml.internal.attr.ManyToManyAttributeProcessing;
|
||||
import org.hibernate.boot.models.xml.internal.attr.ManyToOneAttributeProcessing;
|
||||
import org.hibernate.boot.models.xml.internal.attr.OneToManyAttributeProcessing;
|
||||
import org.hibernate.boot.models.xml.internal.attr.OneToOneAttributeProcessing;
|
||||
import org.hibernate.boot.models.xml.internal.attr.PluralAnyMappingAttributeProcessing;
|
||||
import org.hibernate.boot.models.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.models.internal.MutableClassDetails;
|
||||
import org.hibernate.models.internal.MutableMemberDetails;
|
||||
|
|
@ -1,16 +1,17 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright: Red Hat Inc. and Hibernate Authors
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.boot.models.categorize.xml.internal;
|
||||
package org.hibernate.boot.models.xml.internal;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.hibernate.annotations.SQLDelete;
|
||||
import org.hibernate.annotations.SQLInsert;
|
||||
|
@ -38,12 +39,12 @@ import org.hibernate.boot.jaxb.mapping.spi.JaxbPersistentAttribute;
|
|||
import org.hibernate.boot.jaxb.mapping.spi.JaxbPluralAttribute;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbTenantIdImpl;
|
||||
import org.hibernate.boot.models.categorize.spi.JpaEventListenerStyle;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.attr.BasicAttributeProcessing;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.attr.BasicIdAttributeProcessing;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.attr.CommonAttributeProcessing;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.attr.EmbeddedIdAttributeProcessing;
|
||||
import org.hibernate.boot.models.categorize.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.boot.models.categorize.xml.spi.XmlProcessingResult;
|
||||
import org.hibernate.boot.models.xml.internal.attr.BasicAttributeProcessing;
|
||||
import org.hibernate.boot.models.xml.internal.attr.BasicIdAttributeProcessing;
|
||||
import org.hibernate.boot.models.xml.internal.attr.CommonAttributeProcessing;
|
||||
import org.hibernate.boot.models.xml.internal.attr.EmbeddedIdAttributeProcessing;
|
||||
import org.hibernate.boot.models.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.boot.models.xml.spi.XmlProcessingResult;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||
import org.hibernate.models.ModelsException;
|
||||
|
@ -53,15 +54,22 @@ import org.hibernate.models.internal.MutableClassDetails;
|
|||
import org.hibernate.models.internal.MutableMemberDetails;
|
||||
import org.hibernate.models.internal.dynamic.DynamicClassDetails;
|
||||
import org.hibernate.models.internal.dynamic.MapModeFieldDetails;
|
||||
import org.hibernate.models.spi.AnnotationUsage;
|
||||
import org.hibernate.models.spi.ClassDetails;
|
||||
import org.hibernate.models.spi.ClassDetailsRegistry;
|
||||
import org.hibernate.models.spi.FieldDetails;
|
||||
import org.hibernate.models.spi.MethodDetails;
|
||||
import org.hibernate.property.access.spi.BuiltInPropertyAccessStrategies;
|
||||
|
||||
import jakarta.persistence.Access;
|
||||
import jakarta.persistence.AccessType;
|
||||
import jakarta.persistence.Embeddable;
|
||||
import jakarta.persistence.EmbeddedId;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.MappedSuperclass;
|
||||
|
||||
import static org.hibernate.internal.util.NullnessHelper.coalesce;
|
||||
import static org.hibernate.internal.util.NullnessHelper.coalesceSuppliedValues;
|
||||
import static org.hibernate.internal.util.NullnessHelper.nullif;
|
||||
|
||||
/**
|
||||
|
@ -115,7 +123,9 @@ public class ManagedTypeProcessor {
|
|||
classDetails = (MutableClassDetails) classDetailsRegistry.resolveClassDetails( className );
|
||||
classAccessType = coalesce(
|
||||
jaxbEntity.getAccess(),
|
||||
xmlDocumentContext.getPersistenceUnitMetadata().getAccessType()
|
||||
jaxbRoot.getAccess(),
|
||||
xmlDocumentContext.getPersistenceUnitMetadata().getAccessType(),
|
||||
AccessType.PROPERTY
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -338,7 +348,7 @@ public class ManagedTypeProcessor {
|
|||
final ClassDetailsRegistry classDetailsRegistry = xmlDocumentContext.getModelBuildingContext().getClassDetailsRegistry();
|
||||
|
||||
if ( jaxbPersistentAttribute instanceof JaxbIdImpl jaxbId ) {
|
||||
return XmlAnnotationHelper.resolveJavaType( jaxbId.getTarget(), xmlDocumentContext );
|
||||
return xmlDocumentContext.resolveJavaType( jaxbId.getTarget() );
|
||||
}
|
||||
|
||||
if ( jaxbPersistentAttribute instanceof JaxbEmbeddedIdImpl jaxbEmbeddedId ) {
|
||||
|
@ -353,7 +363,7 @@ public class ManagedTypeProcessor {
|
|||
}
|
||||
|
||||
if ( jaxbPersistentAttribute instanceof JaxbBasicImpl jaxbBasic ) {
|
||||
return XmlAnnotationHelper.resolveJavaType( jaxbBasic.getTarget(), xmlDocumentContext );
|
||||
return xmlDocumentContext.resolveJavaType( jaxbBasic.getTarget() );
|
||||
}
|
||||
|
||||
if ( jaxbPersistentAttribute instanceof JaxbEmbeddedImpl jaxbEmbedded ) {
|
||||
|
@ -436,27 +446,29 @@ public class ManagedTypeProcessor {
|
|||
}
|
||||
|
||||
final JaxbAttributesContainerImpl attributes = jaxbEntity.getAttributes();
|
||||
processIdMappings(
|
||||
attributes,
|
||||
classAccessType,
|
||||
classDetails,
|
||||
memberAdjuster,
|
||||
xmlDocumentContext
|
||||
);
|
||||
AttributeProcessor.processNaturalId(
|
||||
attributes.getNaturalId(),
|
||||
classDetails,
|
||||
classAccessType,
|
||||
memberAdjuster,
|
||||
xmlDocumentContext
|
||||
);
|
||||
AttributeProcessor.processAttributes(
|
||||
attributes,
|
||||
classDetails,
|
||||
classAccessType,
|
||||
memberAdjuster,
|
||||
xmlDocumentContext
|
||||
);
|
||||
if ( attributes != null ) {
|
||||
processIdMappings(
|
||||
attributes,
|
||||
classAccessType,
|
||||
classDetails,
|
||||
memberAdjuster,
|
||||
xmlDocumentContext
|
||||
);
|
||||
AttributeProcessor.processNaturalId(
|
||||
attributes.getNaturalId(),
|
||||
classDetails,
|
||||
classAccessType,
|
||||
memberAdjuster,
|
||||
xmlDocumentContext
|
||||
);
|
||||
AttributeProcessor.processAttributes(
|
||||
attributes,
|
||||
classDetails,
|
||||
classAccessType,
|
||||
memberAdjuster,
|
||||
xmlDocumentContext
|
||||
);
|
||||
}
|
||||
|
||||
jaxbEntity.getFilters().forEach( jaxbFilter -> XmlAnnotationHelper.applyFilter(
|
||||
jaxbFilter,
|
||||
|
@ -551,9 +563,12 @@ public class ManagedTypeProcessor {
|
|||
.getClassDetailsRegistry()
|
||||
.resolveClassDetails( className );
|
||||
|
||||
final AccessType classAccessType = coalesce(
|
||||
jaxbEntity.getAccess(),
|
||||
xmlDocumentContext.getPersistenceUnitMetadata().getAccessType()
|
||||
final AccessType classAccessType = coalesceSuppliedValues(
|
||||
jaxbEntity::getAccess,
|
||||
jaxbRoot::getAccess,
|
||||
() -> determineAccessTypeFromClassAnnotations( classDetails ),
|
||||
xmlDocumentContext.getPersistenceUnitMetadata()::getAccessType,
|
||||
() -> AccessType.PROPERTY
|
||||
);
|
||||
|
||||
// from here, processing is the same between override and metadata-complete modes
|
||||
|
@ -569,6 +584,41 @@ public class ManagedTypeProcessor {
|
|||
|
||||
}
|
||||
|
||||
private static AccessType determineAccessTypeFromClassAnnotations(ClassDetails classDetails) {
|
||||
final AnnotationUsage<Access> accessUsage = classDetails.getAnnotationUsage( Access.class );
|
||||
if ( accessUsage != null ) {
|
||||
return accessUsage.getAttributeValue( "value" );
|
||||
}
|
||||
|
||||
for ( FieldDetails field : classDetails.getFields() ) {
|
||||
if ( field.getAnnotationUsage( Id.class ) != null
|
||||
|| field.getAnnotationUsage( EmbeddedId.class ) != null ) {
|
||||
return AccessType.FIELD;
|
||||
}
|
||||
}
|
||||
|
||||
for ( MethodDetails method : classDetails.getMethods() ) {
|
||||
if ( method.getAnnotationUsage( Id.class ) != null
|
||||
|| method.getAnnotationUsage( EmbeddedId.class ) != null ) {
|
||||
assert method.getMethodKind() == MethodDetails.MethodKind.GETTER;
|
||||
return AccessType.PROPERTY;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used in cases where neither the class nor the XML defined an explicit AccessType.
|
||||
* </p>
|
||||
* According to the specification, strictly speaking, this should (could) be an exception
|
||||
*/
|
||||
private static Supplier<AccessType> determineAccessTypeFromClassAndXml(
|
||||
JaxbEntityImpl jaxbEntity,
|
||||
MutableClassDetails classDetails) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void processIdMappings(
|
||||
JaxbAttributesContainerImpl attributes,
|
||||
AccessType classAccessType,
|
|
@ -1,21 +1,21 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright: Red Hat Inc. and Hibernate Authors
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.boot.models.categorize.xml.internal;
|
||||
package org.hibernate.boot.models.xml.internal;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import org.hibernate.annotations.CascadeType;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbPersistenceUnitDefaultsImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbPersistenceUnitMetadataImpl;
|
||||
import org.hibernate.boot.models.categorize.ModelCategorizationLogging;
|
||||
import org.hibernate.boot.models.categorize.xml.spi.PersistenceUnitMetadata;
|
||||
import org.hibernate.boot.models.xml.spi.PersistenceUnitMetadata;
|
||||
|
||||
import jakarta.persistence.AccessType;
|
||||
|
||||
import static org.hibernate.boot.models.xml.XmlProcessLogging.XML_PROCESS_LOGGER;
|
||||
import static org.hibernate.internal.util.StringHelper.isNotEmpty;
|
||||
import static org.hibernate.internal.util.StringHelper.splitTrimmingTokens;
|
||||
|
||||
|
@ -88,7 +88,7 @@ public final class PersistenceUnitMetadataImpl implements PersistenceUnitMetadat
|
|||
|
||||
if ( isNotEmpty( defaults.getCatalog() ) ) {
|
||||
if ( defaultCatalog != null ) {
|
||||
ModelCategorizationLogging.MODEL_CATEGORIZATION_LOGGER.debugf(
|
||||
XML_PROCESS_LOGGER.debugf(
|
||||
"Setting already set default catalog : %s, %s",
|
||||
defaultCatalog,
|
||||
defaults.getCatalog()
|
||||
|
@ -99,7 +99,7 @@ public final class PersistenceUnitMetadataImpl implements PersistenceUnitMetadat
|
|||
|
||||
if ( isNotEmpty( defaults.getSchema() ) ) {
|
||||
if ( defaultSchema != null ) {
|
||||
ModelCategorizationLogging.MODEL_CATEGORIZATION_LOGGER.debugf(
|
||||
XML_PROCESS_LOGGER.debugf(
|
||||
"Setting already set default schema : %s, %s",
|
||||
defaultSchema,
|
||||
defaults.getSchema()
|
||||
|
@ -110,7 +110,7 @@ public final class PersistenceUnitMetadataImpl implements PersistenceUnitMetadat
|
|||
|
||||
if ( defaults.getAccess() != null ) {
|
||||
if ( accessType != null ) {
|
||||
ModelCategorizationLogging.MODEL_CATEGORIZATION_LOGGER.debugf(
|
||||
XML_PROCESS_LOGGER.debugf(
|
||||
"Overriding already set default AccessType : %s, %s",
|
||||
defaults.getAccess(),
|
||||
accessType
|
||||
|
@ -121,7 +121,7 @@ public final class PersistenceUnitMetadataImpl implements PersistenceUnitMetadat
|
|||
|
||||
if ( isNotEmpty( defaults.getDefaultAccess() ) ) {
|
||||
if ( defaultAccessStrategy != null ) {
|
||||
ModelCategorizationLogging.MODEL_CATEGORIZATION_LOGGER.debugf(
|
||||
XML_PROCESS_LOGGER.debugf(
|
||||
"Overriding already set default access strategy : %s, %s",
|
||||
accessType,
|
||||
defaultAccessStrategy
|
||||
|
@ -133,7 +133,7 @@ public final class PersistenceUnitMetadataImpl implements PersistenceUnitMetadat
|
|||
if ( defaults.getCascadePersist() != null
|
||||
|| isNotEmpty( defaults.getDefaultCascade() ) ) {
|
||||
if ( !defaultCascadeTypes.isEmpty() ) {
|
||||
ModelCategorizationLogging.MODEL_CATEGORIZATION_LOGGER.debugf( "Adding cascades to already defined set of default cascades" );
|
||||
XML_PROCESS_LOGGER.debugf( "Adding cascades to already defined set of default cascades" );
|
||||
}
|
||||
|
||||
if ( defaults.getCascadePersist() != null ) {
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright: Red Hat Inc. and Hibernate Authors
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.boot.models.categorize.xml.internal;
|
||||
package org.hibernate.boot.models.xml.internal;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright: Red Hat Inc. and Hibernate Authors
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.boot.models.categorize.xml.internal;
|
||||
package org.hibernate.boot.models.xml.internal;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Field;
|
||||
|
@ -87,8 +87,8 @@ import org.hibernate.boot.jaxb.mapping.spi.db.JaxbColumnJoined;
|
|||
import org.hibernate.boot.jaxb.mapping.spi.db.JaxbTableMapping;
|
||||
import org.hibernate.boot.models.categorize.spi.JpaEventListener;
|
||||
import org.hibernate.boot.models.categorize.spi.JpaEventListenerStyle;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.db.ColumnProcessing;
|
||||
import org.hibernate.boot.models.categorize.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.boot.models.xml.internal.db.ColumnProcessing;
|
||||
import org.hibernate.boot.models.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.engine.spi.ExecuteUpdateResultCheckStyle;
|
||||
import org.hibernate.internal.util.KeyedConsumer;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
|
@ -846,7 +846,14 @@ public class XmlAnnotationHelper {
|
|||
memberDetails.addAnnotationUsage( annotationUsage );
|
||||
|
||||
final ClassDetailsRegistry classDetailsRegistry = xmlDocumentContext.getModelBuildingContext().getClassDetailsRegistry();
|
||||
final ClassDetails converter = classDetailsRegistry.resolveClassDetails( jaxbConvert.getConverter() );
|
||||
final ClassDetails converter;
|
||||
if ( StringHelper.isNotEmpty( jaxbConvert.getConverter() ) ) {
|
||||
converter = classDetailsRegistry.resolveClassDetails( jaxbConvert.getConverter() );
|
||||
}
|
||||
else {
|
||||
// allowable for disable-conversion
|
||||
converter = null;
|
||||
}
|
||||
annotationUsage.setAttributeValue( "converter", converter );
|
||||
annotationUsage.setAttributeValue( "attributeName", prefixIfNotAlready( jaxbConvert.getAttributeName(), namePrefix ) );
|
||||
annotationUsage.setAttributeValue( "disableConversion", jaxbConvert.isDisableConversion() );
|
||||
|
@ -1005,7 +1012,11 @@ public class XmlAnnotationHelper {
|
|||
}
|
||||
|
||||
public static ClassDetails resolveJavaType(String value, XmlDocumentContext xmlDocumentContext) {
|
||||
return resolveJavaType( value, xmlDocumentContext.getModelBuildingContext() );
|
||||
return resolveJavaType(
|
||||
xmlDocumentContext.getXmlDocument().getDefaults().getPackage(),
|
||||
value,
|
||||
xmlDocumentContext.getModelBuildingContext().getClassDetailsRegistry()
|
||||
);
|
||||
}
|
||||
|
||||
public static ClassDetails resolveJavaType(String value, SourceModelBuildingContext sourceModelBuildingContext) {
|
||||
|
@ -1013,56 +1024,63 @@ public class XmlAnnotationHelper {
|
|||
}
|
||||
|
||||
public static ClassDetails resolveJavaType(String value, ClassDetailsRegistry classDetailsRegistry) {
|
||||
if ( StringHelper.isEmpty( value ) ) {
|
||||
value = Object.class.getName();
|
||||
return resolveJavaType( null, value, classDetailsRegistry );
|
||||
}
|
||||
|
||||
public static ClassDetails resolveJavaType(String packageName, String name, ClassDetailsRegistry classDetailsRegistry) {
|
||||
if ( StringHelper.isEmpty( name ) ) {
|
||||
name = Object.class.getName();
|
||||
}
|
||||
else if ( byte.class.getName().equals( value )
|
||||
|| boolean.class.getName().equals( value )
|
||||
|| short.class.getName().equals( value )
|
||||
|| int.class.getName().equals( value )
|
||||
|| long.class.getName().equals( value )
|
||||
|| double.class.getName().equals( value )
|
||||
|| float.class.getName().equals( value ) ) {
|
||||
else if ( byte.class.getName().equals( name )
|
||||
|| boolean.class.getName().equals( name )
|
||||
|| short.class.getName().equals( name )
|
||||
|| int.class.getName().equals( name )
|
||||
|| long.class.getName().equals( name )
|
||||
|| double.class.getName().equals( name )
|
||||
|| float.class.getName().equals( name ) ) {
|
||||
// nothing to do for primitives
|
||||
}
|
||||
else if ( Byte.class.getSimpleName().equalsIgnoreCase( value ) ) {
|
||||
value = Byte.class.getName();
|
||||
else if ( Byte.class.getSimpleName().equalsIgnoreCase( name ) ) {
|
||||
name = Byte.class.getName();
|
||||
}
|
||||
else if ( Boolean.class.getSimpleName().equalsIgnoreCase( value ) ) {
|
||||
value = Boolean.class.getName();
|
||||
else if ( Boolean.class.getSimpleName().equalsIgnoreCase( name ) ) {
|
||||
name = Boolean.class.getName();
|
||||
}
|
||||
else if ( Short.class.getSimpleName().equalsIgnoreCase( value ) ) {
|
||||
value = Short.class.getName();
|
||||
else if ( Short.class.getSimpleName().equalsIgnoreCase( name ) ) {
|
||||
name = Short.class.getName();
|
||||
}
|
||||
else if ( Integer.class.getSimpleName().equalsIgnoreCase( value ) ) {
|
||||
value = Integer.class.getName();
|
||||
else if ( Integer.class.getSimpleName().equalsIgnoreCase( name ) ) {
|
||||
name = Integer.class.getName();
|
||||
}
|
||||
else if ( Long.class.getSimpleName().equalsIgnoreCase( value ) ) {
|
||||
value = Long.class.getName();
|
||||
else if ( Long.class.getSimpleName().equalsIgnoreCase( name ) ) {
|
||||
name = Long.class.getName();
|
||||
}
|
||||
else if ( Double.class.getSimpleName().equalsIgnoreCase( value ) ) {
|
||||
value = Double.class.getName();
|
||||
else if ( Double.class.getSimpleName().equalsIgnoreCase( name ) ) {
|
||||
name = Double.class.getName();
|
||||
}
|
||||
else if ( Float.class.getSimpleName().equalsIgnoreCase( value ) ) {
|
||||
value = Float.class.getName();
|
||||
else if ( Float.class.getSimpleName().equalsIgnoreCase( name ) ) {
|
||||
name = Float.class.getName();
|
||||
}
|
||||
else if ( BigInteger.class.getSimpleName().equalsIgnoreCase( value ) ) {
|
||||
value = BigInteger.class.getName();
|
||||
else if ( BigInteger.class.getSimpleName().equalsIgnoreCase( name ) ) {
|
||||
name = BigInteger.class.getName();
|
||||
}
|
||||
else if ( BigDecimal.class.getSimpleName().equalsIgnoreCase( value ) ) {
|
||||
value = BigDecimal.class.getName();
|
||||
else if ( BigDecimal.class.getSimpleName().equalsIgnoreCase( name ) ) {
|
||||
name = BigDecimal.class.getName();
|
||||
}
|
||||
else if ( String.class.getSimpleName().equalsIgnoreCase( value ) ) {
|
||||
value = String.class.getName();
|
||||
else if ( String.class.getSimpleName().equalsIgnoreCase( name ) ) {
|
||||
name = String.class.getName();
|
||||
}
|
||||
else if ( Character.class.getSimpleName().equalsIgnoreCase( value ) ) {
|
||||
value = Character.class.getName();
|
||||
else if ( Character.class.getSimpleName().equalsIgnoreCase( name ) ) {
|
||||
name = Character.class.getName();
|
||||
}
|
||||
else if ( UUID.class.getSimpleName().equalsIgnoreCase( value ) ) {
|
||||
value = Character.class.getName();
|
||||
else if ( UUID.class.getSimpleName().equalsIgnoreCase( name ) ) {
|
||||
name = Character.class.getName();
|
||||
}
|
||||
else {
|
||||
name = StringHelper.qualifyConditionallyIfNot( packageName, name );
|
||||
}
|
||||
|
||||
return classDetailsRegistry.resolveClassDetails( value );
|
||||
return classDetailsRegistry.resolveClassDetails( name );
|
||||
}
|
||||
|
||||
public static void applyBasicTypeComposition(
|
||||
|
@ -1277,8 +1295,7 @@ public class XmlAnnotationHelper {
|
|||
classDetails,
|
||||
xmlDocumentContext
|
||||
);
|
||||
final MutableClassDetails entityListenerClass = (MutableClassDetails) xmlDocumentContext.getModelBuildingContext().getClassDetailsRegistry()
|
||||
.resolveClassDetails( jaxbEntityListener.getClazz() );
|
||||
final MutableClassDetails entityListenerClass = xmlDocumentContext.resolveJavaType( jaxbEntityListener.getClazz() );
|
||||
applyLifecycleCallbacks(
|
||||
jaxbEntityListener,
|
||||
JpaEventListenerStyle.LISTENER,
|
|
@ -1,14 +1,14 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright: Red Hat Inc. and Hibernate Authors
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.boot.models.categorize.xml.internal;
|
||||
package org.hibernate.boot.models.xml.internal;
|
||||
|
||||
import org.hibernate.boot.models.categorize.xml.spi.PersistenceUnitMetadata;
|
||||
import org.hibernate.boot.models.categorize.xml.spi.XmlDocument;
|
||||
import org.hibernate.boot.models.categorize.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.boot.models.xml.spi.PersistenceUnitMetadata;
|
||||
import org.hibernate.boot.models.xml.spi.XmlDocument;
|
||||
import org.hibernate.boot.models.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.models.spi.SourceModelBuildingContext;
|
||||
|
||||
/**
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright: Red Hat Inc. and Hibernate Authors
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.boot.models.categorize.xml.internal;
|
||||
package org.hibernate.boot.models.xml.internal;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
@ -28,8 +28,8 @@ import org.hibernate.boot.jaxb.mapping.spi.JaxbNamedNativeQueryImpl;
|
|||
import org.hibernate.boot.jaxb.mapping.spi.JaxbNamedQueryImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbNamedStoredProcedureQueryImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbUserTypeRegistrationImpl;
|
||||
import org.hibernate.boot.models.categorize.xml.spi.PersistenceUnitMetadata;
|
||||
import org.hibernate.boot.models.categorize.xml.spi.XmlDocument;
|
||||
import org.hibernate.boot.models.xml.spi.PersistenceUnitMetadata;
|
||||
import org.hibernate.boot.models.xml.spi.XmlDocument;
|
||||
import org.hibernate.internal.util.NullnessHelper;
|
||||
|
||||
import jakarta.persistence.AccessType;
|
|
@ -1,16 +1,16 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright: Red Hat Inc. and Hibernate Authors
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.boot.models.categorize.xml.internal;
|
||||
package org.hibernate.boot.models.xml.internal;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityMappingsImpl;
|
||||
import org.hibernate.boot.models.categorize.xml.spi.XmlPreProcessingResult;
|
||||
import org.hibernate.boot.models.xml.spi.XmlPreProcessingResult;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
|
||||
/**
|
||||
|
@ -49,7 +49,7 @@ public class XmlPreProcessingResultImpl implements XmlPreProcessingResult {
|
|||
if ( StringHelper.isNotEmpty( jaxbEmbeddable.getClazz() ) ) {
|
||||
managedClasses.add( XmlProcessingHelper.determineClassName( document, jaxbEmbeddable ) );
|
||||
}
|
||||
if ( StringHelper.isNotEmpty( jaxbEmbeddable.getName() ) ) {
|
||||
else if ( StringHelper.isNotEmpty( jaxbEmbeddable.getName() ) ) {
|
||||
managedNames.add( jaxbEmbeddable.getName() );
|
||||
}
|
||||
} );
|
||||
|
@ -60,7 +60,7 @@ public class XmlPreProcessingResultImpl implements XmlPreProcessingResult {
|
|||
if ( StringHelper.isNotEmpty( jaxbEntity.getClazz() ) ) {
|
||||
managedClasses.add( XmlProcessingHelper.determineClassName( document, jaxbEntity ) );
|
||||
}
|
||||
if ( StringHelper.isNotEmpty( jaxbEntity.getName() ) ) {
|
||||
else if ( StringHelper.isNotEmpty( jaxbEntity.getName() ) ) {
|
||||
managedNames.add( jaxbEntity.getName() );
|
||||
}
|
||||
} );
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright: Red Hat Inc. and Hibernate Authors
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.boot.models.categorize.xml.internal;
|
||||
package org.hibernate.boot.models.xml.internal;
|
||||
|
||||
import java.beans.Introspector;
|
||||
import java.lang.annotation.Annotation;
|
||||
|
@ -12,7 +12,7 @@ import java.lang.annotation.Annotation;
|
|||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityMappingsImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbManagedType;
|
||||
import org.hibernate.boot.models.MemberResolutionException;
|
||||
import org.hibernate.boot.models.categorize.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.boot.models.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.models.internal.MutableAnnotationTarget;
|
||||
import org.hibernate.models.internal.MutableAnnotationUsage;
|
||||
|
@ -38,12 +38,7 @@ public class XmlProcessingHelper {
|
|||
* @param jaxbManagedType The class JAXB node
|
||||
*/
|
||||
public static String determineClassName(JaxbEntityMappingsImpl jaxbRoot, JaxbManagedType jaxbManagedType) {
|
||||
// if ( StringHelper.isQualified( jaxbManagedType.getClazz() ) ) {
|
||||
if ( jaxbManagedType.getClazz().lastIndexOf( '.' ) > 0 ) {
|
||||
return jaxbManagedType.getClazz();
|
||||
}
|
||||
|
||||
return StringHelper.qualify( jaxbRoot.getPackage(), jaxbManagedType.getClazz() );
|
||||
return StringHelper.qualifyConditionallyIfNot( jaxbRoot.getPackage(), jaxbManagedType.getClazz() );
|
||||
}
|
||||
|
||||
public static AccessType inverse(AccessType accessType) {
|
||||
|
@ -102,8 +97,7 @@ public class XmlProcessingHelper {
|
|||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
assert accessType == AccessType.FIELD;
|
||||
else if ( accessType == AccessType.FIELD ) {
|
||||
for ( int i = 0; i < classDetails.getFields().size(); i++ ) {
|
||||
final FieldDetails fieldDetails = classDetails.getFields().get( i );
|
||||
if ( fieldDetails.getName().equals( attributeName ) ) {
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright: Red Hat Inc. and Hibernate Authors
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.boot.models.categorize.xml.internal;
|
||||
package org.hibernate.boot.models.xml.internal;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -12,8 +12,8 @@ import java.util.List;
|
|||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEmbeddableImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbMappedSuperclassImpl;
|
||||
import org.hibernate.boot.models.categorize.xml.spi.PersistenceUnitMetadata;
|
||||
import org.hibernate.boot.models.categorize.xml.spi.XmlProcessingResult;
|
||||
import org.hibernate.boot.models.xml.spi.PersistenceUnitMetadata;
|
||||
import org.hibernate.boot.models.xml.spi.XmlProcessingResult;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright: Red Hat Inc. and Hibernate Authors
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.boot.models.categorize.xml.internal.attr;
|
||||
package org.hibernate.boot.models.xml.internal.attr;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -19,9 +19,9 @@ import org.hibernate.boot.jaxb.mapping.spi.JaxbAnyMappingImpl;
|
|||
import org.hibernate.boot.jaxb.mapping.spi.JaxbAnyMappingKeyImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbColumnImpl;
|
||||
import org.hibernate.boot.internal.AnyKeyType;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.XmlProcessingHelper;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.db.ColumnProcessing;
|
||||
import org.hibernate.boot.models.categorize.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.boot.models.xml.internal.XmlProcessingHelper;
|
||||
import org.hibernate.boot.models.xml.internal.db.ColumnProcessing;
|
||||
import org.hibernate.boot.models.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||
import org.hibernate.models.internal.MutableAnnotationUsage;
|
|
@ -1,17 +1,17 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright: Red Hat Inc. and Hibernate Authors
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.boot.models.categorize.xml.internal.attr;
|
||||
package org.hibernate.boot.models.xml.internal.attr;
|
||||
|
||||
import org.hibernate.annotations.Formula;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbBasicImpl;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.XmlAnnotationHelper;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.XmlProcessingHelper;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.db.ColumnProcessing;
|
||||
import org.hibernate.boot.models.categorize.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.boot.models.xml.internal.XmlAnnotationHelper;
|
||||
import org.hibernate.boot.models.xml.internal.XmlProcessingHelper;
|
||||
import org.hibernate.boot.models.xml.internal.db.ColumnProcessing;
|
||||
import org.hibernate.boot.models.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.models.internal.MutableAnnotationUsage;
|
||||
import org.hibernate.models.internal.MutableClassDetails;
|
|
@ -1,15 +1,15 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright: Red Hat Inc. and Hibernate Authors
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.boot.models.categorize.xml.internal.attr;
|
||||
package org.hibernate.boot.models.xml.internal.attr;
|
||||
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbIdImpl;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.XmlAnnotationHelper;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.XmlProcessingHelper;
|
||||
import org.hibernate.boot.models.categorize.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.boot.models.xml.internal.XmlAnnotationHelper;
|
||||
import org.hibernate.boot.models.xml.internal.XmlProcessingHelper;
|
||||
import org.hibernate.boot.models.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.models.internal.MutableAnnotationUsage;
|
||||
import org.hibernate.models.internal.MutableClassDetails;
|
||||
import org.hibernate.models.internal.MutableMemberDetails;
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright: Red Hat Inc. and Hibernate Authors
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.boot.models.categorize.xml.internal.attr;
|
||||
package org.hibernate.boot.models.xml.internal.attr;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
|
||||
|
@ -18,8 +18,8 @@ import org.hibernate.boot.jaxb.mapping.spi.JaxbPersistentAttribute;
|
|||
import org.hibernate.boot.jaxb.mapping.spi.JaxbSingularAssociationAttribute;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbSingularFetchModeImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbStandardAttribute;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.XmlProcessingHelper;
|
||||
import org.hibernate.boot.models.categorize.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.boot.models.xml.internal.XmlProcessingHelper;
|
||||
import org.hibernate.boot.models.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.models.internal.MutableAnnotationUsage;
|
||||
import org.hibernate.models.internal.MutableMemberDetails;
|
||||
import org.hibernate.models.spi.ClassDetails;
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright: Red Hat Inc. and Hibernate Authors
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.boot.models.categorize.xml.internal.attr;
|
||||
package org.hibernate.boot.models.xml.internal.attr;
|
||||
|
||||
import org.hibernate.annotations.Bag;
|
||||
import org.hibernate.annotations.Fetch;
|
||||
|
@ -19,8 +19,9 @@ import org.hibernate.boot.internal.LimitedCollectionClassification;
|
|||
import org.hibernate.boot.jaxb.mapping.spi.JaxbMapKeyImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbOrderColumnImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbPluralAttribute;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.XmlAnnotationHelper;
|
||||
import org.hibernate.boot.models.categorize.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.boot.models.xml.internal.XmlAnnotationHelper;
|
||||
import org.hibernate.boot.models.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.boot.models.xml.internal.XmlProcessingHelper;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.models.internal.MutableAnnotationUsage;
|
||||
import org.hibernate.models.internal.MutableMemberDetails;
|
||||
|
@ -36,8 +37,7 @@ import jakarta.persistence.MapKeyTemporal;
|
|||
import jakarta.persistence.OrderBy;
|
||||
import jakarta.persistence.OrderColumn;
|
||||
|
||||
import static org.hibernate.boot.models.categorize.xml.internal.XmlAnnotationHelper.applyOr;
|
||||
import static org.hibernate.boot.models.categorize.xml.internal.XmlProcessingHelper.getOrMakeAnnotation;
|
||||
import static org.hibernate.boot.models.xml.internal.XmlAnnotationHelper.applyOr;
|
||||
|
||||
/**
|
||||
* @author Marco Belladelli
|
||||
|
@ -51,19 +51,19 @@ public class CommonPluralAttributeProcessing {
|
|||
final ClassDetailsRegistry classDetailsRegistry = buildingContext.getClassDetailsRegistry();
|
||||
|
||||
if ( jaxbPluralAttribute.getFetchMode() != null ) {
|
||||
final MutableAnnotationUsage<Fetch> fetchAnn = getOrMakeAnnotation( Fetch.class, memberDetails, xmlDocumentContext );
|
||||
final MutableAnnotationUsage<Fetch> fetchAnn = XmlProcessingHelper.getOrMakeAnnotation( Fetch.class, memberDetails, xmlDocumentContext );
|
||||
fetchAnn.setAttributeValue( "value", jaxbPluralAttribute.getFetchMode() );
|
||||
}
|
||||
|
||||
if ( jaxbPluralAttribute.getClassification() != null ) {
|
||||
final MutableAnnotationUsage<CollectionClassification> collectionClassificationAnn = getOrMakeAnnotation(
|
||||
final MutableAnnotationUsage<CollectionClassification> collectionClassificationAnn = XmlProcessingHelper.getOrMakeAnnotation(
|
||||
CollectionClassification.class,
|
||||
memberDetails,
|
||||
xmlDocumentContext
|
||||
);
|
||||
collectionClassificationAnn.setAttributeValue( "value", jaxbPluralAttribute.getClassification() );
|
||||
if ( jaxbPluralAttribute.getClassification() == LimitedCollectionClassification.BAG ) {
|
||||
getOrMakeAnnotation( Bag.class, memberDetails, xmlDocumentContext );
|
||||
XmlProcessingHelper.getOrMakeAnnotation( Bag.class, memberDetails, xmlDocumentContext );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ public class CommonPluralAttributeProcessing {
|
|||
XmlAnnotationHelper.applyCollectionId( jaxbPluralAttribute.getCollectionId(), memberDetails, xmlDocumentContext );
|
||||
|
||||
if ( StringHelper.isNotEmpty( jaxbPluralAttribute.getOrderBy() ) ) {
|
||||
final MutableAnnotationUsage<OrderBy> orderByAnn = getOrMakeAnnotation(
|
||||
final MutableAnnotationUsage<OrderBy> orderByAnn = XmlProcessingHelper.getOrMakeAnnotation(
|
||||
OrderBy.class,
|
||||
memberDetails,
|
||||
xmlDocumentContext
|
||||
|
@ -86,7 +86,7 @@ public class CommonPluralAttributeProcessing {
|
|||
applyOrderColumn( jaxbPluralAttribute, memberDetails, xmlDocumentContext );
|
||||
|
||||
if ( StringHelper.isNotEmpty( jaxbPluralAttribute.getSort() ) ) {
|
||||
final MutableAnnotationUsage<SortComparator> sortAnn = getOrMakeAnnotation(
|
||||
final MutableAnnotationUsage<SortComparator> sortAnn = XmlProcessingHelper.getOrMakeAnnotation(
|
||||
SortComparator.class,
|
||||
memberDetails,
|
||||
xmlDocumentContext
|
||||
|
@ -96,14 +96,14 @@ public class CommonPluralAttributeProcessing {
|
|||
}
|
||||
|
||||
if ( jaxbPluralAttribute.getSortNatural() != null ) {
|
||||
getOrMakeAnnotation( SortNatural.class, memberDetails, xmlDocumentContext );
|
||||
XmlProcessingHelper.getOrMakeAnnotation( SortNatural.class, memberDetails, xmlDocumentContext );
|
||||
}
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// map-key
|
||||
|
||||
if ( jaxbPluralAttribute.getMapKey() != null ) {
|
||||
final MutableAnnotationUsage<MapKey> mapKeyAnn = getOrMakeAnnotation( MapKey.class, memberDetails, xmlDocumentContext );
|
||||
final MutableAnnotationUsage<MapKey> mapKeyAnn = XmlProcessingHelper.getOrMakeAnnotation( MapKey.class, memberDetails, xmlDocumentContext );
|
||||
applyOr(
|
||||
jaxbPluralAttribute.getMapKey(),
|
||||
JaxbMapKeyImpl::getName,
|
||||
|
@ -115,18 +115,18 @@ public class CommonPluralAttributeProcessing {
|
|||
|
||||
if ( jaxbPluralAttribute.getMapKeyClass() != null ) {
|
||||
final ClassDetails mapKeyClass = classDetailsRegistry.resolveClassDetails( jaxbPluralAttribute.getMapKeyClass().getClazz() );
|
||||
getOrMakeAnnotation( MapKeyClass.class, memberDetails, xmlDocumentContext ).setAttributeValue( "value", mapKeyClass );
|
||||
XmlProcessingHelper.getOrMakeAnnotation( MapKeyClass.class, memberDetails, xmlDocumentContext ).setAttributeValue( "value", mapKeyClass );
|
||||
}
|
||||
|
||||
if ( jaxbPluralAttribute.getMapKeyTemporal() != null ) {
|
||||
getOrMakeAnnotation( MapKeyTemporal.class, memberDetails, xmlDocumentContext ).setAttributeValue(
|
||||
XmlProcessingHelper.getOrMakeAnnotation( MapKeyTemporal.class, memberDetails, xmlDocumentContext ).setAttributeValue(
|
||||
"value",
|
||||
jaxbPluralAttribute.getMapKeyTemporal()
|
||||
);
|
||||
}
|
||||
|
||||
if ( jaxbPluralAttribute.getMapKeyEnumerated() != null ) {
|
||||
getOrMakeAnnotation( MapKeyEnumerated.class, memberDetails, xmlDocumentContext ).setAttributeValue(
|
||||
XmlProcessingHelper.getOrMakeAnnotation( MapKeyEnumerated.class, memberDetails, xmlDocumentContext ).setAttributeValue(
|
||||
"value",
|
||||
jaxbPluralAttribute.getMapKeyEnumerated()
|
||||
);
|
||||
|
@ -175,7 +175,7 @@ public class CommonPluralAttributeProcessing {
|
|||
return;
|
||||
}
|
||||
|
||||
final MutableAnnotationUsage<OrderColumn> orderColumnAnn = getOrMakeAnnotation(
|
||||
final MutableAnnotationUsage<OrderColumn> orderColumnAnn = XmlProcessingHelper.getOrMakeAnnotation(
|
||||
OrderColumn.class,
|
||||
memberDetails,
|
||||
xmlDocumentContext
|
|
@ -1,17 +1,17 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright: Red Hat Inc. and Hibernate Authors
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.boot.models.categorize.xml.internal.attr;
|
||||
package org.hibernate.boot.models.xml.internal.attr;
|
||||
|
||||
import org.hibernate.boot.internal.Target;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbCollectionTableImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbElementCollectionImpl;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.XmlAnnotationHelper;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.XmlProcessingHelper;
|
||||
import org.hibernate.boot.models.categorize.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.boot.models.xml.internal.XmlAnnotationHelper;
|
||||
import org.hibernate.boot.models.xml.internal.XmlProcessingHelper;
|
||||
import org.hibernate.boot.models.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.models.internal.MutableAnnotationUsage;
|
||||
import org.hibernate.models.internal.MutableClassDetails;
|
||||
|
@ -22,11 +22,7 @@ import jakarta.persistence.AccessType;
|
|||
import jakarta.persistence.CollectionTable;
|
||||
import jakarta.persistence.ElementCollection;
|
||||
|
||||
import static org.hibernate.boot.models.categorize.xml.internal.XmlAnnotationHelper.applyIndexes;
|
||||
import static org.hibernate.boot.models.categorize.xml.internal.XmlAnnotationHelper.applyOr;
|
||||
import static org.hibernate.boot.models.categorize.xml.internal.XmlAnnotationHelper.applyUniqueConstraints;
|
||||
import static org.hibernate.boot.models.categorize.xml.internal.XmlAnnotationHelper.createForeignKeyAnnotation;
|
||||
import static org.hibernate.boot.models.categorize.xml.internal.XmlAnnotationHelper.createJoinColumns;
|
||||
import static org.hibernate.boot.models.xml.internal.XmlAnnotationHelper.applyOr;
|
||||
import static org.hibernate.internal.util.NullnessHelper.coalesce;
|
||||
|
||||
/**
|
||||
|
@ -111,21 +107,21 @@ public class ElementCollectionAttributeProcessing {
|
|||
.getAnnotationDescriptorRegistry()
|
||||
.getDescriptor( CollectionTable.class );
|
||||
|
||||
applyOr( jaxbCollectionTable, JaxbCollectionTableImpl::getName, "name", collectionTableAnn, collectionTableDescriptor );
|
||||
applyOr( jaxbCollectionTable, JaxbCollectionTableImpl::getSchema, "schema", collectionTableAnn, collectionTableDescriptor );
|
||||
applyOr( jaxbCollectionTable, JaxbCollectionTableImpl::getOptions, "options", collectionTableAnn, collectionTableDescriptor );
|
||||
XmlAnnotationHelper.applyOr( jaxbCollectionTable, JaxbCollectionTableImpl::getName, "name", collectionTableAnn, collectionTableDescriptor );
|
||||
XmlAnnotationHelper.applyOr( jaxbCollectionTable, JaxbCollectionTableImpl::getSchema, "schema", collectionTableAnn, collectionTableDescriptor );
|
||||
XmlAnnotationHelper.applyOr( jaxbCollectionTable, JaxbCollectionTableImpl::getOptions, "options", collectionTableAnn, collectionTableDescriptor );
|
||||
|
||||
collectionTableAnn.setAttributeValue( "joinColumns", createJoinColumns( jaxbCollectionTable.getJoinColumns(), memberDetails, xmlDocumentContext ) );
|
||||
collectionTableAnn.setAttributeValue( "joinColumns", XmlAnnotationHelper.createJoinColumns( jaxbCollectionTable.getJoinColumns(), memberDetails, xmlDocumentContext ) );
|
||||
|
||||
if ( jaxbCollectionTable.getForeignKeys() != null ) {
|
||||
collectionTableAnn.setAttributeValue(
|
||||
"foreignKey",
|
||||
createForeignKeyAnnotation( jaxbCollectionTable.getForeignKeys(), memberDetails, xmlDocumentContext )
|
||||
XmlAnnotationHelper.createForeignKeyAnnotation( jaxbCollectionTable.getForeignKeys(), memberDetails, xmlDocumentContext )
|
||||
);
|
||||
}
|
||||
|
||||
applyUniqueConstraints( jaxbCollectionTable.getUniqueConstraints(), memberDetails, collectionTableAnn, xmlDocumentContext );
|
||||
XmlAnnotationHelper.applyUniqueConstraints( jaxbCollectionTable.getUniqueConstraints(), memberDetails, collectionTableAnn, xmlDocumentContext );
|
||||
|
||||
applyIndexes( jaxbCollectionTable.getIndexes(), memberDetails, collectionTableAnn, xmlDocumentContext );
|
||||
XmlAnnotationHelper.applyIndexes( jaxbCollectionTable.getIndexes(), memberDetails, collectionTableAnn, xmlDocumentContext );
|
||||
}
|
||||
}
|
|
@ -1,16 +1,16 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright: Red Hat Inc. and Hibernate Authors
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.boot.models.categorize.xml.internal.attr;
|
||||
package org.hibernate.boot.models.xml.internal.attr;
|
||||
|
||||
import org.hibernate.boot.internal.Target;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEmbeddedImpl;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.XmlAnnotationHelper;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.XmlProcessingHelper;
|
||||
import org.hibernate.boot.models.categorize.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.boot.models.xml.internal.XmlAnnotationHelper;
|
||||
import org.hibernate.boot.models.xml.internal.XmlProcessingHelper;
|
||||
import org.hibernate.boot.models.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.models.internal.MutableAnnotationUsage;
|
||||
import org.hibernate.models.internal.MutableClassDetails;
|
||||
|
@ -19,7 +19,7 @@ import org.hibernate.models.internal.MutableMemberDetails;
|
|||
import jakarta.persistence.AccessType;
|
||||
import jakarta.persistence.Embedded;
|
||||
|
||||
import static org.hibernate.boot.models.categorize.xml.internal.attr.CommonAttributeProcessing.applyAttributeBasics;
|
||||
import static org.hibernate.boot.models.xml.internal.attr.CommonAttributeProcessing.applyAttributeBasics;
|
||||
import static org.hibernate.internal.util.NullnessHelper.coalesce;
|
||||
|
||||
/**
|
|
@ -1,15 +1,15 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright: Red Hat Inc. and Hibernate Authors
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.boot.models.categorize.xml.internal.attr;
|
||||
package org.hibernate.boot.models.xml.internal.attr;
|
||||
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEmbeddedIdImpl;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.XmlAnnotationHelper;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.XmlProcessingHelper;
|
||||
import org.hibernate.boot.models.categorize.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.boot.models.xml.internal.XmlAnnotationHelper;
|
||||
import org.hibernate.boot.models.xml.internal.XmlProcessingHelper;
|
||||
import org.hibernate.boot.models.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.models.internal.MutableAnnotationUsage;
|
||||
import org.hibernate.models.internal.MutableClassDetails;
|
||||
import org.hibernate.models.internal.MutableMemberDetails;
|
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.boot.models.xml.internal.attr;
|
||||
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbManyToManyImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbOneToManyImpl;
|
||||
import org.hibernate.boot.models.xml.internal.XmlAnnotationHelper;
|
||||
import org.hibernate.boot.models.xml.internal.XmlProcessingHelper;
|
||||
import org.hibernate.boot.models.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.models.internal.MutableAnnotationUsage;
|
||||
import org.hibernate.models.internal.MutableClassDetails;
|
||||
import org.hibernate.models.internal.MutableMemberDetails;
|
||||
import org.hibernate.models.spi.AnnotationDescriptor;
|
||||
|
||||
import jakarta.persistence.AccessType;
|
||||
import jakarta.persistence.ManyToMany;
|
||||
import jakarta.persistence.OneToMany;
|
||||
|
||||
import static org.hibernate.boot.models.xml.internal.XmlProcessingHelper.getOrMakeAnnotation;
|
||||
import static org.hibernate.internal.util.NullnessHelper.coalesce;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class ManyToManyAttributeProcessing {
|
||||
|
||||
@SuppressWarnings("UnusedReturnValue")
|
||||
public static MutableMemberDetails processManyToManyAttribute(
|
||||
JaxbManyToManyImpl jaxbManyToMany,
|
||||
MutableClassDetails declarer,
|
||||
AccessType classAccessType,
|
||||
XmlDocumentContext xmlDocumentContext) {
|
||||
final AccessType accessType = coalesce( jaxbManyToMany.getAccess(), classAccessType );
|
||||
final MutableMemberDetails memberDetails = XmlProcessingHelper.getAttributeMember(
|
||||
jaxbManyToMany.getName(),
|
||||
accessType,
|
||||
declarer
|
||||
);
|
||||
|
||||
final MutableAnnotationUsage<ManyToMany> manyToManyAnn = applyManyToMany(
|
||||
jaxbManyToMany,
|
||||
memberDetails,
|
||||
xmlDocumentContext
|
||||
);
|
||||
|
||||
applyTargetEntity( jaxbManyToMany, manyToManyAnn, xmlDocumentContext );
|
||||
|
||||
XmlAnnotationHelper.applyCascading( jaxbManyToMany.getCascade(), memberDetails, xmlDocumentContext );
|
||||
|
||||
CommonAttributeProcessing.applyAttributeBasics( jaxbManyToMany, memberDetails, manyToManyAnn, accessType, xmlDocumentContext );
|
||||
|
||||
CommonPluralAttributeProcessing.applyPluralAttributeStructure( jaxbManyToMany, memberDetails, xmlDocumentContext );
|
||||
|
||||
return memberDetails;
|
||||
}
|
||||
|
||||
private static MutableAnnotationUsage<ManyToMany> applyManyToMany(
|
||||
JaxbManyToManyImpl jaxbManyToMany,
|
||||
MutableMemberDetails memberDetails,
|
||||
XmlDocumentContext xmlDocumentContext) {
|
||||
final MutableAnnotationUsage<ManyToMany> manyToManyAnn = getOrMakeAnnotation(
|
||||
ManyToMany.class,
|
||||
memberDetails,
|
||||
xmlDocumentContext
|
||||
);
|
||||
final AnnotationDescriptor<ManyToMany> manyToManyDescriptor = xmlDocumentContext
|
||||
.getModelBuildingContext()
|
||||
.getAnnotationDescriptorRegistry()
|
||||
.getDescriptor( ManyToMany.class );
|
||||
|
||||
XmlAnnotationHelper.applyOr( jaxbManyToMany, JaxbManyToManyImpl::getFetch, "fetch", manyToManyAnn, manyToManyDescriptor );
|
||||
XmlAnnotationHelper.applyOr( jaxbManyToMany, JaxbManyToManyImpl::getMappedBy, "mappedBy", manyToManyAnn, manyToManyDescriptor );
|
||||
|
||||
return manyToManyAnn;
|
||||
}
|
||||
|
||||
private static void applyTargetEntity(
|
||||
JaxbManyToManyImpl jaxbManyToMany,
|
||||
MutableAnnotationUsage<ManyToMany> manyToManyAnn,
|
||||
XmlDocumentContext xmlDocumentContext) {
|
||||
final String targetEntity = jaxbManyToMany.getTargetEntity();
|
||||
if ( StringHelper.isNotEmpty( targetEntity ) ) {
|
||||
manyToManyAnn.setAttributeValue(
|
||||
"targetEntity",
|
||||
xmlDocumentContext.getModelBuildingContext()
|
||||
.getClassDetailsRegistry()
|
||||
.resolveClassDetails( targetEntity )
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright: Red Hat Inc. and Hibernate Authors
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.boot.models.categorize.xml.internal.attr;
|
||||
package org.hibernate.boot.models.xml.internal.attr;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
@ -15,9 +15,9 @@ import org.hibernate.annotations.OnDelete;
|
|||
import org.hibernate.annotations.OnDeleteAction;
|
||||
import org.hibernate.boot.internal.Target;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbManyToOneImpl;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.XmlAnnotationHelper;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.XmlProcessingHelper;
|
||||
import org.hibernate.boot.models.categorize.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.boot.models.xml.internal.XmlAnnotationHelper;
|
||||
import org.hibernate.boot.models.xml.internal.XmlProcessingHelper;
|
||||
import org.hibernate.boot.models.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||
import org.hibernate.models.internal.MutableAnnotationUsage;
|
||||
|
@ -28,8 +28,6 @@ import org.hibernate.models.spi.AnnotationDescriptor;
|
|||
import jakarta.persistence.AccessType;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
|
||||
import static org.hibernate.boot.models.categorize.xml.internal.XmlAnnotationHelper.applyCascading;
|
||||
import static org.hibernate.boot.models.categorize.xml.internal.XmlAnnotationHelper.applyJoinColumns;
|
||||
import static org.hibernate.internal.util.NullnessHelper.coalesce;
|
||||
|
||||
/**
|
||||
|
@ -57,11 +55,11 @@ public class ManyToOneAttributeProcessing {
|
|||
|
||||
CommonAttributeProcessing.applyAttributeBasics( jaxbManyToOne, memberDetails, manyToOneAnn, accessType, xmlDocumentContext );
|
||||
|
||||
applyJoinColumns( jaxbManyToOne.getJoinColumns(), memberDetails, xmlDocumentContext );
|
||||
XmlAnnotationHelper.applyJoinColumns( jaxbManyToOne.getJoinColumns(), memberDetails, xmlDocumentContext );
|
||||
applyNotFound( memberDetails, jaxbManyToOne, manyToOneAnn, xmlDocumentContext );
|
||||
applyOnDelete( memberDetails, jaxbManyToOne, manyToOneAnn, xmlDocumentContext );
|
||||
applyTarget( memberDetails, jaxbManyToOne, manyToOneAnn, xmlDocumentContext );
|
||||
applyCascading( jaxbManyToOne.getCascade(), memberDetails, xmlDocumentContext );
|
||||
XmlAnnotationHelper.applyCascading( jaxbManyToOne.getCascade(), memberDetails, xmlDocumentContext );
|
||||
|
||||
return memberDetails;
|
||||
}
|
||||
|
@ -70,8 +68,6 @@ public class ManyToOneAttributeProcessing {
|
|||
MutableMemberDetails memberDetails,
|
||||
JaxbManyToOneImpl jaxbManyToOne,
|
||||
XmlDocumentContext xmlDocumentContext) {
|
||||
// todo : apply the @ManyToOne annotation
|
||||
|
||||
final MutableAnnotationUsage<ManyToOne> manyToOneAnn = XmlProcessingHelper.getOrMakeAnnotation( ManyToOne.class, memberDetails, xmlDocumentContext );
|
||||
final AnnotationDescriptor<ManyToOne> manyToOneDescriptor = xmlDocumentContext
|
||||
.getModelBuildingContext()
|
|
@ -1,17 +1,17 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright: Red Hat Inc. and Hibernate Authors
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.boot.models.categorize.xml.internal.attr;
|
||||
package org.hibernate.boot.models.xml.internal.attr;
|
||||
|
||||
import org.hibernate.annotations.NotFound;
|
||||
import org.hibernate.annotations.OnDelete;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbOneToManyImpl;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.XmlAnnotationHelper;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.XmlProcessingHelper;
|
||||
import org.hibernate.boot.models.categorize.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.boot.models.xml.internal.XmlAnnotationHelper;
|
||||
import org.hibernate.boot.models.xml.internal.XmlProcessingHelper;
|
||||
import org.hibernate.boot.models.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.models.internal.MutableAnnotationUsage;
|
||||
import org.hibernate.models.internal.MutableClassDetails;
|
||||
|
@ -21,8 +21,6 @@ import org.hibernate.models.spi.AnnotationDescriptor;
|
|||
import jakarta.persistence.AccessType;
|
||||
import jakarta.persistence.OneToMany;
|
||||
|
||||
import static org.hibernate.boot.models.categorize.xml.internal.XmlAnnotationHelper.applyOr;
|
||||
import static org.hibernate.boot.models.categorize.xml.internal.XmlProcessingHelper.getOrMakeAnnotation;
|
||||
import static org.hibernate.internal.util.NullnessHelper.coalesce;
|
||||
|
||||
/**
|
||||
|
@ -41,7 +39,7 @@ public class OneToManyAttributeProcessing {
|
|||
declarer
|
||||
);
|
||||
|
||||
final MutableAnnotationUsage<OneToMany> oneToManyAnn = applyManyToOne(
|
||||
final MutableAnnotationUsage<OneToMany> oneToManyAnn = applyOneToMany(
|
||||
jaxbOneToMany,
|
||||
memberDetails,
|
||||
xmlDocumentContext
|
||||
|
@ -74,29 +72,29 @@ public class OneToManyAttributeProcessing {
|
|||
} );
|
||||
|
||||
if ( jaxbOneToMany.getOnDelete() != null ) {
|
||||
getOrMakeAnnotation( OnDelete.class, memberDetails, xmlDocumentContext ).setAttributeValue( "action", jaxbOneToMany.getOnDelete() );
|
||||
XmlProcessingHelper.getOrMakeAnnotation( OnDelete.class, memberDetails, xmlDocumentContext ).setAttributeValue( "action", jaxbOneToMany.getOnDelete() );
|
||||
}
|
||||
|
||||
if ( jaxbOneToMany.getNotFound() != null ) {
|
||||
getOrMakeAnnotation( NotFound.class, memberDetails, xmlDocumentContext ).setAttributeValue( "action", jaxbOneToMany.getNotFound() );
|
||||
XmlProcessingHelper.getOrMakeAnnotation( NotFound.class, memberDetails, xmlDocumentContext ).setAttributeValue( "action", jaxbOneToMany.getNotFound() );
|
||||
}
|
||||
|
||||
return memberDetails;
|
||||
}
|
||||
|
||||
private static MutableAnnotationUsage<OneToMany> applyManyToOne(
|
||||
private static MutableAnnotationUsage<OneToMany> applyOneToMany(
|
||||
JaxbOneToManyImpl jaxbOneToMany,
|
||||
MutableMemberDetails memberDetails,
|
||||
XmlDocumentContext xmlDocumentContext) {
|
||||
final MutableAnnotationUsage<OneToMany> oneToManyAnn = getOrMakeAnnotation( OneToMany.class, memberDetails, xmlDocumentContext );
|
||||
final MutableAnnotationUsage<OneToMany> oneToManyAnn = XmlProcessingHelper.getOrMakeAnnotation( OneToMany.class, memberDetails, xmlDocumentContext );
|
||||
final AnnotationDescriptor<OneToMany> oneToManyDescriptor = xmlDocumentContext
|
||||
.getModelBuildingContext()
|
||||
.getAnnotationDescriptorRegistry()
|
||||
.getDescriptor( OneToMany.class );
|
||||
|
||||
applyOr( jaxbOneToMany, JaxbOneToManyImpl::getFetch, "fetch", oneToManyAnn, oneToManyDescriptor );
|
||||
applyOr( jaxbOneToMany, JaxbOneToManyImpl::getMappedBy, "mappedBy", oneToManyAnn, oneToManyDescriptor );
|
||||
applyOr( jaxbOneToMany, JaxbOneToManyImpl::isOrphanRemoval, "orphanRemoval", oneToManyAnn, oneToManyDescriptor );
|
||||
XmlAnnotationHelper.applyOr( jaxbOneToMany, JaxbOneToManyImpl::getFetch, "fetch", oneToManyAnn, oneToManyDescriptor );
|
||||
XmlAnnotationHelper.applyOr( jaxbOneToMany, JaxbOneToManyImpl::getMappedBy, "mappedBy", oneToManyAnn, oneToManyDescriptor );
|
||||
XmlAnnotationHelper.applyOr( jaxbOneToMany, JaxbOneToManyImpl::isOrphanRemoval, "orphanRemoval", oneToManyAnn, oneToManyDescriptor );
|
||||
|
||||
return oneToManyAnn;
|
||||
}
|
||||
|
@ -109,9 +107,7 @@ public class OneToManyAttributeProcessing {
|
|||
if ( StringHelper.isNotEmpty( targetEntity ) ) {
|
||||
oneToManyAnn.setAttributeValue(
|
||||
"targetEntity",
|
||||
xmlDocumentContext.getModelBuildingContext()
|
||||
.getClassDetailsRegistry()
|
||||
.resolveClassDetails( targetEntity )
|
||||
xmlDocumentContext.resolveJavaType( targetEntity )
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.boot.models.xml.internal.attr;
|
||||
|
||||
import org.hibernate.boot.internal.Target;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbOneToOneImpl;
|
||||
import org.hibernate.boot.models.xml.internal.XmlAnnotationHelper;
|
||||
import org.hibernate.boot.models.xml.internal.XmlProcessingHelper;
|
||||
import org.hibernate.boot.models.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.models.internal.MutableAnnotationUsage;
|
||||
import org.hibernate.models.internal.MutableClassDetails;
|
||||
import org.hibernate.models.internal.MutableMemberDetails;
|
||||
import org.hibernate.models.spi.AnnotationDescriptor;
|
||||
|
||||
import jakarta.persistence.AccessType;
|
||||
import jakarta.persistence.OneToOne;
|
||||
|
||||
import static org.hibernate.boot.models.xml.internal.XmlAnnotationHelper.applyCascading;
|
||||
import static org.hibernate.boot.models.xml.internal.XmlProcessingHelper.getOrMakeAnnotation;
|
||||
import static org.hibernate.boot.models.xml.internal.attr.CommonAttributeProcessing.applyAttributeBasics;
|
||||
import static org.hibernate.internal.util.NullnessHelper.coalesce;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class OneToOneAttributeProcessing {
|
||||
|
||||
@SuppressWarnings("UnusedReturnValue")
|
||||
public static MutableMemberDetails processOneToOneAttribute(
|
||||
JaxbOneToOneImpl jaxbOneToOne,
|
||||
MutableClassDetails declarer,
|
||||
AccessType classAccessType,
|
||||
XmlDocumentContext xmlDocumentContext) {
|
||||
final AccessType accessType = coalesce( jaxbOneToOne.getAccess(), classAccessType );
|
||||
final MutableMemberDetails memberDetails = XmlProcessingHelper.getAttributeMember(
|
||||
jaxbOneToOne.getName(),
|
||||
accessType,
|
||||
declarer
|
||||
);
|
||||
|
||||
final MutableAnnotationUsage<OneToOne> oneToOneAnn = applyOneToOne(
|
||||
memberDetails,
|
||||
jaxbOneToOne,
|
||||
xmlDocumentContext
|
||||
);
|
||||
|
||||
applyAttributeBasics( jaxbOneToOne, memberDetails, oneToOneAnn, accessType, xmlDocumentContext );
|
||||
applyTarget( memberDetails, jaxbOneToOne, oneToOneAnn, xmlDocumentContext );
|
||||
applyCascading( jaxbOneToOne.getCascade(), memberDetails, xmlDocumentContext );
|
||||
|
||||
return memberDetails;
|
||||
}
|
||||
|
||||
private static MutableAnnotationUsage<OneToOne> applyOneToOne(
|
||||
MutableMemberDetails memberDetails,
|
||||
JaxbOneToOneImpl jaxbOneToOne,
|
||||
XmlDocumentContext xmlDocumentContext) {
|
||||
final MutableAnnotationUsage<OneToOne> oneToOneAnn = getOrMakeAnnotation( OneToOne.class, memberDetails, xmlDocumentContext );
|
||||
final AnnotationDescriptor<OneToOne> oneToOneDescriptor = xmlDocumentContext
|
||||
.getModelBuildingContext()
|
||||
.getAnnotationDescriptorRegistry()
|
||||
.getDescriptor( OneToOne.class );
|
||||
|
||||
XmlAnnotationHelper.applyOr(
|
||||
jaxbOneToOne,
|
||||
JaxbOneToOneImpl::getFetch,
|
||||
"fetch",
|
||||
oneToOneAnn,
|
||||
oneToOneDescriptor
|
||||
);
|
||||
|
||||
return oneToOneAnn;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static void applyTarget(
|
||||
MutableMemberDetails memberDetails,
|
||||
JaxbOneToOneImpl jaxbOneToOne,
|
||||
MutableAnnotationUsage<OneToOne> oneToOneAnn,
|
||||
XmlDocumentContext xmlDocumentContext) {
|
||||
final String targetEntityName = jaxbOneToOne.getTargetEntity();
|
||||
if ( StringHelper.isEmpty( targetEntityName ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
final MutableAnnotationUsage<Target> targetAnn = XmlProcessingHelper.makeAnnotation( Target.class, memberDetails, xmlDocumentContext );
|
||||
targetAnn.setAttributeValue( "value", targetEntityName );
|
||||
}
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright: Red Hat Inc. and Hibernate Authors
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.boot.models.categorize.xml.internal.attr;
|
||||
package org.hibernate.boot.models.xml.internal.attr;
|
||||
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbPluralAnyMappingImpl;
|
||||
import org.hibernate.boot.models.categorize.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.boot.models.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.models.internal.MutableClassDetails;
|
||||
import org.hibernate.models.internal.MutableMemberDetails;
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright: Red Hat Inc. and Hibernate Authors
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.boot.models.categorize.xml.internal.db;
|
||||
package org.hibernate.boot.models.xml.internal.db;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
|
||||
|
@ -18,13 +18,12 @@ import org.hibernate.boot.jaxb.mapping.spi.db.JaxbColumnSizable;
|
|||
import org.hibernate.boot.jaxb.mapping.spi.db.JaxbColumnStandard;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.db.JaxbColumnUniqueable;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.db.JaxbCommentable;
|
||||
import org.hibernate.boot.models.categorize.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.boot.models.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.boot.models.xml.internal.XmlAnnotationHelper;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.models.internal.MutableAnnotationTarget;
|
||||
import org.hibernate.models.internal.MutableAnnotationUsage;
|
||||
|
||||
import static org.hibernate.boot.models.categorize.xml.internal.XmlAnnotationHelper.applyCheckConstraints;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
|
@ -45,7 +44,7 @@ public class ColumnProcessing {
|
|||
applyColumnDefinition( jaxbColumn, target, columnAnn, xmlDocumentContext );
|
||||
applyColumnUniqueness( jaxbColumn, target, columnAnn, xmlDocumentContext );
|
||||
applyColumnComment( jaxbColumn, target, columnAnn, xmlDocumentContext );
|
||||
applyCheckConstraints( jaxbColumn, target, columnAnn, xmlDocumentContext );
|
||||
XmlAnnotationHelper.applyCheckConstraints( jaxbColumn, target, columnAnn, xmlDocumentContext );
|
||||
|
||||
if ( jaxbColumn instanceof JaxbColumnSizable sizable ) {
|
||||
applyColumnSizing( sizable, target, columnAnn, xmlDocumentContext );
|
||||
|
@ -69,7 +68,7 @@ public class ColumnProcessing {
|
|||
applyColumnSizing( jaxbColumn, target, columnAnn, xmlDocumentContext );
|
||||
applyColumnUniqueness( jaxbColumn, target, columnAnn, xmlDocumentContext );
|
||||
applyColumnComment( jaxbColumn, target, columnAnn, xmlDocumentContext );
|
||||
applyCheckConstraints( jaxbColumn, target, columnAnn, xmlDocumentContext );
|
||||
XmlAnnotationHelper.applyCheckConstraints( jaxbColumn, target, columnAnn, xmlDocumentContext );
|
||||
}
|
||||
|
||||
public static <A extends Annotation> void applyColumnDetails(
|
||||
|
@ -108,7 +107,7 @@ public class ColumnProcessing {
|
|||
}
|
||||
|
||||
if ( jaxbColumn instanceof JaxbCheckable checkable ) {
|
||||
applyCheckConstraints( checkable, target, columnAnn, xmlDocumentContext );
|
||||
XmlAnnotationHelper.applyCheckConstraints( checkable, target, columnAnn, xmlDocumentContext );
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright: Red Hat Inc. and Hibernate Authors
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -29,7 +29,7 @@
|
|||
* </dl>
|
||||
* <p/>
|
||||
* When operating in metadata-complete mode,
|
||||
* {@linkplain org.hibernate.boot.models.categorize.xml.internal.ManagedTypeProcessor} will first clear
|
||||
* {@linkplain org.hibernate.boot.models.xml.internal.ManagedTypeProcessor} will first clear
|
||||
* all annotations from the managed type's
|
||||
* {@linkplain org.hibernate.models.spi.ClassDetails class},
|
||||
* {@linkplain org.hibernate.models.spi.FieldDetails fields} and
|
||||
|
@ -38,4 +38,4 @@
|
|||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
package org.hibernate.boot.models.categorize.xml.internal;
|
||||
package org.hibernate.boot.models.xml.internal;
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright: Red Hat Inc. and Hibernate Authors
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -11,19 +11,19 @@
|
|||
* on the model's {@linkplain org.hibernate.models.spi.AnnotationTarget targets}
|
||||
* based on the XML.<ol>
|
||||
* <li>
|
||||
* First performs some {@linkplain org.hibernate.boot.models.categorize.xml.spi.XmlPreProcessor pre-processing}
|
||||
* First performs some {@linkplain org.hibernate.boot.models.xml.spi.XmlPreProcessor pre-processing}
|
||||
* which aggregates information across all XML mappings
|
||||
* </li>
|
||||
* <li>
|
||||
* Next performs XML {@linkplain org.hibernate.boot.models.categorize.xml.spi.XmlProcessor processing} which
|
||||
* Next performs XML {@linkplain org.hibernate.boot.models.xml.spi.XmlProcessor processing} which
|
||||
* applies metadata-complete mappings and collects overlay/override XML for later application.
|
||||
* </li>
|
||||
* <li>
|
||||
* Performs XML {@linkplain org.hibernate.boot.models.categorize.xml.spi.XmlProcessingResult post-processing} which
|
||||
* Performs XML {@linkplain org.hibernate.boot.models.xml.spi.XmlProcessingResult post-processing} which
|
||||
* applies overlay/override XML.
|
||||
* </li>
|
||||
* </ol>
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
package org.hibernate.boot.models.categorize.xml;
|
||||
package org.hibernate.boot.models.xml;
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright: Red Hat Inc. and Hibernate Authors
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.boot.models.categorize.xml.spi;
|
||||
package org.hibernate.boot.models.xml.spi;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright: Red Hat Inc. and Hibernate Authors
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.boot.models.categorize.xml.spi;
|
||||
package org.hibernate.boot.models.xml.spi;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.boot.models.xml.spi;
|
||||
|
||||
import org.hibernate.boot.models.xml.internal.XmlAnnotationHelper;
|
||||
import org.hibernate.models.internal.MutableClassDetails;
|
||||
import org.hibernate.models.spi.SourceModelBuildingContext;
|
||||
|
||||
/**
|
||||
* Context for a specific XML mapping file
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface XmlDocumentContext {
|
||||
/**
|
||||
* The XML document
|
||||
*/
|
||||
XmlDocument getXmlDocument();
|
||||
|
||||
/**
|
||||
* The {@code <persistence-unit-metadata/>} defined by the XML document
|
||||
*/
|
||||
PersistenceUnitMetadata getPersistenceUnitMetadata();
|
||||
|
||||
/**
|
||||
* Access to the containing context
|
||||
*/
|
||||
SourceModelBuildingContext getModelBuildingContext();
|
||||
|
||||
/**
|
||||
* Resolve a ClassDetails by name, accounting for XML-defined package name if one.
|
||||
*/
|
||||
default MutableClassDetails resolveJavaType(String name) {
|
||||
return (MutableClassDetails) XmlAnnotationHelper.resolveJavaType( name, this );
|
||||
}
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright: Red Hat Inc. and Hibernate Authors
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.boot.models.categorize.xml.spi;
|
||||
package org.hibernate.boot.models.xml.spi;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -1,16 +1,17 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright: Red Hat Inc. and Hibernate Authors
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.boot.models.categorize.xml.spi;
|
||||
package org.hibernate.boot.models.xml.spi;
|
||||
|
||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmHibernateMapping;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityMappingsImpl;
|
||||
import org.hibernate.boot.jaxb.spi.Binding;
|
||||
import org.hibernate.boot.jaxb.spi.JaxbBindableMappingDescriptor;
|
||||
import org.hibernate.boot.model.process.spi.ManagedResources;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.XmlPreProcessingResultImpl;
|
||||
import org.hibernate.boot.models.xml.internal.XmlPreProcessingResultImpl;
|
||||
|
||||
/**
|
||||
* Performs pre-processing across XML mappings to collect data
|
||||
|
@ -27,7 +28,12 @@ public class XmlPreProcessor {
|
|||
final XmlPreProcessingResultImpl collected = new XmlPreProcessingResultImpl();
|
||||
|
||||
for ( Binding<JaxbBindableMappingDescriptor> mappingXmlBinding : managedResources.getXmlMappingBindings() ) {
|
||||
collected.addDocument( (JaxbEntityMappingsImpl) mappingXmlBinding.getRoot() );
|
||||
// for now skip hbm.xml
|
||||
final JaxbBindableMappingDescriptor root = mappingXmlBinding.getRoot();
|
||||
if ( root instanceof JaxbHbmHibernateMapping ) {
|
||||
continue;
|
||||
}
|
||||
collected.addDocument( (JaxbEntityMappingsImpl) root );
|
||||
}
|
||||
|
||||
return collected;
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright: Red Hat Inc. and Hibernate Authors
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.boot.models.categorize.xml.spi;
|
||||
package org.hibernate.boot.models.xml.spi;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -1,16 +1,16 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright: Red Hat Inc. and Hibernate Authors
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.boot.models.categorize.xml.spi;
|
||||
package org.hibernate.boot.models.xml.spi;
|
||||
|
||||
import org.hibernate.boot.models.categorize.internal.DomainModelCategorizationCollector;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.ManagedTypeProcessor;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.XmlDocumentContextImpl;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.XmlDocumentImpl;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.XmlProcessingResultImpl;
|
||||
import org.hibernate.boot.models.xml.internal.ManagedTypeProcessor;
|
||||
import org.hibernate.boot.models.xml.internal.XmlDocumentContextImpl;
|
||||
import org.hibernate.boot.models.xml.internal.XmlDocumentImpl;
|
||||
import org.hibernate.boot.models.xml.internal.XmlProcessingResultImpl;
|
||||
import org.hibernate.models.spi.SourceModelBuildingContext;
|
||||
|
||||
/**
|
|
@ -504,4 +504,38 @@ public final class CollectionHelper {
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static <E> List<E> mutableJoin(Collection<E> first, Collection<E> second) {
|
||||
final int totalCount = ( first == null ? 0 : first.size() )
|
||||
+ ( second == null ? 0 : second.size() );
|
||||
if ( totalCount == 0 ) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
final ArrayList<E> joined = new ArrayList<>( totalCount );
|
||||
if ( first != null ) {
|
||||
joined.addAll( first );
|
||||
}
|
||||
if ( second != null ) {
|
||||
joined.addAll( second );
|
||||
}
|
||||
return joined;
|
||||
}
|
||||
|
||||
public static <E> List<E> mutableJoin(Collection<E> first, Collection<E>... others) {
|
||||
// it can be empty, but not null
|
||||
assert first != null;
|
||||
|
||||
if ( isEmpty( others ) ) {
|
||||
final ArrayList<E> list = new ArrayList<>( first.size() );
|
||||
list.addAll( first );
|
||||
return list;
|
||||
}
|
||||
|
||||
final List<E> joined = arrayList( first.size() + ( isEmpty( others ) ? 0 : others.length * 8 ) );
|
||||
joined.addAll( first );
|
||||
for ( Collection<E> other : others ) {
|
||||
joined.addAll( other );
|
||||
}
|
||||
return joined;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,8 +70,8 @@ import static org.hibernate.metamodel.mapping.EntityDiscriminatorMapping.DISCRIM
|
|||
/**
|
||||
* A mapping model object that represents an {@linkplain jakarta.persistence.Embeddable embeddable class}.
|
||||
*
|
||||
* @apiNote The name of this class is historical and unfortunate. An embeddable class holds a "component"
|
||||
* of the state of an entity. It has absolutely nothing to do with modularity in software engineering.
|
||||
* @apiNote The name of this class is historical and unfortunate. It reflects modeling a *composition*
|
||||
* of state. It has absolutely nothing to do with modularity in software engineering.
|
||||
*
|
||||
* @author Gavin King
|
||||
* @author Steve Ebersole
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.junit.Test;
|
|||
|
||||
import org.hibernate.AnnotationException;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.boot.models.AccessTypeDeterminationException;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
|
@ -35,7 +36,7 @@ public class SafeMappingTest {
|
|||
sessionFactory = cfg.buildSessionFactory( serviceRegistry );
|
||||
fail( "Entity wo id should fail" );
|
||||
}
|
||||
catch (AnnotationException e) {
|
||||
catch (AnnotationException | AccessTypeDeterminationException e) {
|
||||
//success
|
||||
}
|
||||
finally {
|
||||
|
|
|
@ -31,7 +31,6 @@ public class BasketItems implements Serializable {
|
|||
@ManyToOne(cascade={ CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH })
|
||||
@JoinColumn(name="basketDatetime", referencedColumnName="basketDatetime")
|
||||
@JoinColumn(name="customerID", referencedColumnName="customerID")
|
||||
@Basic(fetch= FetchType.LAZY)
|
||||
private ShoppingBaskets shoppingBaskets;
|
||||
|
||||
@Column(name="cost", nullable=false)
|
||||
|
|
|
@ -31,7 +31,6 @@ public class ShoppingBaskets implements Serializable {
|
|||
@Id
|
||||
@ManyToOne(cascade={ CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH })
|
||||
@JoinColumn(name="customerID", referencedColumnName="customerID")
|
||||
@Basic(fetch=FetchType.LAZY)
|
||||
private Customers owner;
|
||||
|
||||
@Column(name="basketDatetime", nullable=false)
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package org.hibernate.orm.test.annotations.various;
|
||||
|
||||
import org.hibernate.annotations.Generated;
|
||||
import org.hibernate.annotations.GenerationTime;
|
||||
import org.hibernate.annotations.Subselect;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
|
@ -56,7 +54,6 @@ public class OneOneGeneratedValueTest {
|
|||
|
||||
private String name;
|
||||
|
||||
@Generated(GenerationTime.INSERT)
|
||||
@OneToOne(mappedBy = "a")
|
||||
private EntityB b;
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ import org.hibernate.boot.jaxb.internal.MappingBinder;
|
|||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityMappingsImpl;
|
||||
import org.hibernate.boot.jaxb.spi.Binding;
|
||||
import org.hibernate.boot.jaxb.spi.JaxbBindableMappingDescriptor;
|
||||
import org.hibernate.boot.models.categorize.xml.XmlResourceException;
|
||||
import org.hibernate.boot.models.xml.XmlResourceException;
|
||||
import org.hibernate.models.spi.ClassLoading;
|
||||
|
||||
import static org.hibernate.boot.jaxb.internal.MappingBinder.NON_VALIDATING;
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.hibernate.boot.models.categorize.spi.EntityHierarchy;
|
|||
import org.hibernate.boot.models.categorize.spi.ManagedResourcesProcessor;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||
import org.hibernate.orm.test.boot.models.ManagedResourcesImpl;
|
||||
import org.hibernate.boot.model.source.internal.annotations.AdditionalManagedResourcesImpl;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
|
@ -112,7 +112,7 @@ public class BindingTestingHelper {
|
|||
}
|
||||
|
||||
public static Set<EntityHierarchy> buildHierarchyMetadata(Class<?>... classes) {
|
||||
final ManagedResources managedResources = new ManagedResourcesImpl.Builder()
|
||||
final ManagedResources managedResources = new AdditionalManagedResourcesImpl.Builder()
|
||||
.addLoadedClasses(classes)
|
||||
.build();
|
||||
|
||||
|
@ -130,7 +130,7 @@ public class BindingTestingHelper {
|
|||
}
|
||||
|
||||
public static CategorizedDomainModel buildCategorizedDomainModel(Class<?>... classes) {
|
||||
final ManagedResources managedResources = new ManagedResourcesImpl.Builder()
|
||||
final ManagedResources managedResources = new AdditionalManagedResourcesImpl.Builder()
|
||||
.addLoadedClasses(classes)
|
||||
.build();
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import java.util.Map;
|
|||
import org.hibernate.boot.internal.MetadataBuilderImpl;
|
||||
import org.hibernate.boot.model.process.spi.ManagedResources;
|
||||
import org.hibernate.orm.test.boot.models.BootstrapContextTesting;
|
||||
import org.hibernate.orm.test.boot.models.ManagedResourcesImpl;
|
||||
import org.hibernate.boot.model.source.internal.annotations.AdditionalManagedResourcesImpl;
|
||||
import org.hibernate.orm.test.boot.models.MyStringConverter;
|
||||
import org.hibernate.orm.test.boot.models.MyUuidConverter;
|
||||
import org.hibernate.orm.test.boot.models.SourceModelTestHelper;
|
||||
|
@ -51,7 +51,7 @@ public class SimpleProcessorTests {
|
|||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// ManagedResources is built by scanning and from explicit resources
|
||||
// during ORM bootstrap
|
||||
final ManagedResourcesImpl.Builder managedResourcesBuilder = new ManagedResourcesImpl.Builder();
|
||||
final AdditionalManagedResourcesImpl.Builder managedResourcesBuilder = new AdditionalManagedResourcesImpl.Builder();
|
||||
managedResourcesBuilder
|
||||
.addLoadedClasses( Person.class, Root.class, Sub.class, MyStringConverter.class, MyUuidConverter.class )
|
||||
.addPackages( "org.hibernate.models.orm.process" );
|
||||
|
|
|
@ -14,9 +14,9 @@ import org.hibernate.orm.test.boot.models.SourceModelTestHelper;
|
|||
import org.hibernate.boot.models.categorize.internal.DomainModelCategorizationCollector;
|
||||
import org.hibernate.boot.models.categorize.internal.GlobalRegistrationsImpl;
|
||||
import org.hibernate.boot.models.categorize.spi.FilterDefRegistration;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.XmlDocumentImpl;
|
||||
import org.hibernate.boot.models.categorize.xml.internal.XmlPreProcessingResultImpl;
|
||||
import org.hibernate.boot.models.categorize.xml.spi.PersistenceUnitMetadata;
|
||||
import org.hibernate.boot.models.xml.internal.XmlDocumentImpl;
|
||||
import org.hibernate.boot.models.xml.internal.XmlPreProcessingResultImpl;
|
||||
import org.hibernate.boot.models.xml.spi.PersistenceUnitMetadata;
|
||||
import org.hibernate.models.internal.StringTypeDescriptor;
|
||||
import org.hibernate.models.spi.ClassDetails;
|
||||
import org.hibernate.models.spi.SourceModelBuildingContext;
|
||||
|
@ -127,7 +127,8 @@ public class XmlProcessingSmokeTests {
|
|||
final DomainModelCategorizationCollector collector = new DomainModelCategorizationCollector(
|
||||
false,
|
||||
buildingContext.getClassDetailsRegistry(),
|
||||
buildingContext.getAnnotationDescriptorRegistry()
|
||||
buildingContext.getAnnotationDescriptorRegistry(),
|
||||
null
|
||||
);
|
||||
collectedXmlResources.getDocuments().forEach( collector::apply );
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ import org.hibernate.boot.model.process.spi.ManagedResources;
|
|||
import org.hibernate.boot.internal.AnyKeyType;
|
||||
import org.hibernate.boot.models.categorize.spi.CategorizedDomainModel;
|
||||
import org.hibernate.boot.models.categorize.spi.EntityHierarchy;
|
||||
import org.hibernate.orm.test.boot.models.ManagedResourcesImpl;
|
||||
import org.hibernate.boot.model.source.internal.annotations.AdditionalManagedResourcesImpl;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||
import org.hibernate.models.spi.AnnotationUsage;
|
||||
import org.hibernate.models.spi.FieldDetails;
|
||||
|
@ -45,7 +45,7 @@ public class AnyTests {
|
|||
@SuppressWarnings("JUnitMalformedDeclaration")
|
||||
void testSimpleAnyAttribute(ServiceRegistryScope scope) {
|
||||
final StandardServiceRegistry serviceRegistry = scope.getRegistry();
|
||||
final ManagedResources managedResources = new ManagedResourcesImpl.Builder()
|
||||
final ManagedResources managedResources = new AdditionalManagedResourcesImpl.Builder()
|
||||
.addLoadedClasses( Entity1.class )
|
||||
.addLoadedClasses( Entity2.class )
|
||||
.addXmlMappings( "mappings/models/attr/any/simple.xml" )
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.hibernate.boot.model.process.spi.ManagedResources;
|
|||
import org.hibernate.boot.models.categorize.spi.CategorizedDomainModel;
|
||||
import org.hibernate.boot.models.categorize.spi.EntityHierarchy;
|
||||
import org.hibernate.boot.models.categorize.spi.EntityTypeMetadata;
|
||||
import org.hibernate.orm.test.boot.models.ManagedResourcesImpl;
|
||||
import org.hibernate.boot.model.source.internal.annotations.AdditionalManagedResourcesImpl;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||
import org.hibernate.models.spi.AnnotationUsage;
|
||||
import org.hibernate.models.spi.FieldDetails;
|
||||
|
@ -51,7 +51,7 @@ public class ManyToOneTests {
|
|||
@SuppressWarnings("JUnitMalformedDeclaration")
|
||||
void testSimpleManyToOne(ServiceRegistryScope scope) {
|
||||
final StandardServiceRegistry serviceRegistry = scope.getRegistry();
|
||||
final ManagedResources managedResources = new ManagedResourcesImpl.Builder()
|
||||
final ManagedResources managedResources = new AdditionalManagedResourcesImpl.Builder()
|
||||
.addXmlMappings( "mappings/models/attr/many-to-one/simple.xml" )
|
||||
.build();
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import org.hibernate.boot.model.process.spi.ManagedResources;
|
|||
import org.hibernate.boot.models.categorize.spi.CategorizedDomainModel;
|
||||
import org.hibernate.boot.models.categorize.spi.EntityHierarchy;
|
||||
import org.hibernate.boot.models.categorize.spi.EntityTypeMetadata;
|
||||
import org.hibernate.orm.test.boot.models.ManagedResourcesImpl;
|
||||
import org.hibernate.boot.model.source.internal.annotations.AdditionalManagedResourcesImpl;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||
import org.hibernate.models.spi.AnnotationUsage;
|
||||
import org.hibernate.models.spi.FieldDetails;
|
||||
|
@ -33,7 +33,7 @@ import static org.hibernate.boot.models.categorize.spi.ManagedResourcesProcessor
|
|||
public class ColumnTests {
|
||||
@Test
|
||||
void testCompleteColumn(ServiceRegistryScope scope) {
|
||||
final ManagedResources managedResources = new ManagedResourcesImpl.Builder()
|
||||
final ManagedResources managedResources = new AdditionalManagedResourcesImpl.Builder()
|
||||
.addXmlMappings( "mappings/models/column/complete.xml" )
|
||||
.build();
|
||||
final StandardServiceRegistry serviceRegistry = scope.getRegistry();
|
||||
|
@ -65,7 +65,7 @@ public class ColumnTests {
|
|||
|
||||
@Test
|
||||
void testOverrideColumn(ServiceRegistryScope scope) {
|
||||
final ManagedResources managedResources = new ManagedResourcesImpl.Builder()
|
||||
final ManagedResources managedResources = new AdditionalManagedResourcesImpl.Builder()
|
||||
.addXmlMappings( "mappings/models/column/override.xml" )
|
||||
.build();
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ import org.hibernate.boot.registry.StandardServiceRegistry;
|
|||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||
import org.hibernate.orm.test.boot.models.BootstrapContextTesting;
|
||||
import org.hibernate.orm.test.boot.models.SourceModelTestHelper;
|
||||
import org.hibernate.orm.test.boot.models.ManagedResourcesImpl;
|
||||
import org.hibernate.boot.model.source.internal.annotations.AdditionalManagedResourcesImpl;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
@ -36,7 +36,7 @@ public class CompleteXmlInheritanceTests {
|
|||
@Test
|
||||
void testIt() {
|
||||
|
||||
final ManagedResourcesImpl.Builder managedResourcesBuilder = new ManagedResourcesImpl.Builder();
|
||||
final AdditionalManagedResourcesImpl.Builder managedResourcesBuilder = new AdditionalManagedResourcesImpl.Builder();
|
||||
managedResourcesBuilder.addXmlMappings( "mappings/models/complete/simple-inherited.xml" );
|
||||
final ManagedResources managedResources = managedResourcesBuilder.build();
|
||||
|
||||
|
|
|
@ -11,9 +11,10 @@ import org.hibernate.boot.internal.MetadataBuilderImpl;
|
|||
import org.hibernate.boot.model.process.spi.ManagedResources;
|
||||
import org.hibernate.boot.models.categorize.spi.AttributeMetadata;
|
||||
import org.hibernate.boot.models.categorize.spi.CategorizedDomainModel;
|
||||
import org.hibernate.boot.models.categorize.spi.ClassAttributeAccessType;
|
||||
import org.hibernate.boot.models.categorize.spi.EntityHierarchy;
|
||||
import org.hibernate.boot.models.categorize.spi.EntityTypeMetadata;
|
||||
import org.hibernate.orm.test.boot.models.ManagedResourcesImpl;
|
||||
import org.hibernate.boot.model.source.internal.annotations.AdditionalManagedResourcesImpl;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||
|
||||
|
@ -35,7 +36,7 @@ import static org.hibernate.boot.models.categorize.spi.ManagedResourcesProcessor
|
|||
public class CompleteXmlWithEmbeddableTests {
|
||||
@Test
|
||||
void testIt() {
|
||||
final ManagedResourcesImpl.Builder managedResourcesBuilder = new ManagedResourcesImpl.Builder();
|
||||
final AdditionalManagedResourcesImpl.Builder managedResourcesBuilder = new AdditionalManagedResourcesImpl.Builder();
|
||||
managedResourcesBuilder.addXmlMappings( "mappings/models/complete/simple-person.xml" );
|
||||
final ManagedResources managedResources = managedResourcesBuilder.build();
|
||||
|
||||
|
@ -53,7 +54,7 @@ public class CompleteXmlWithEmbeddableTests {
|
|||
|
||||
final EntityHierarchy hierarchy = categorizedDomainModel.getEntityHierarchies().iterator().next();
|
||||
final EntityTypeMetadata personMetadata = hierarchy.getRoot();
|
||||
assertThat( personMetadata.getAccessType() ).isEqualTo( AccessType.FIELD );
|
||||
assertThat( personMetadata.getClassLevelAccessType() ).isEqualTo( ClassAttributeAccessType.EXPLICIT_FIELD );
|
||||
|
||||
assertThat( personMetadata.getAttributes() ).hasSize( 2 );
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ import org.hibernate.boot.models.categorize.spi.CategorizedDomainModel;
|
|||
import org.hibernate.boot.models.categorize.spi.EntityHierarchy;
|
||||
import org.hibernate.boot.models.categorize.spi.EntityTypeMetadata;
|
||||
import org.hibernate.boot.models.categorize.spi.IdentifiableTypeMetadata;
|
||||
import org.hibernate.orm.test.boot.models.ManagedResourcesImpl;
|
||||
import org.hibernate.boot.model.source.internal.annotations.AdditionalManagedResourcesImpl;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||
import org.hibernate.models.spi.AnnotationUsage;
|
||||
|
@ -33,7 +33,7 @@ import static org.hibernate.boot.models.categorize.spi.ManagedResourcesProcessor
|
|||
public class DiscriminatorValueTest {
|
||||
@Test
|
||||
void testDiscriminatorValue() {
|
||||
final ManagedResources managedResources = new ManagedResourcesImpl.Builder()
|
||||
final ManagedResources managedResources = new AdditionalManagedResourcesImpl.Builder()
|
||||
.addXmlMappings( "mappings/models/complete/discriminator-value.xml" )
|
||||
.build();
|
||||
try (StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().build()) {
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.hibernate.boot.models.categorize.spi.AttributeMetadata;
|
|||
import org.hibernate.boot.models.categorize.spi.CategorizedDomainModel;
|
||||
import org.hibernate.boot.models.categorize.spi.EntityHierarchy;
|
||||
import org.hibernate.boot.models.categorize.spi.EntityTypeMetadata;
|
||||
import org.hibernate.orm.test.boot.models.ManagedResourcesImpl;
|
||||
import org.hibernate.boot.model.source.internal.annotations.AdditionalManagedResourcesImpl;
|
||||
import org.hibernate.orm.test.boot.models.xml.SimpleEntity;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||
|
@ -42,8 +42,7 @@ import static org.hibernate.boot.models.categorize.spi.ManagedResourcesProcessor
|
|||
public class SimpleCompleteXmlTests {
|
||||
@Test
|
||||
void testSimpleCompleteEntity() {
|
||||
|
||||
final ManagedResourcesImpl.Builder managedResourcesBuilder = new ManagedResourcesImpl.Builder();
|
||||
final AdditionalManagedResourcesImpl.Builder managedResourcesBuilder = new AdditionalManagedResourcesImpl.Builder();
|
||||
managedResourcesBuilder.addXmlMappings( "mappings/models/complete/simple-complete.xml" );
|
||||
final ManagedResources managedResources = managedResourcesBuilder.build();
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.hibernate.boot.model.process.spi.ManagedResources;
|
|||
import org.hibernate.boot.models.categorize.spi.CategorizedDomainModel;
|
||||
import org.hibernate.boot.models.categorize.spi.EntityHierarchy;
|
||||
import org.hibernate.boot.models.categorize.spi.EntityTypeMetadata;
|
||||
import org.hibernate.orm.test.boot.models.ManagedResourcesImpl;
|
||||
import org.hibernate.boot.model.source.internal.annotations.AdditionalManagedResourcesImpl;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||
import org.hibernate.models.spi.AnnotationUsage;
|
||||
|
@ -54,7 +54,7 @@ import static org.hibernate.boot.models.categorize.spi.ManagedResourcesProcessor
|
|||
public class DynamicModelTests {
|
||||
@Test
|
||||
void testSimpleDynamicModel() {
|
||||
final ManagedResources managedResources = new ManagedResourcesImpl.Builder()
|
||||
final ManagedResources managedResources = new AdditionalManagedResourcesImpl.Builder()
|
||||
.addXmlMappings( "mappings/models/dynamic/dynamic-simple.xml" )
|
||||
.build();
|
||||
try (StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().build()) {
|
||||
|
@ -87,7 +87,7 @@ public class DynamicModelTests {
|
|||
|
||||
@Test
|
||||
void testSemiSimpleDynamicModel() {
|
||||
final ManagedResources managedResources = new ManagedResourcesImpl.Builder()
|
||||
final ManagedResources managedResources = new AdditionalManagedResourcesImpl.Builder()
|
||||
.addXmlMappings( "mappings/models/dynamic/dynamic-semi-simple.xml" )
|
||||
.build();
|
||||
try (StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().build()) {
|
||||
|
@ -134,7 +134,7 @@ public class DynamicModelTests {
|
|||
|
||||
@Test
|
||||
void testIdClass() {
|
||||
final ManagedResources managedResources = new ManagedResourcesImpl.Builder()
|
||||
final ManagedResources managedResources = new AdditionalManagedResourcesImpl.Builder()
|
||||
.addXmlMappings( "mappings/models/dynamic/dynamic-id-class.xml" )
|
||||
.build();
|
||||
try (StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().build()) {
|
||||
|
@ -161,7 +161,7 @@ public class DynamicModelTests {
|
|||
|
||||
@Test
|
||||
void testOneToMany() {
|
||||
final ManagedResources managedResources = new ManagedResourcesImpl.Builder()
|
||||
final ManagedResources managedResources = new AdditionalManagedResourcesImpl.Builder()
|
||||
.addXmlMappings( "mappings/models/dynamic/dynamic-plurals.xml" )
|
||||
.build();
|
||||
try (StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().build()) {
|
||||
|
|
|
@ -15,7 +15,7 @@ import org.hibernate.boot.model.process.spi.ManagedResources;
|
|||
import org.hibernate.boot.models.categorize.spi.CategorizedDomainModel;
|
||||
import org.hibernate.boot.models.categorize.spi.EntityHierarchy;
|
||||
import org.hibernate.boot.models.categorize.spi.EntityTypeMetadata;
|
||||
import org.hibernate.orm.test.boot.models.ManagedResourcesImpl;
|
||||
import org.hibernate.boot.model.source.internal.annotations.AdditionalManagedResourcesImpl;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||
import org.hibernate.models.spi.AnnotationUsage;
|
||||
|
@ -33,7 +33,7 @@ import static org.hibernate.boot.models.categorize.spi.ManagedResourcesProcessor
|
|||
public class NamedEntityGraphTest {
|
||||
@Test
|
||||
void testNamedEntityGraph() {
|
||||
final ManagedResources managedResources = new ManagedResourcesImpl.Builder()
|
||||
final ManagedResources managedResources = new AdditionalManagedResourcesImpl.Builder()
|
||||
.addXmlMappings( "mappings/models/dynamic/dynamic-named-entity-graph.xml" )
|
||||
.build();
|
||||
try (StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().build()) {
|
||||
|
|
|
@ -15,7 +15,7 @@ import org.hibernate.boot.model.process.spi.ManagedResources;
|
|||
import org.hibernate.boot.models.categorize.spi.CategorizedDomainModel;
|
||||
import org.hibernate.boot.models.categorize.spi.EntityHierarchy;
|
||||
import org.hibernate.boot.models.categorize.spi.EntityTypeMetadata;
|
||||
import org.hibernate.orm.test.boot.models.ManagedResourcesImpl;
|
||||
import org.hibernate.boot.model.source.internal.annotations.AdditionalManagedResourcesImpl;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||
import org.hibernate.models.spi.AnnotationUsage;
|
||||
|
@ -28,7 +28,7 @@ import static org.hibernate.boot.models.categorize.spi.ManagedResourcesProcessor
|
|||
public class RowIdTest {
|
||||
@Test
|
||||
void testSimpleDynamicModel() {
|
||||
final ManagedResources managedResources = new ManagedResourcesImpl.Builder()
|
||||
final ManagedResources managedResources = new AdditionalManagedResourcesImpl.Builder()
|
||||
.addXmlMappings( "mappings/models/dynamic/dynamic-rowid.xml" )
|
||||
.build();
|
||||
try (StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().build()) {
|
||||
|
|
|
@ -16,7 +16,7 @@ import org.hibernate.boot.model.process.spi.ManagedResources;
|
|||
import org.hibernate.boot.models.categorize.spi.CategorizedDomainModel;
|
||||
import org.hibernate.boot.models.categorize.spi.EntityHierarchy;
|
||||
import org.hibernate.boot.models.categorize.spi.EntityTypeMetadata;
|
||||
import org.hibernate.orm.test.boot.models.ManagedResourcesImpl;
|
||||
import org.hibernate.boot.model.source.internal.annotations.AdditionalManagedResourcesImpl;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||
import org.hibernate.models.spi.AnnotationUsage;
|
||||
|
@ -35,7 +35,7 @@ import static org.hibernate.boot.models.categorize.spi.ManagedResourcesProcessor
|
|||
public class TenantIdTest {
|
||||
@Test
|
||||
void testSimpleDynamicModel() {
|
||||
final ManagedResources managedResources = new ManagedResourcesImpl.Builder()
|
||||
final ManagedResources managedResources = new AdditionalManagedResourcesImpl.Builder()
|
||||
.addXmlMappings( "mappings/models/dynamic/dynamic-tenantid.xml" )
|
||||
.build();
|
||||
try (StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().build()) {
|
||||
|
|
|
@ -13,7 +13,7 @@ import org.hibernate.boot.internal.MetadataBuilderImpl;
|
|||
import org.hibernate.boot.model.process.spi.ManagedResources;
|
||||
import org.hibernate.boot.models.categorize.spi.CategorizedDomainModel;
|
||||
import org.hibernate.boot.models.categorize.spi.JpaEventListener;
|
||||
import org.hibernate.orm.test.boot.models.ManagedResourcesImpl;
|
||||
import org.hibernate.boot.model.source.internal.annotations.AdditionalManagedResourcesImpl;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||
import org.hibernate.models.internal.jdk.VoidClassDetails;
|
||||
|
@ -30,7 +30,7 @@ import static org.hibernate.boot.models.categorize.spi.ManagedResourcesProcessor
|
|||
public class JpaEventListenerTests {
|
||||
@Test
|
||||
void testGlobalRegistration() {
|
||||
final ManagedResources managedResources = new ManagedResourcesImpl.Builder()
|
||||
final ManagedResources managedResources = new AdditionalManagedResourcesImpl.Builder()
|
||||
.addXmlMappings( "mappings/models/globals.xml" )
|
||||
.build();
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ import org.hibernate.boot.internal.MetadataBuilderImpl;
|
|||
import org.hibernate.boot.model.process.spi.ManagedResources;
|
||||
import org.hibernate.boot.models.categorize.spi.CategorizedDomainModel;
|
||||
import org.hibernate.boot.models.categorize.spi.EntityTypeMetadata;
|
||||
import org.hibernate.orm.test.boot.models.ManagedResourcesImpl;
|
||||
import org.hibernate.boot.model.source.internal.annotations.AdditionalManagedResourcesImpl;
|
||||
import org.hibernate.orm.test.boot.models.xml.SimpleEntity;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||
|
@ -42,7 +42,7 @@ import static org.hibernate.boot.models.categorize.spi.ManagedResourcesProcessor
|
|||
public class EntityLifecycleTests {
|
||||
@Test
|
||||
void testEntityLifecycle() {
|
||||
final ManagedResources managedResources = new ManagedResourcesImpl.Builder()
|
||||
final ManagedResources managedResources = new AdditionalManagedResourcesImpl.Builder()
|
||||
.addXmlMappings( "mappings/models/lifecycle/entity-lifecycle.xml" )
|
||||
.build();
|
||||
try (StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().build()) {
|
||||
|
|
|
@ -13,7 +13,7 @@ import org.hibernate.boot.models.categorize.spi.AttributeMetadata;
|
|||
import org.hibernate.boot.models.categorize.spi.CategorizedDomainModel;
|
||||
import org.hibernate.boot.models.categorize.spi.EntityHierarchy;
|
||||
import org.hibernate.boot.models.categorize.spi.EntityTypeMetadata;
|
||||
import org.hibernate.orm.test.boot.models.ManagedResourcesImpl;
|
||||
import org.hibernate.boot.model.source.internal.annotations.AdditionalManagedResourcesImpl;
|
||||
import org.hibernate.orm.test.boot.models.xml.SimpleEntity;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||
|
@ -35,7 +35,7 @@ public class SimpleOverrideXmlTests {
|
|||
@Test
|
||||
void testSimpleCompleteEntity() {
|
||||
|
||||
final ManagedResourcesImpl.Builder managedResourcesBuilder = new ManagedResourcesImpl.Builder();
|
||||
final AdditionalManagedResourcesImpl.Builder managedResourcesBuilder = new AdditionalManagedResourcesImpl.Builder();
|
||||
managedResourcesBuilder.addXmlMappings( "mappings/models/override/simple-override.xml" );
|
||||
final ManagedResources managedResources = managedResourcesBuilder.build();
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ import jakarta.persistence.Lob;
|
|||
|
||||
@Entity
|
||||
public class GenericCompositeUserTypeEntity {
|
||||
@Lob
|
||||
@Embedded
|
||||
@CompositeType(value = EnumPlaceholderUserType.class)
|
||||
@AttributeOverrides({
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package org.hibernate.orm.test.entitygraph.parser;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import jakarta.persistence.Basic;
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.ElementCollection;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.Id;
|
||||
|
@ -61,7 +61,6 @@ public class GraphParsingTestEntity {
|
|||
}
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||
@ElementCollection(targetClass = GraphParsingTestEntity.class)
|
||||
public Map<GraphParsingTestEntity, GraphParsingTestEntity> getMap() {
|
||||
return map;
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package org.hibernate.orm.test.graph;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import jakarta.persistence.Basic;
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.ElementCollection;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.Id;
|
||||
|
@ -61,7 +61,6 @@ public class GraphParsingTestEntity {
|
|||
}
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||
@ElementCollection(targetClass = GraphParsingTestEntity.class)
|
||||
public Map<GraphParsingTestEntity, GraphParsingTestEntity> getMap() {
|
||||
return map;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
*/
|
||||
package org.hibernate.orm.test.proxy;
|
||||
|
||||
import jakarta.persistence.Access;
|
||||
import jakarta.persistence.AccessType;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
|
@ -70,9 +72,11 @@ public class MissingSetterWithEnhancementTest {
|
|||
}
|
||||
|
||||
@Entity
|
||||
@Access(AccessType.PROPERTY)
|
||||
public static class EntityWithMissingSetter {
|
||||
private Long id;
|
||||
@Column
|
||||
@Access(AccessType.FIELD)
|
||||
private int someInt;
|
||||
|
||||
@Id
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue