HHH-18060 - HbmXmlTransformer
testing an alternative approach using the boot model
This commit is contained in:
parent
944a3b9bd8
commit
2d0f1a76cc
|
@ -26,6 +26,12 @@ import org.hibernate.boot.archive.spi.ArchiveDescriptorFactory;
|
|||
import org.hibernate.boot.cfgxml.spi.CfgXmlAccessService;
|
||||
import org.hibernate.boot.cfgxml.spi.LoadedConfig;
|
||||
import org.hibernate.boot.cfgxml.spi.MappingReference;
|
||||
import org.hibernate.boot.jaxb.Origin;
|
||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmHibernateMapping;
|
||||
import org.hibernate.boot.jaxb.hbm.transform.HbmXmlTransformer;
|
||||
import org.hibernate.boot.jaxb.hbm.transform.UnsupportedFeatureHandling;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityMappingsImpl;
|
||||
import org.hibernate.boot.jaxb.spi.Binding;
|
||||
import org.hibernate.boot.model.FunctionContributions;
|
||||
import org.hibernate.boot.model.FunctionContributor;
|
||||
import org.hibernate.boot.model.TypeContributions;
|
||||
|
@ -59,15 +65,18 @@ import org.hibernate.boot.spi.MetadataSourcesContributor;
|
|||
import org.hibernate.cache.spi.RegionFactory;
|
||||
import org.hibernate.cache.spi.access.AccessType;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.cfg.MappingSettings;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.dialect.TimeZoneSupport;
|
||||
import org.hibernate.engine.config.spi.ConfigurationService;
|
||||
import org.hibernate.engine.config.spi.StandardConverters;
|
||||
import org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentImpl;
|
||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||
import org.hibernate.internal.CoreLogging;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.internal.log.DeprecationLogger;
|
||||
import org.hibernate.internal.util.NullnessHelper;
|
||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||
import org.hibernate.metamodel.CollectionClassification;
|
||||
import org.hibernate.query.sqm.function.SqmFunctionDescriptor;
|
||||
import org.hibernate.query.sqm.function.SqmFunctionRegistry;
|
||||
|
@ -105,7 +114,7 @@ public class MetadataBuilderImpl implements MetadataBuilderImplementor, TypeCont
|
|||
this( sources, getStandardServiceRegistry( sources.getServiceRegistry() ) );
|
||||
}
|
||||
|
||||
private static StandardServiceRegistry getStandardServiceRegistry(ServiceRegistry serviceRegistry) {
|
||||
public static StandardServiceRegistry getStandardServiceRegistry(ServiceRegistry serviceRegistry) {
|
||||
if ( serviceRegistry == null ) {
|
||||
throw new HibernateException( "ServiceRegistry passed to MetadataBuilder cannot be null" );
|
||||
}
|
||||
|
@ -435,7 +444,52 @@ public class MetadataBuilderImpl implements MetadataBuilderImplementor, TypeCont
|
|||
}
|
||||
}
|
||||
|
||||
return MetadataBuildingProcess.build( sources, bootstrapContext, options );
|
||||
final MetadataImplementor bootModel = MetadataBuildingProcess.build( sources, bootstrapContext, options );
|
||||
|
||||
if ( CollectionHelper.isNotEmpty( sources.getHbmXmlBindings() ) ) {
|
||||
final ConfigurationService configurationService = bootstrapContext.getServiceRegistry().getService( ConfigurationService.class );
|
||||
final boolean transformHbm = configurationService != null
|
||||
&& configurationService.getSetting( MappingSettings.TRANSFORM_HBM_XML, BOOLEAN,false );
|
||||
|
||||
if ( !transformHbm ) {
|
||||
for ( Binding<JaxbHbmHibernateMapping> hbmXmlBinding : sources.getHbmXmlBindings() ) {
|
||||
final Origin origin = hbmXmlBinding.getOrigin();
|
||||
DeprecationLogger.DEPRECATION_LOGGER.logDeprecatedHbmXmlProcessing( origin.getType(), origin.getName() );
|
||||
}
|
||||
}
|
||||
else {
|
||||
final List<Binding<JaxbEntityMappingsImpl>> transformed = HbmXmlTransformer.transform(
|
||||
sources.getHbmXmlBindings(),
|
||||
bootModel,
|
||||
bootstrapContext.getServiceRegistry(),
|
||||
UnsupportedFeatureHandling.fromSetting(
|
||||
configurationService.getSettings().get( AvailableSettings.TRANSFORM_HBM_XML_FEATURE_HANDLING ),
|
||||
UnsupportedFeatureHandling.ERROR
|
||||
)
|
||||
);
|
||||
|
||||
final MetadataSources newSources = new MetadataSources( bootstrapContext.getServiceRegistry() );
|
||||
if ( sources.getAnnotatedClasses() != null ) {
|
||||
sources.getAnnotatedClasses().forEach( newSources::addAnnotatedClass );
|
||||
}
|
||||
if ( sources.getAnnotatedClassNames() != null ) {
|
||||
sources.getAnnotatedClassNames().forEach( newSources::addAnnotatedClassName );
|
||||
}
|
||||
if ( sources.getAnnotatedPackages() != null ) {
|
||||
sources.getAnnotatedPackages().forEach( newSources::addPackage );
|
||||
}
|
||||
if ( sources.getExtraQueryImports() != null ) {
|
||||
sources.getExtraQueryImports().forEach( newSources::addQueryImport );
|
||||
}
|
||||
for ( Binding<JaxbEntityMappingsImpl> mappingXmlBinding : transformed ) {
|
||||
newSources.addMappingXmlBinding( mappingXmlBinding );
|
||||
}
|
||||
|
||||
return (MetadataImplementor) newSources.buildMetadata();
|
||||
}
|
||||
}
|
||||
|
||||
return bootModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,129 @@
|
|||
/*
|
||||
* 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.jaxb.hbm.transform;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.boot.internal.MetadataImpl;
|
||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmHibernateMapping;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityImpl;
|
||||
import org.hibernate.boot.jaxb.spi.Binding;
|
||||
import org.hibernate.boot.spi.MetadataImplementor;
|
||||
import org.hibernate.mapping.Collection;
|
||||
import org.hibernate.mapping.Component;
|
||||
import org.hibernate.mapping.IndexedCollection;
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
import org.hibernate.mapping.Property;
|
||||
import org.hibernate.mapping.RootClass;
|
||||
import org.hibernate.mapping.Table;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class BootModelPreprocessor {
|
||||
static void preprocessBooModel(
|
||||
List<Binding<JaxbHbmHibernateMapping>> hbmXmlBindings,
|
||||
MetadataImplementor bootModel,
|
||||
ServiceRegistry serviceRegistry,
|
||||
TransformationState transformationState) {
|
||||
bootModel.getEntityBindings().forEach( (persistentClass) -> {
|
||||
final Table table = TransformationHelper.determineEntityTable( persistentClass );
|
||||
final EntityTypeInfo entityTypeInfo = new EntityTypeInfo( table, persistentClass );
|
||||
transformationState.getEntityInfoByName().put( persistentClass.getEntityName(), entityTypeInfo );
|
||||
buildPersistentClassPropertyInfos( persistentClass, entityTypeInfo, bootModel, transformationState );
|
||||
} );
|
||||
}
|
||||
|
||||
private static void buildPersistentClassPropertyInfos(
|
||||
PersistentClass persistentClass,
|
||||
EntityTypeInfo entityTypeInfo,
|
||||
MetadataImplementor bootModel,
|
||||
TransformationState transformationState) {
|
||||
if ( persistentClass instanceof RootClass rootClass ) {
|
||||
if ( persistentClass.getIdentifierProperty() != null ) {
|
||||
if ( persistentClass.getIdentifierProperty().getValue() instanceof Component component ) {
|
||||
final String componentRole = rootClass.getEntityName() + "." + persistentClass.getIdentifierProperty().getName();
|
||||
buildComponentEntries( componentRole, component, transformationState );
|
||||
}
|
||||
}
|
||||
else {
|
||||
assert rootClass.getIdentifier() instanceof Component;
|
||||
final String componentRole = rootClass.getEntityName() + ".id";
|
||||
buildComponentEntries( componentRole, (Component) rootClass.getIdentifier(), transformationState );
|
||||
}
|
||||
}
|
||||
|
||||
persistentClass.getProperties().forEach( (property) -> processProperty(
|
||||
entityTypeInfo.propertyInfoMap(),
|
||||
property,
|
||||
persistentClass.getEntityName(),
|
||||
transformationState
|
||||
) );
|
||||
|
||||
persistentClass.getJoins().forEach( (join) -> {
|
||||
join.getProperties().forEach( (property) -> processProperty(
|
||||
entityTypeInfo.propertyInfoMap(),
|
||||
property,
|
||||
persistentClass.getEntityName(),
|
||||
transformationState
|
||||
) );
|
||||
} );
|
||||
}
|
||||
|
||||
private static void processProperty(
|
||||
Map<String, PropertyInfo> entityTypeInfo,
|
||||
Property property,
|
||||
String entityName,
|
||||
TransformationState transformationState) {
|
||||
entityTypeInfo.put( property.getName(), new PropertyInfo( property ) );
|
||||
|
||||
if ( property.getValue() instanceof Component component ) {
|
||||
final String componentRole = entityName + "." + property.getName();
|
||||
buildComponentEntries( componentRole, component, transformationState );
|
||||
}
|
||||
else if ( property.getValue() instanceof IndexedCollection indexedCollection ) {
|
||||
if ( indexedCollection.getIndex() instanceof Component index ) {
|
||||
final String componentRole = entityName + "." + property.getName() + ".key";
|
||||
buildComponentEntries( componentRole, index, transformationState );
|
||||
}
|
||||
if ( indexedCollection.getElement() instanceof Component element ) {
|
||||
final String componentRole = entityName + "." + property.getName() + ".value";
|
||||
buildComponentEntries( componentRole, element, transformationState );
|
||||
}
|
||||
}
|
||||
else if ( property.getValue() instanceof Collection collection ) {
|
||||
if ( collection.getElement() instanceof Component element ) {
|
||||
final String componentRole = entityName + "." + property.getName() + ".value";
|
||||
buildComponentEntries( componentRole, element, transformationState );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void buildComponentEntries(
|
||||
String role,
|
||||
Component component,
|
||||
TransformationState transformationState) {
|
||||
final ComponentTypeInfo componentTypeInfo = new ComponentTypeInfo( component );
|
||||
transformationState.getEmbeddableInfoByRole().put( role, componentTypeInfo );
|
||||
|
||||
buildComponentPropertyInfos( role, component, componentTypeInfo, transformationState );
|
||||
}
|
||||
|
||||
private static void buildComponentPropertyInfos(
|
||||
String componentRole,
|
||||
Component component,
|
||||
ComponentTypeInfo componentTypeInfo,
|
||||
TransformationState transformationState) {
|
||||
|
||||
component.getProperties().forEach( (property) -> {
|
||||
processProperty( componentTypeInfo.propertyInfoMap(), property, componentRole, transformationState );
|
||||
} );
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* 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.jaxb.hbm.transform;
|
||||
|
||||
import org.hibernate.mapping.Component;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class ComponentTypeInfo extends ManagedTypeInfo {
|
||||
private final Component component;
|
||||
|
||||
public ComponentTypeInfo(Component component) {
|
||||
super( component.getTable() );
|
||||
this.component = component;
|
||||
}
|
||||
|
||||
public Component getComponent() {
|
||||
return component;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* 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.jaxb.hbm.transform;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
import org.hibernate.mapping.Table;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class EntityTypeInfo extends ManagedTypeInfo {
|
||||
private final PersistentClass persistentClass;
|
||||
|
||||
public EntityTypeInfo(
|
||||
Table table,
|
||||
PersistentClass persistentClass) {
|
||||
super( table );
|
||||
this.persistentClass = persistentClass;
|
||||
}
|
||||
|
||||
public PersistentClass getPersistentClass() {
|
||||
return persistentClass;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* 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.jaxb.hbm.transform;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.hibernate.mapping.Component;
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
import org.hibernate.mapping.Table;
|
||||
|
||||
/**
|
||||
* Common information between {@linkplain PersistentClass} and {@linkplain Component}
|
||||
* used while transforming {@code hbm.xml}
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class ManagedTypeInfo {
|
||||
private final Table table;
|
||||
private final Map<String, PropertyInfo> propertyInfoMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ManagedTypeInfo(Table table) {
|
||||
this.table = table;
|
||||
}
|
||||
|
||||
public Table table() {
|
||||
return table;
|
||||
}
|
||||
|
||||
public Map<String, PropertyInfo> propertyInfoMap() {
|
||||
return propertyInfoMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if ( obj == this ) {
|
||||
return true;
|
||||
}
|
||||
if ( obj == null || obj.getClass() != this.getClass() ) {
|
||||
return false;
|
||||
}
|
||||
var that = (ManagedTypeInfo) obj;
|
||||
return Objects.equals( this.table, that.table ) &&
|
||||
Objects.equals( this.propertyInfoMap, that.propertyInfoMap );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash( table, propertyInfoMap );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ManagedTypeInfo[" +
|
||||
"table=" + table + ", " +
|
||||
"propertyInfoMap=" + propertyInfoMap + ']';
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* 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.jaxb.hbm.transform;
|
||||
|
||||
import org.hibernate.mapping.Property;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public record PropertyInfo(Property bootModelProperty) {
|
||||
public String tableName() {
|
||||
return bootModelProperty.getValue().getTable().getName();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* 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.jaxb.hbm.transform;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.boot.jaxb.hbm.spi.EntityInfo;
|
||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmHibernateMapping;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.mapping.JoinedSubclass;
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
import org.hibernate.mapping.RootClass;
|
||||
import org.hibernate.mapping.SingleTableSubclass;
|
||||
import org.hibernate.mapping.Table;
|
||||
import org.hibernate.mapping.UnionSubclass;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class TransformationHelper {
|
||||
public static String determineEntityName(EntityInfo hbmEntity, JaxbHbmHibernateMapping hibernateMapping) {
|
||||
if ( StringHelper.isNotEmpty( hbmEntity.getEntityName() ) ) {
|
||||
return hbmEntity.getEntityName();
|
||||
}
|
||||
|
||||
final String className = hbmEntity.getName();
|
||||
assert StringHelper.isNotEmpty( className );
|
||||
return StringHelper.qualifyConditionallyIfNot( hibernateMapping.getPackage(), className );
|
||||
}
|
||||
|
||||
public static <T> void transfer(Supplier<T> source, Consumer<T> target) {
|
||||
final T value = source.get();
|
||||
if ( value != null ) {
|
||||
target.accept( value );
|
||||
}
|
||||
}
|
||||
|
||||
public static Table determineEntityTable(PersistentClass persistentClass) {
|
||||
if ( persistentClass instanceof RootClass rootClass ) {
|
||||
return rootClass.getTable();
|
||||
}
|
||||
if ( persistentClass instanceof SingleTableSubclass discriminatedSubclass ) {
|
||||
return discriminatedSubclass.getRootTable();
|
||||
}
|
||||
if ( persistentClass instanceof JoinedSubclass joinedSubclass ) {
|
||||
return joinedSubclass.getTable();
|
||||
}
|
||||
if ( persistentClass instanceof UnionSubclass unionSubclass ) {
|
||||
return unionSubclass.getTable();
|
||||
}
|
||||
throw new MappingException( "Unexpected PersistentClass subtype : " + persistentClass );
|
||||
}
|
||||
}
|
|
@ -1,377 +0,0 @@
|
|||
/*
|
||||
* 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.jaxb.hbm.transform;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.boot.MappingException;
|
||||
import org.hibernate.boot.jaxb.Origin;
|
||||
import org.hibernate.boot.jaxb.hbm.spi.EntityInfo;
|
||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmDiscriminatorSubclassEntityType;
|
||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmEntityBaseDefinition;
|
||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmHibernateMapping;
|
||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmJoinedSubclassEntityType;
|
||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmSubclassEntityBaseDefinition;
|
||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmUnionSubclassEntityType;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityMappingsImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbInheritanceImpl;
|
||||
import org.hibernate.boot.jaxb.spi.Binding;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||
|
||||
import jakarta.persistence.InheritanceType;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class TransformationPreprocessor {
|
||||
static void preprocessHbmXml(
|
||||
List<Binding<JaxbHbmHibernateMapping>> hbmXmlBindings,
|
||||
TransformationState transformationState) {
|
||||
final EntityMappingConsumer entityMappingConsumer = new EntityMappingConsumer( transformationState );
|
||||
final Map<String, JaxbEntityImpl> rootClassesMap = new HashMap<>();
|
||||
|
||||
collectGlobalState( hbmXmlBindings, transformationState );
|
||||
processStructuredHierarchies( hbmXmlBindings, rootClassesMap, entityMappingConsumer );
|
||||
processSeparatedHierarchies( hbmXmlBindings, rootClassesMap, entityMappingConsumer );
|
||||
}
|
||||
|
||||
private static void collectGlobalState(
|
||||
List<Binding<JaxbHbmHibernateMapping>> hbmXmlBindings,
|
||||
TransformationState transformationState) {
|
||||
hbmXmlBindings.forEach( (hbmBinding) -> {
|
||||
hbmBinding.getRoot().getTypedef().forEach( transformationState::acceptTypeDefinition );
|
||||
} );
|
||||
}
|
||||
|
||||
private static void processStructuredHierarchies(
|
||||
Collection<Binding<JaxbHbmHibernateMapping>> hbmXmlBindings,
|
||||
Map<String, JaxbEntityImpl> rootClassesMap,
|
||||
EntityMappingConsumer entityMappingConsumer) {
|
||||
hbmXmlBindings.forEach( (hbmBinding) -> {
|
||||
processStructuredHierarchies( rootClassesMap, entityMappingConsumer, hbmBinding );
|
||||
} );
|
||||
}
|
||||
|
||||
private static void processStructuredHierarchies(
|
||||
Map<String, JaxbEntityImpl> rootClassesMap,
|
||||
EntityMappingConsumer entityMappingConsumer,
|
||||
Binding<JaxbHbmHibernateMapping> hbmBinding) {
|
||||
final JaxbHbmHibernateMapping hibernateMapping = hbmBinding.getRoot();
|
||||
hibernateMapping.getClazz().forEach( (hbmRoot) -> {
|
||||
final JaxbEntityImpl rootJaxbEntity = makeJaxbEntity( hbmRoot, hibernateMapping );
|
||||
final String entityName = determineEntityName( hbmRoot, hibernateMapping );
|
||||
|
||||
entityMappingConsumer.accept( hbmBinding, entityName, hbmRoot, rootJaxbEntity );
|
||||
rootClassesMap.put( entityName, rootJaxbEntity );
|
||||
|
||||
if ( CollectionHelper.isNotEmpty( hbmRoot.getSubclass() ) ) {
|
||||
applyInheritanceStrategy( entityName, rootJaxbEntity, InheritanceType.SINGLE_TABLE );
|
||||
processStructuredDiscriminatorSubclasses(
|
||||
hbmRoot.getSubclass(),
|
||||
entityName,
|
||||
hbmBinding,
|
||||
entityMappingConsumer
|
||||
);
|
||||
}
|
||||
|
||||
if ( CollectionHelper.isNotEmpty( hbmRoot.getJoinedSubclass() ) ) {
|
||||
applyInheritanceStrategy( entityName, rootJaxbEntity, InheritanceType.JOINED );
|
||||
processStructuredJoinedSubclasses(
|
||||
hbmRoot.getJoinedSubclass(),
|
||||
entityName,
|
||||
hbmBinding,
|
||||
entityMappingConsumer
|
||||
);
|
||||
}
|
||||
|
||||
if ( CollectionHelper.isNotEmpty( hbmRoot.getUnionSubclass() ) ) {
|
||||
applyInheritanceStrategy( entityName, rootJaxbEntity, InheritanceType.TABLE_PER_CLASS );
|
||||
processStructuredUnionSubclasses(
|
||||
hbmRoot.getUnionSubclass(),
|
||||
entityName,
|
||||
hbmBinding,
|
||||
entityMappingConsumer
|
||||
);
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
private static void applyInheritanceStrategy(String entityName, JaxbEntityImpl rootJaxbEntity, InheritanceType strategy) {
|
||||
final JaxbInheritanceImpl existing = rootJaxbEntity.getInheritance();
|
||||
if ( existing != null ) {
|
||||
if ( existing.getStrategy() != null && existing.getStrategy() != strategy ) {
|
||||
throw new IllegalStateException( String.format(
|
||||
Locale.ROOT,
|
||||
"Root entity `%s` defined a mix of inheritance strategies; at least %s and %s",
|
||||
entityName,
|
||||
strategy,
|
||||
existing.getStrategy()
|
||||
) );
|
||||
}
|
||||
existing.setStrategy( strategy );
|
||||
}
|
||||
else {
|
||||
final JaxbInheritanceImpl created = new JaxbInheritanceImpl();
|
||||
created.setStrategy( strategy );
|
||||
rootJaxbEntity.setInheritance( created );
|
||||
}
|
||||
}
|
||||
|
||||
private static void processStructuredDiscriminatorSubclasses(
|
||||
List<JaxbHbmDiscriminatorSubclassEntityType> hbmSubclasses,
|
||||
String superEntityName,
|
||||
Binding<JaxbHbmHibernateMapping> hbmBinding,
|
||||
EntityMappingConsumer entityMappingConsumer) {
|
||||
hbmSubclasses.forEach( (hbmSubclass) -> {
|
||||
final JaxbEntityImpl subclassJaxbEntity = makeJaxbEntity( hbmSubclass, hbmBinding.getRoot() );
|
||||
final String subclassEntityName = determineEntityName( hbmSubclass, hbmBinding.getRoot() );
|
||||
entityMappingConsumer.accept( hbmBinding, subclassEntityName, hbmSubclass, subclassJaxbEntity );
|
||||
|
||||
subclassJaxbEntity.setExtends( superEntityName );
|
||||
|
||||
if ( CollectionHelper.isNotEmpty( hbmSubclass.getSubclass() ) ) {
|
||||
processStructuredDiscriminatorSubclasses(
|
||||
hbmSubclass.getSubclass(),
|
||||
subclassEntityName,
|
||||
hbmBinding,
|
||||
entityMappingConsumer
|
||||
);
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
private static void processStructuredJoinedSubclasses(
|
||||
List<JaxbHbmJoinedSubclassEntityType> hbmSubclasses,
|
||||
String superEntityName,
|
||||
Binding<JaxbHbmHibernateMapping> hbmBinding,
|
||||
EntityMappingConsumer entityMappingConsumer) {
|
||||
hbmSubclasses.forEach( (hbmSubclass) -> {
|
||||
final JaxbEntityImpl subclassJaxbEntity = makeJaxbEntity( hbmSubclass, hbmBinding.getRoot() );
|
||||
final String subclassEntityName = determineEntityName( hbmSubclass, hbmBinding.getRoot() );
|
||||
entityMappingConsumer.accept( hbmBinding, subclassEntityName, hbmSubclass, subclassJaxbEntity );
|
||||
|
||||
subclassJaxbEntity.setExtends( superEntityName );
|
||||
|
||||
if ( CollectionHelper.isNotEmpty( hbmSubclass.getJoinedSubclass() ) ) {
|
||||
processStructuredJoinedSubclasses(
|
||||
hbmSubclass.getJoinedSubclass(),
|
||||
subclassEntityName,
|
||||
hbmBinding,
|
||||
entityMappingConsumer
|
||||
);
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
private static void processStructuredUnionSubclasses(
|
||||
List<JaxbHbmUnionSubclassEntityType> hbmSubclasses,
|
||||
String superEntityName,
|
||||
Binding<JaxbHbmHibernateMapping> hbmBinding,
|
||||
EntityMappingConsumer entityMappingConsumer) {
|
||||
hbmSubclasses.forEach( (hbmSubclass) -> {
|
||||
final JaxbEntityImpl subclassJaxbEntity = makeJaxbEntity( hbmSubclass, hbmBinding.getRoot() );
|
||||
final String subclassEntityName = determineEntityName( hbmSubclass, hbmBinding.getRoot() );
|
||||
entityMappingConsumer.accept( hbmBinding, subclassEntityName, hbmSubclass, subclassJaxbEntity );
|
||||
|
||||
subclassJaxbEntity.setExtends( superEntityName );
|
||||
|
||||
if ( CollectionHelper.isNotEmpty( hbmSubclass.getUnionSubclass() ) ) {
|
||||
processStructuredUnionSubclasses(
|
||||
hbmSubclass.getUnionSubclass(),
|
||||
subclassEntityName,
|
||||
hbmBinding,
|
||||
entityMappingConsumer
|
||||
);
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
private static void processSeparatedHierarchies(
|
||||
Collection<Binding<JaxbHbmHibernateMapping>> hbmXmlBindings,
|
||||
Map<String, JaxbEntityImpl> rootClassesMap,
|
||||
EntityMappingConsumer entityMappingConsumer) {
|
||||
hbmXmlBindings.forEach( (hbmBinding) -> {
|
||||
processSeparatedHierarchies( rootClassesMap, entityMappingConsumer, hbmBinding );
|
||||
|
||||
} );
|
||||
}
|
||||
|
||||
private static void processSeparatedHierarchies(
|
||||
Map<String, JaxbEntityImpl> rootClassesMap,
|
||||
EntityMappingConsumer entityMappingConsumer,
|
||||
Binding<JaxbHbmHibernateMapping> hbmBinding) {
|
||||
final JaxbHbmHibernateMapping hibernateMapping = hbmBinding.getRoot();
|
||||
|
||||
processTopLevelDiscriminatedSubclasses( rootClassesMap, entityMappingConsumer, hbmBinding, hibernateMapping );
|
||||
processTopLevelJoinedSubclasses( rootClassesMap, entityMappingConsumer, hbmBinding, hibernateMapping );
|
||||
processTopLevelUnionSubclasses( rootClassesMap, entityMappingConsumer, hbmBinding, hibernateMapping );
|
||||
}
|
||||
|
||||
private static void processTopLevelDiscriminatedSubclasses(
|
||||
Map<String, JaxbEntityImpl> rootClassesMap,
|
||||
EntityMappingConsumer entityMappingConsumer,
|
||||
Binding<JaxbHbmHibernateMapping> hbmBinding,
|
||||
JaxbHbmHibernateMapping hibernateMapping) {
|
||||
hibernateMapping.getSubclass().forEach( (hbmSubclass) -> {
|
||||
final String entityName = determineEntityName( hbmSubclass, hibernateMapping );
|
||||
applyExtendedInheritanceStrategy(
|
||||
entityName,
|
||||
InheritanceType.SINGLE_TABLE,
|
||||
hbmSubclass,
|
||||
hibernateMapping,
|
||||
rootClassesMap,
|
||||
hbmBinding.getOrigin()
|
||||
);
|
||||
|
||||
final JaxbEntityImpl jaxbEntity = makeJaxbEntity( hbmSubclass, hibernateMapping );
|
||||
entityMappingConsumer.accept( hbmBinding, entityName, hbmSubclass, jaxbEntity );
|
||||
|
||||
if ( CollectionHelper.isNotEmpty( hbmSubclass.getSubclass() ) ) {
|
||||
processStructuredDiscriminatorSubclasses(
|
||||
hbmSubclass.getSubclass(),
|
||||
entityName,
|
||||
hbmBinding,
|
||||
entityMappingConsumer
|
||||
);
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
private static void processTopLevelJoinedSubclasses(
|
||||
Map<String, JaxbEntityImpl> rootClassesMap,
|
||||
EntityMappingConsumer entityMappingConsumer,
|
||||
Binding<JaxbHbmHibernateMapping> hbmBinding,
|
||||
JaxbHbmHibernateMapping hibernateMapping) {
|
||||
hibernateMapping.getJoinedSubclass().forEach( (hbmSubclass) -> {
|
||||
final String entityName = determineEntityName( hbmSubclass, hibernateMapping );
|
||||
applyExtendedInheritanceStrategy(
|
||||
entityName,
|
||||
InheritanceType.JOINED,
|
||||
hbmSubclass,
|
||||
hibernateMapping,
|
||||
rootClassesMap,
|
||||
hbmBinding.getOrigin()
|
||||
);
|
||||
|
||||
final JaxbEntityImpl jaxbEntity = makeJaxbEntity( hbmSubclass, hibernateMapping );
|
||||
entityMappingConsumer.accept( hbmBinding, entityName, hbmSubclass, jaxbEntity );
|
||||
|
||||
if ( CollectionHelper.isNotEmpty( hbmSubclass.getJoinedSubclass() ) ) {
|
||||
processStructuredJoinedSubclasses(
|
||||
hbmSubclass.getJoinedSubclass(),
|
||||
entityName,
|
||||
hbmBinding,
|
||||
entityMappingConsumer
|
||||
);
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
private static void processTopLevelUnionSubclasses(
|
||||
Map<String, JaxbEntityImpl> rootClassesMap,
|
||||
EntityMappingConsumer entityMappingConsumer,
|
||||
Binding<JaxbHbmHibernateMapping> hbmBinding,
|
||||
JaxbHbmHibernateMapping hibernateMapping) {
|
||||
hibernateMapping.getUnionSubclass().forEach( (hbmSubclass) -> {
|
||||
final String entityName = determineEntityName( hbmSubclass, hibernateMapping );
|
||||
applyExtendedInheritanceStrategy(
|
||||
entityName,
|
||||
InheritanceType.TABLE_PER_CLASS,
|
||||
hbmSubclass,
|
||||
hibernateMapping,
|
||||
rootClassesMap,
|
||||
hbmBinding.getOrigin()
|
||||
);
|
||||
|
||||
final JaxbEntityImpl jaxbEntity = makeJaxbEntity( hbmSubclass, hibernateMapping );
|
||||
entityMappingConsumer.accept( hbmBinding, entityName, hbmSubclass, jaxbEntity );
|
||||
|
||||
if ( CollectionHelper.isNotEmpty( hbmSubclass.getUnionSubclass() ) ) {
|
||||
processStructuredUnionSubclasses(
|
||||
hbmSubclass.getUnionSubclass(),
|
||||
entityName,
|
||||
hbmBinding,
|
||||
entityMappingConsumer
|
||||
);
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
private static void applyExtendedInheritanceStrategy(
|
||||
String entityName,
|
||||
InheritanceType strategy,
|
||||
JaxbHbmSubclassEntityBaseDefinition hbmSubclass,
|
||||
JaxbHbmHibernateMapping hibernateMapping,
|
||||
Map<String, JaxbEntityImpl> rootClassesMap,
|
||||
Origin origin) {
|
||||
if ( StringHelper.isEmpty( hbmSubclass.getExtends() ) ) {
|
||||
throw new MappingException( "Separated inheritance mapping did not specify extends", origin );
|
||||
}
|
||||
|
||||
// we only have something to do here if the extends names a root entity
|
||||
final JaxbEntityImpl superRoot = TransformationState.resolveEntityReference(
|
||||
hbmSubclass.getExtends(),
|
||||
hibernateMapping,
|
||||
rootClassesMap
|
||||
);
|
||||
|
||||
if ( superRoot != null ) {
|
||||
applyInheritanceStrategy( entityName, superRoot, strategy );
|
||||
}
|
||||
}
|
||||
|
||||
private static JaxbEntityImpl makeJaxbEntity(
|
||||
JaxbHbmEntityBaseDefinition hbmEntity,
|
||||
JaxbHbmHibernateMapping hibernateMapping) {
|
||||
final JaxbEntityImpl jaxbEntity = new JaxbEntityImpl();
|
||||
if ( StringHelper.isNotEmpty( hbmEntity.getName() ) ) {
|
||||
jaxbEntity.setClazz( StringHelper.qualifyConditionallyIfNot( hibernateMapping.getPackage(), hbmEntity.getName() ) );
|
||||
}
|
||||
if ( StringHelper.isNotEmpty( hbmEntity.getEntityName() ) ) {
|
||||
jaxbEntity.setName( hbmEntity.getEntityName() );
|
||||
}
|
||||
return jaxbEntity;
|
||||
}
|
||||
|
||||
private static String determineEntityName(EntityInfo entityInfo, JaxbHbmHibernateMapping hibernateMapping) {
|
||||
if ( entityInfo.getEntityName() != null ) {
|
||||
return entityInfo.getEntityName();
|
||||
}
|
||||
return StringHelper.qualifyConditionallyIfNot( hibernateMapping.getPackage(), entityInfo.getName() );
|
||||
}
|
||||
|
||||
|
||||
private record EntityMappingConsumer(TransformationState transformationState) {
|
||||
|
||||
public void accept(
|
||||
Binding<JaxbHbmHibernateMapping> hbmBinding,
|
||||
String registrationName,
|
||||
JaxbHbmEntityBaseDefinition hbmEntity,
|
||||
JaxbEntityImpl mappingEntity) {
|
||||
final Binding<JaxbEntityMappingsImpl> mappingBinding = resolveMappingBinding( hbmBinding );
|
||||
mappingBinding.getRoot().getEntities().add( mappingEntity );
|
||||
transformationState.getEntityXref().put( hbmEntity, mappingEntity );
|
||||
transformationState.getEntityMap().put( registrationName, mappingEntity );
|
||||
}
|
||||
|
||||
private Binding<JaxbEntityMappingsImpl> resolveMappingBinding(Binding<JaxbHbmHibernateMapping> hbmBinding) {
|
||||
for ( int i = 0; i < transformationState.getHbmBindings().size(); i++ ) {
|
||||
if ( hbmBinding == transformationState.getHbmBindings().get( i ) ) {
|
||||
return transformationState.getMappingBindings().get( i );
|
||||
}
|
||||
}
|
||||
|
||||
throw new IllegalStateException( "Could not resolve corresponding mapping binding : " + hbmBinding );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,145 +7,74 @@
|
|||
package org.hibernate.boot.jaxb.hbm.transform;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.boot.jaxb.Origin;
|
||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmEntityBaseDefinition;
|
||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmFilterDefinitionType;
|
||||
import org.hibernate.boot.jaxb.hbm.spi.EntityInfo;
|
||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmHibernateMapping;
|
||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmTypeDefinitionType;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEmbeddableImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityMappingsImpl;
|
||||
import org.hibernate.boot.jaxb.spi.Binding;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
class TransformationState {
|
||||
private final List<Binding<JaxbHbmHibernateMapping>> hbmBindings;
|
||||
private final List<Binding<JaxbEntityMappingsImpl>> mappingBindings;
|
||||
public class TransformationState {
|
||||
private final Map<JaxbHbmHibernateMapping,JaxbEntityMappingsImpl> jaxbRootMap = new HashMap<>();
|
||||
|
||||
private final Map<String, JaxbEntityImpl> entityMap = new HashMap<>();
|
||||
private final Map<JaxbHbmEntityBaseDefinition, JaxbEntityImpl> entityXref = new HashMap<>();
|
||||
private final Map<String,JaxbHbmHibernateMapping> entityToHbmXmlMap = new HashMap<>();
|
||||
private final Map<String, JaxbEntityMappingsImpl> entityToMappingXmlMap = new HashMap<>();
|
||||
|
||||
private final Map<String, JaxbEntityImpl> mappingEntityByName = new HashMap<>();
|
||||
private final Map<String, EntityInfo> hbmEntityByName = new HashMap<>();
|
||||
private final Map<String, EntityTypeInfo> entityInfoByName = new HashMap<>();
|
||||
|
||||
private final Map<String, JaxbEmbeddableImpl> embeddableByName = new HashMap<>();
|
||||
private final Map<String, JaxbEmbeddableImpl> embeddableByRole = new HashMap<>();
|
||||
private final Map<String, ComponentTypeInfo> embeddableInfoByRole = new HashMap<>();
|
||||
|
||||
private final Map<String, JaxbHbmTypeDefinitionType> typeDefMap = new HashMap<>();
|
||||
private final Map<String, JaxbHbmFilterDefinitionType> filterDefMap = new HashMap<>();
|
||||
|
||||
public TransformationState(List<Binding<JaxbHbmHibernateMapping>> hbmBindings) {
|
||||
this.hbmBindings = hbmBindings;
|
||||
this.mappingBindings = CollectionHelper.arrayList( hbmBindings.size() );
|
||||
for ( Binding<JaxbHbmHibernateMapping> hbmBinding : this.hbmBindings ) {
|
||||
final JaxbEntityMappingsImpl mappingRoot = new JaxbEntityMappingsImpl();
|
||||
mappingRoot.setDescription( String.format(
|
||||
Locale.ROOT,
|
||||
"Generated by Hibernate HbmXmlTransformer from %s (%s)",
|
||||
hbmBinding.getOrigin().getName(),
|
||||
hbmBinding.getOrigin().getType()
|
||||
) );
|
||||
mappingBindings.add( new Binding<>( mappingRoot, hbmBinding.getOrigin() ) );
|
||||
}
|
||||
public TransformationState() {
|
||||
}
|
||||
|
||||
public static String resolveEntityReferenceName(
|
||||
String referenceName,
|
||||
JaxbHbmHibernateMapping hibernateMapping,
|
||||
Map<String,JaxbEntityImpl> entityMap) {
|
||||
|
||||
// First try it as a direct key reference; this covers the case of:
|
||||
// 1. entity-name
|
||||
// 2. fully-qualified name
|
||||
final JaxbEntityImpl byDirectName = entityMap.get( referenceName );
|
||||
if ( byDirectName != null ) {
|
||||
return referenceName;
|
||||
}
|
||||
|
||||
// Next, try as an implicitly qualified name
|
||||
if ( StringHelper.isNotEmpty( hibernateMapping.getPackage() ) ) {
|
||||
final String qualifiedName = StringHelper.qualify( hibernateMapping.getPackage(), referenceName );
|
||||
final JaxbEntityImpl byQualifiedName = entityMap.get( qualifiedName );
|
||||
if ( byQualifiedName != null ) {
|
||||
return qualifiedName;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
public Map<JaxbHbmHibernateMapping, JaxbEntityMappingsImpl> getJaxbRootMap() {
|
||||
return jaxbRootMap;
|
||||
}
|
||||
|
||||
public static String requireEntityReferenceName(
|
||||
String referenceName,
|
||||
JaxbHbmHibernateMapping hibernateMapping,
|
||||
Map<String,JaxbEntityImpl> entityMap,
|
||||
Origin origin) {
|
||||
final String resolved = resolveEntityReferenceName( referenceName, hibernateMapping, entityMap );
|
||||
if ( resolved == null ) {
|
||||
throw new UnknownEntityReferenceException( referenceName, origin );
|
||||
}
|
||||
return resolved;
|
||||
public Map<String, JaxbHbmHibernateMapping> getEntityToHbmXmlMap() {
|
||||
return entityToHbmXmlMap;
|
||||
}
|
||||
|
||||
public static JaxbEntityImpl resolveEntityReference(
|
||||
String referenceName,
|
||||
JaxbHbmHibernateMapping hibernateMapping,
|
||||
Map<String,JaxbEntityImpl> entityMap) {
|
||||
|
||||
// First try it as a direct key reference; this covers the case of:
|
||||
// 1. entity-name
|
||||
// 2. fully-qualified name
|
||||
final JaxbEntityImpl byDirectName = entityMap.get( referenceName );
|
||||
if ( byDirectName != null ) {
|
||||
return byDirectName;
|
||||
}
|
||||
|
||||
// Next, try as an implicitly qualified name
|
||||
if ( StringHelper.isNotEmpty( hibernateMapping.getPackage() ) ) {
|
||||
final String qualifiedName = StringHelper.qualify( hibernateMapping.getPackage(), referenceName );
|
||||
final JaxbEntityImpl byQualifiedName = entityMap.get( qualifiedName );
|
||||
if ( byQualifiedName != null ) {
|
||||
return byQualifiedName;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
public Map<String, JaxbEntityMappingsImpl> getEntityToMappingXmlMap() {
|
||||
return entityToMappingXmlMap;
|
||||
}
|
||||
|
||||
public static JaxbEntityImpl requireEntityReference(
|
||||
String referenceName,
|
||||
JaxbHbmHibernateMapping hibernateMapping,
|
||||
Map<String,JaxbEntityImpl> entityMap,
|
||||
Origin origin) {
|
||||
final JaxbEntityImpl resolved = resolveEntityReference( referenceName, hibernateMapping, entityMap );
|
||||
if ( resolved == null ) {
|
||||
throw new UnknownEntityReferenceException( referenceName, origin );
|
||||
}
|
||||
return resolved;
|
||||
public Map<String, JaxbEntityImpl> getMappingEntityByName() {
|
||||
return mappingEntityByName;
|
||||
}
|
||||
|
||||
|
||||
public List<Binding<JaxbHbmHibernateMapping>> getHbmBindings() {
|
||||
return hbmBindings;
|
||||
public Map<String, EntityInfo> getHbmEntityByName() {
|
||||
return hbmEntityByName;
|
||||
}
|
||||
|
||||
public List<Binding<JaxbEntityMappingsImpl>> getMappingBindings() {
|
||||
return mappingBindings;
|
||||
public Map<String, EntityTypeInfo> getEntityInfoByName() {
|
||||
return entityInfoByName;
|
||||
}
|
||||
|
||||
public Map<String, JaxbEntityImpl> getEntityMap() {
|
||||
return entityMap;
|
||||
public Map<String, JaxbEmbeddableImpl> getEmbeddableByName() {
|
||||
return embeddableByName;
|
||||
}
|
||||
|
||||
public Map<JaxbHbmEntityBaseDefinition, JaxbEntityImpl> getEntityXref() {
|
||||
return entityXref;
|
||||
public Map<String, JaxbEmbeddableImpl> getEmbeddableByRole() {
|
||||
return embeddableByRole;
|
||||
}
|
||||
|
||||
public Map<String, JaxbHbmTypeDefinitionType> getTypeDefinitionMap() {
|
||||
public Map<String, ComponentTypeInfo> getEmbeddableInfoByRole() {
|
||||
return embeddableInfoByRole;
|
||||
}
|
||||
|
||||
public Map<String, JaxbHbmTypeDefinitionType> getTypeDefMap() {
|
||||
return typeDefMap;
|
||||
}
|
||||
|
||||
public void acceptTypeDefinition(JaxbHbmTypeDefinitionType hbmTypeDef) {
|
||||
typeDefMap.put( hbmTypeDef.getName(), hbmTypeDef );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,158 @@
|
|||
/*
|
||||
* 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.jaxb.hbm.transform;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.hibernate.boot.jaxb.hbm.spi.EntityInfo;
|
||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmDiscriminatorSubclassEntityType;
|
||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmHibernateMapping;
|
||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmJoinedSubclassEntityType;
|
||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmRootEntityType;
|
||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmUnionSubclassEntityType;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityMappingsImpl;
|
||||
import org.hibernate.boot.jaxb.spi.Binding;
|
||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class XmlPreprocessor {
|
||||
public static List<Binding<JaxbEntityMappingsImpl>> preprocessHbmXml(
|
||||
List<Binding<JaxbHbmHibernateMapping>> hbmXmlBindings,
|
||||
TransformationState transformationState) {
|
||||
final List<Binding<JaxbEntityMappingsImpl>> mappingBindings = CollectionHelper.arrayList( hbmXmlBindings.size() );
|
||||
hbmXmlBindings.forEach( (hbmXmlBinding) -> preProcessHbmXml( hbmXmlBinding, mappingBindings, transformationState ) );
|
||||
return mappingBindings;
|
||||
}
|
||||
|
||||
private static void preProcessHbmXml(
|
||||
Binding<JaxbHbmHibernateMapping> hbmXmlBinding,
|
||||
List<Binding<JaxbEntityMappingsImpl>> mappingBindings,
|
||||
TransformationState transformationState) {
|
||||
final JaxbHbmHibernateMapping hbmRoot = hbmXmlBinding.getRoot();
|
||||
final JaxbEntityMappingsImpl mappingRoot = new JaxbEntityMappingsImpl();
|
||||
transformationState.getJaxbRootMap().put( hbmRoot, mappingRoot );
|
||||
|
||||
mappingRoot.setDescription( String.format(
|
||||
Locale.ROOT,
|
||||
"Generated by Hibernate HbmXmlTransformer from %s (%s)",
|
||||
hbmXmlBinding.getOrigin().getName(),
|
||||
hbmXmlBinding.getOrigin().getType()
|
||||
) );
|
||||
mappingBindings.add( new Binding<>( mappingRoot, hbmXmlBinding.getOrigin() ) );
|
||||
|
||||
hbmRoot.getTypedef().forEach( hbmTypeDef -> {
|
||||
transformationState.getTypeDefMap().put( hbmTypeDef.getName(), hbmTypeDef );
|
||||
} );
|
||||
|
||||
hbmRoot.getClazz().forEach( (hbmRootEntity) -> {
|
||||
preProcessRooEntity( hbmRootEntity, hbmRoot, mappingRoot, transformationState );
|
||||
} );
|
||||
|
||||
hbmRoot.getSubclass().forEach( (hbmSubclass) -> {
|
||||
preProcessSubclass( hbmSubclass, hbmRoot, mappingRoot, transformationState );
|
||||
} );
|
||||
|
||||
hbmRoot.getJoinedSubclass().forEach( (hbmSubclass) -> {
|
||||
preProcessJoinedSubclass( hbmSubclass, hbmRoot, mappingRoot, transformationState );
|
||||
} );
|
||||
|
||||
hbmRoot.getUnionSubclass().forEach( (hbmSubclass) -> {
|
||||
preProcessUnionSubclass( hbmSubclass, hbmRoot, mappingRoot, transformationState );
|
||||
} );
|
||||
}
|
||||
|
||||
private static void preProcessRooEntity(
|
||||
JaxbHbmRootEntityType hbmRootEntity,
|
||||
JaxbHbmHibernateMapping hbmRoot,
|
||||
JaxbEntityMappingsImpl mappingRoot,
|
||||
TransformationState transformationState) {
|
||||
final JaxbEntityImpl mappingEntity = new JaxbEntityImpl();
|
||||
mappingRoot.getEntities().add( mappingEntity );
|
||||
|
||||
commonEntityPreprocessing( hbmRootEntity, hbmRoot, mappingRoot, transformationState, mappingEntity );
|
||||
|
||||
hbmRootEntity.getSubclass().forEach( (hbmSubclass) -> {
|
||||
preProcessSubclass( hbmSubclass, hbmRoot, mappingRoot, transformationState );
|
||||
} );
|
||||
|
||||
hbmRootEntity.getJoinedSubclass().forEach( (hbmSubclass) -> {
|
||||
preProcessJoinedSubclass( hbmSubclass, hbmRoot, mappingRoot, transformationState );
|
||||
} );
|
||||
|
||||
hbmRootEntity.getUnionSubclass().forEach( (hbmSubclass) -> {
|
||||
preProcessUnionSubclass( hbmSubclass, hbmRoot, mappingRoot, transformationState );
|
||||
} );
|
||||
}
|
||||
|
||||
private static void commonEntityPreprocessing(
|
||||
EntityInfo hbmEntity,
|
||||
JaxbHbmHibernateMapping hbmRoot,
|
||||
JaxbEntityMappingsImpl mappingRoot,
|
||||
TransformationState transformationState,
|
||||
JaxbEntityImpl mappingEntity) {
|
||||
// apply some basic info to the mapping.xsd entity
|
||||
TransformationHelper.transfer( hbmEntity::getEntityName, mappingEntity::setName );
|
||||
TransformationHelper.transfer( hbmEntity::getName, mappingEntity::setClazz );
|
||||
|
||||
final String entityName = TransformationHelper.determineEntityName( hbmEntity, hbmRoot );
|
||||
transformationState.getEntityToHbmXmlMap().put( entityName, hbmRoot );
|
||||
transformationState.getEntityToMappingXmlMap().put( entityName, mappingRoot );
|
||||
transformationState.getHbmEntityByName().put( entityName, hbmEntity );
|
||||
transformationState.getMappingEntityByName().put( entityName, mappingEntity );
|
||||
|
||||
// todo (7.0) : walk attributes looking for components
|
||||
}
|
||||
|
||||
private static void preProcessSubclass(
|
||||
JaxbHbmDiscriminatorSubclassEntityType hbmSubclass,
|
||||
JaxbHbmHibernateMapping hbmRoot,
|
||||
JaxbEntityMappingsImpl mappingRoot,
|
||||
TransformationState transformationState) {
|
||||
final JaxbEntityImpl mappingEntity = new JaxbEntityImpl();
|
||||
mappingRoot.getEntities().add( mappingEntity );
|
||||
|
||||
commonEntityPreprocessing( hbmSubclass, hbmRoot, mappingRoot, transformationState, mappingEntity );
|
||||
|
||||
hbmSubclass.getSubclass().forEach( (hbmSubclassSubclass) -> {
|
||||
preProcessSubclass( hbmSubclassSubclass, hbmRoot, mappingRoot, transformationState );
|
||||
} );
|
||||
}
|
||||
|
||||
private static void preProcessJoinedSubclass(
|
||||
JaxbHbmJoinedSubclassEntityType hbmSubclass,
|
||||
JaxbHbmHibernateMapping hbmRoot,
|
||||
JaxbEntityMappingsImpl mappingRoot,
|
||||
TransformationState transformationState) {
|
||||
final JaxbEntityImpl mappingEntity = new JaxbEntityImpl();
|
||||
mappingRoot.getEntities().add( mappingEntity );
|
||||
|
||||
commonEntityPreprocessing( hbmSubclass, hbmRoot, mappingRoot, transformationState, mappingEntity );
|
||||
|
||||
hbmSubclass.getJoinedSubclass().forEach( (hbmSubclassSubclass) -> {
|
||||
preProcessJoinedSubclass( hbmSubclassSubclass, hbmRoot, mappingRoot, transformationState );
|
||||
} );
|
||||
}
|
||||
|
||||
private static void preProcessUnionSubclass(
|
||||
JaxbHbmUnionSubclassEntityType hbmSubclass,
|
||||
JaxbHbmHibernateMapping hbmRoot,
|
||||
JaxbEntityMappingsImpl mappingRoot,
|
||||
TransformationState transformationState) {
|
||||
final JaxbEntityImpl mappingEntity = new JaxbEntityImpl();
|
||||
mappingRoot.getEntities().add( mappingEntity );
|
||||
|
||||
commonEntityPreprocessing( hbmSubclass, hbmRoot, mappingRoot, transformationState, mappingEntity );
|
||||
|
||||
hbmSubclass.getUnionSubclass().forEach( (hbmSubclassSubclass) -> {
|
||||
preProcessUnionSubclass( hbmSubclassSubclass, hbmRoot, mappingRoot, transformationState );
|
||||
} );
|
||||
}
|
||||
}
|
|
@ -52,7 +52,6 @@ public class MappingBinder extends AbstractBinder<JaxbBindableMappingDescriptor>
|
|||
private final XMLEventFactory xmlEventFactory = XMLEventFactory.newInstance();
|
||||
|
||||
private final Supplier<Options> optionsAccess;
|
||||
private final Supplier<UnsupportedFeatureHandling> unsupportedHandlingAccess;
|
||||
|
||||
private JAXBContext hbmJaxbContext;
|
||||
private JAXBContext entityMappingsJaxbContext;
|
||||
|
@ -84,7 +83,6 @@ public class MappingBinder extends AbstractBinder<JaxbBindableMappingDescriptor>
|
|||
Supplier<UnsupportedFeatureHandling> unsupportedHandlingAccess) {
|
||||
super( resourceStreamLocator );
|
||||
this.optionsAccess = optionsAccess;
|
||||
this.unsupportedHandlingAccess = unsupportedHandlingAccess;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -104,7 +102,6 @@ public class MappingBinder extends AbstractBinder<JaxbBindableMappingDescriptor>
|
|||
|
||||
if ( settingsAccess == null ) {
|
||||
this.optionsAccess = () -> VALIDATING;
|
||||
this.unsupportedHandlingAccess = () -> UnsupportedFeatureHandling.ERROR;
|
||||
}
|
||||
else {
|
||||
this.optionsAccess = () -> new Options() {
|
||||
|
@ -117,11 +114,6 @@ public class MappingBinder extends AbstractBinder<JaxbBindableMappingDescriptor>
|
|||
return BOOLEAN.convert( setting );
|
||||
}
|
||||
};
|
||||
|
||||
this.unsupportedHandlingAccess = () -> {
|
||||
final Object setting = settingsAccess.apply( AvailableSettings.TRANSFORM_HBM_XML_FEATURE_HANDLING );
|
||||
return UnsupportedFeatureHandling.fromSetting( setting, UnsupportedFeatureHandling.ERROR );
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,8 +122,7 @@ public class MappingBinder extends AbstractBinder<JaxbBindableMappingDescriptor>
|
|||
serviceRegistry.getService( ClassLoaderService.class ),
|
||||
(settingName) -> {
|
||||
final ConfigurationService configurationService;
|
||||
if ( serviceRegistry instanceof ServiceRegistryImplementor ) {
|
||||
final ServiceRegistryImplementor serviceRegistryImplementor = (ServiceRegistryImplementor) serviceRegistry;
|
||||
if ( serviceRegistry instanceof ServiceRegistryImplementor serviceRegistryImplementor ) {
|
||||
configurationService = serviceRegistryImplementor.fromRegistryOrChildren( ConfigurationService.class );
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -48,6 +48,7 @@ import org.hibernate.annotations.TimeZoneColumn;
|
|||
import org.hibernate.annotations.TimeZoneStorage;
|
||||
import org.hibernate.annotations.TimeZoneStorageType;
|
||||
import org.hibernate.annotations.Type;
|
||||
import org.hibernate.boot.internal.AnyKeyType;
|
||||
import org.hibernate.boot.model.TypeDefinition;
|
||||
import org.hibernate.boot.model.convert.spi.ConverterDescriptor;
|
||||
import org.hibernate.boot.spi.AccessType;
|
||||
|
@ -898,6 +899,18 @@ public class BasicValueBinder implements JdbcTypeIndicators {
|
|||
.getDescriptor( impl );
|
||||
}
|
||||
|
||||
// mainly used in XML interpretation
|
||||
final AnyKeyType anyKeyTypeAnn = memberDetails.locateAnnotationUsage( AnyKeyType.class, getSourceModelContext() );
|
||||
if ( anyKeyTypeAnn != null ) {
|
||||
final String namedType = anyKeyTypeAnn.value();
|
||||
final BasicType<Object> registeredType = typeConfiguration.getBasicTypeRegistry().getRegisteredType( namedType );
|
||||
if ( registeredType == null ) {
|
||||
throw new MappingException( "Unrecognized @AnyKeyType value - " + namedType );
|
||||
}
|
||||
//noinspection rawtypes
|
||||
return (BasicJavaType) registeredType.getJavaTypeDescriptor();
|
||||
}
|
||||
|
||||
throw new MappingException("Could not determine key type for '@Any' mapping (specify '@AnyKeyJavaType' or '@AnyKeyJavaClass')");
|
||||
};
|
||||
|
||||
|
|
|
@ -64,8 +64,6 @@ public class ManagedResourcesImpl implements ManagedResources {
|
|||
MetadataSources sources,
|
||||
ManagedResourcesImpl impl,
|
||||
BootstrapContext bootstrapContext) {
|
||||
impl.mappingFileBindings.addAll( (List) sources.getMappingXmlBindings() );
|
||||
|
||||
if ( !bootstrapContext.getMetadataBuildingOptions().isXmlMappingEnabled() ) {
|
||||
BootLogging.BOOT_LOGGER.debugf(
|
||||
"Ignoring %s XML mappings due to `%s`",
|
||||
|
@ -74,31 +72,7 @@ public class ManagedResourcesImpl implements ManagedResources {
|
|||
);
|
||||
return;
|
||||
}
|
||||
|
||||
final ConfigurationService configurationService = bootstrapContext.getServiceRegistry().getService( ConfigurationService.class );
|
||||
// NOTE : the configurationService nullness checking is here for a few tests using mocks
|
||||
final boolean transformHbm = configurationService != null
|
||||
&& configurationService.getSetting( MappingSettings.TRANSFORM_HBM_XML, BOOLEAN,false );
|
||||
|
||||
if ( !transformHbm ) {
|
||||
// we are not transforming hbm.xml to mapping.xml, so just add the hbm.xml bindings as-is
|
||||
impl.mappingFileBindings.addAll( (List) sources.getHbmXmlBindings() );
|
||||
for ( Binding<JaxbHbmHibernateMapping> hbmXmlBinding : sources.getHbmXmlBindings() ) {
|
||||
final Origin origin = hbmXmlBinding.getOrigin();
|
||||
DeprecationLogger.DEPRECATION_LOGGER.logDeprecatedHbmXmlProcessing( origin.getType(), origin.getName() );
|
||||
}
|
||||
}
|
||||
else {
|
||||
// do the transformations
|
||||
final List<Binding<JaxbEntityMappingsImpl>> transformed = HbmXmlTransformer.transform(
|
||||
sources.getHbmXmlBindings(),
|
||||
UnsupportedFeatureHandling.fromSetting(
|
||||
configurationService.getSettings().get( AvailableSettings.TRANSFORM_HBM_XML_FEATURE_HANDLING ),
|
||||
UnsupportedFeatureHandling.ERROR
|
||||
)
|
||||
);
|
||||
impl.mappingFileBindings.addAll( (List) transformed );
|
||||
}
|
||||
impl.mappingFileBindings.addAll( (List) sources.getXmlBindings() );
|
||||
}
|
||||
|
||||
public ManagedResourcesImpl() {
|
||||
|
|
|
@ -9,23 +9,21 @@ package org.hibernate.boot.model.source.internal.annotations;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.boot.jaxb.Origin;
|
||||
import org.hibernate.boot.jaxb.SourceType;
|
||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmHibernateMapping;
|
||||
import org.hibernate.boot.jaxb.hbm.transform.HbmXmlTransformer;
|
||||
import org.hibernate.boot.jaxb.hbm.transform.UnsupportedFeatureHandling;
|
||||
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.model.convert.spi.ConverterDescriptor;
|
||||
import org.hibernate.boot.model.process.spi.ManagedResources;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||
import org.hibernate.models.spi.ClassDetails;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
|
||||
import static org.hibernate.boot.jaxb.SourceType.OTHER;
|
||||
|
||||
|
@ -78,8 +76,7 @@ public class AdditionalManagedResourcesImpl implements ManagedResources {
|
|||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
//noinspection unchecked,rawtypes
|
||||
return (Collection) xmlMappings;
|
||||
return xmlMappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -89,37 +86,18 @@ public class AdditionalManagedResourcesImpl implements ManagedResources {
|
|||
|
||||
public static class Builder {
|
||||
private final MappingBinder mappingBinder;
|
||||
private final boolean transformHbmMappings;
|
||||
|
||||
private List<Class<?>> classes;
|
||||
private List<ClassDetails> classDetails;
|
||||
private List<String> packageNames;
|
||||
private Collection<Binding<JaxbBindableMappingDescriptor>> xmlMappings;
|
||||
|
||||
public Builder(boolean validateMappings, boolean transformHbmMappings) {
|
||||
this( transformHbmMappings, new MappingBinder.Options() {
|
||||
@Override
|
||||
public boolean validateMappings() {
|
||||
return validateMappings;
|
||||
}
|
||||
} );
|
||||
public Builder(ServiceRegistry serviceRegistry) {
|
||||
this.mappingBinder = new MappingBinder( serviceRegistry );
|
||||
}
|
||||
|
||||
public Builder() {
|
||||
this( false, new MappingBinder.Options() {
|
||||
@Override
|
||||
public boolean validateMappings() {
|
||||
return false;
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
public Builder(boolean transformHbmMappings, MappingBinder.Options options) {
|
||||
this.transformHbmMappings = transformHbmMappings;
|
||||
this.mappingBinder = new MappingBinder(
|
||||
(resourceName) -> Builder.class.getClassLoader().getResourceAsStream( resourceName ),
|
||||
options
|
||||
);
|
||||
this( new StandardServiceRegistryBuilder().build() );
|
||||
}
|
||||
|
||||
public Builder addLoadedClasses(List<Class<?>> additionalClasses) {
|
||||
|
@ -159,28 +137,6 @@ public class AdditionalManagedResourcesImpl implements ManagedResources {
|
|||
}
|
||||
|
||||
public ManagedResources build() {
|
||||
if ( CollectionHelper.isNotEmpty( xmlMappings ) ) {
|
||||
if ( transformHbmMappings ) {
|
||||
final List<Binding<JaxbHbmHibernateMapping>> hbmBindings = new ArrayList<>();
|
||||
final Iterator<Binding<JaxbBindableMappingDescriptor>> iterator = xmlMappings.iterator();
|
||||
while ( iterator.hasNext() ) {
|
||||
final Binding<JaxbBindableMappingDescriptor> xmlBinding = iterator.next();
|
||||
if ( xmlBinding.getRoot() instanceof JaxbHbmHibernateMapping ) {
|
||||
//noinspection rawtypes,unchecked
|
||||
hbmBindings.add( (Binding) xmlBinding );
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
if ( !hbmBindings.isEmpty() ) {
|
||||
final List<Binding<JaxbEntityMappingsImpl>> transformed = HbmXmlTransformer.transform(
|
||||
hbmBindings,
|
||||
UnsupportedFeatureHandling.ERROR
|
||||
);
|
||||
//noinspection rawtypes,unchecked
|
||||
xmlMappings.addAll( (List) transformed );
|
||||
}
|
||||
}
|
||||
}
|
||||
return new AdditionalManagedResourcesImpl( classes, classDetails, packageNames, xmlMappings );
|
||||
}
|
||||
|
||||
|
|
|
@ -115,7 +115,9 @@ public class AnnotationMetadataSourceProcessorImpl implements MetadataSourceProc
|
|||
List<JaxbEntityMappingsImpl> additionalJaxbMappings,
|
||||
MetadataBuildingContextRootImpl rootMetadataBuildingContext,
|
||||
MetadataBuildingOptions options) {
|
||||
final AdditionalManagedResourcesImpl.Builder mrBuilder = new AdditionalManagedResourcesImpl.Builder();
|
||||
final AdditionalManagedResourcesImpl.Builder mrBuilder = new AdditionalManagedResourcesImpl.Builder(
|
||||
rootMetadataBuildingContext.getBootstrapContext().getServiceRegistry()
|
||||
);
|
||||
mrBuilder.addLoadedClasses( additionalClasses );
|
||||
mrBuilder.addClassDetails( additionalClassDetails );
|
||||
mrBuilder.addJaxbEntityMappings( additionalJaxbMappings );
|
||||
|
|
|
@ -114,7 +114,7 @@ public class ManagedTypeProcessor {
|
|||
prepareDynamicClass( classDetails, jaxbEntity, xmlDocumentContext );
|
||||
}
|
||||
else {
|
||||
memberAdjuster = ManagedTypeProcessor::adjustNonDynamicTypeMember;
|
||||
memberAdjuster = ManagedTypeProcessor::adjustCompleteNonDynamicTypeMember;
|
||||
final String className = XmlProcessingHelper.determineClassName( jaxbRoot, jaxbEntity );
|
||||
classDetails = (MutableClassDetails) classDetailsRegistry.resolveClassDetails( className );
|
||||
classAccessType = coalesce(
|
||||
|
@ -127,9 +127,14 @@ public class ManagedTypeProcessor {
|
|||
if ( classDetails.isInterface() ) {
|
||||
throw new MappingException( "Only classes (not interfaces) may be mapped as @Entity : " + classDetails.getName() );
|
||||
}
|
||||
|
||||
classDetails.forEachPersistableMember( memberDetails -> {
|
||||
final MutableMemberDetails mutableMemberDetails = (MutableMemberDetails) memberDetails;
|
||||
mutableMemberDetails.clearAnnotationUsages();
|
||||
mutableMemberDetails.addAnnotationUsage( JpaAnnotations.TRANSIENT.createUsage( xmlDocumentContext.getModelBuildingContext() ) );
|
||||
} );
|
||||
}
|
||||
|
||||
classDetails.clearMemberAnnotationUsages();
|
||||
classDetails.clearAnnotationUsages();
|
||||
|
||||
// from here, processing is the same between override and metadata-complete modes (aside from the dynamic model handling)
|
||||
|
@ -189,7 +194,7 @@ public class ManagedTypeProcessor {
|
|||
classDetails.addField( member );
|
||||
} );
|
||||
}
|
||||
else {
|
||||
else if ( attributes.getEmbeddedIdAttribute() != null ) {
|
||||
// <embedded-id/>
|
||||
final JaxbEmbeddedIdImpl embeddedId = attributes.getEmbeddedIdAttribute();
|
||||
final TypeDetails attributeJavaType = determineDynamicAttributeJavaType(
|
||||
|
@ -708,6 +713,18 @@ public class ManagedTypeProcessor {
|
|||
);
|
||||
}
|
||||
|
||||
private static void adjustCompleteNonDynamicTypeMember(
|
||||
MutableMemberDetails memberDetails,
|
||||
JaxbPersistentAttribute jaxbAttribute,
|
||||
XmlDocumentContext xmlDocumentContext) {
|
||||
memberDetails.removeAnnotationUsage( JpaAnnotations.TRANSIENT );
|
||||
CommonAttributeProcessing.applyAttributeAccessor(
|
||||
jaxbAttribute,
|
||||
memberDetails,
|
||||
xmlDocumentContext
|
||||
);
|
||||
}
|
||||
|
||||
public static void processOverrideEntity(List<XmlProcessingResult.OverrideTuple<JaxbEntityImpl>> entityOverrides) {
|
||||
entityOverrides.forEach( (overrideTuple) -> {
|
||||
final XmlDocumentContext xmlDocumentContext = overrideTuple.getXmlDocumentContext();
|
||||
|
|
|
@ -32,6 +32,8 @@ import org.hibernate.testing.junit4.BaseUnitTestCase;
|
|||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
||||
import jakarta.persistence.Transient;
|
||||
|
||||
import static org.hibernate.models.internal.SimpleClassLoading.SIMPLE_CLASS_LOADING;
|
||||
|
||||
/**
|
||||
|
@ -59,14 +61,18 @@ public abstract class Ejb3XmlTestCase extends BaseUnitTestCase {
|
|||
final ClassDetails classDetails = getClassDetails( entityClass, xmlResourceName );
|
||||
final FieldDetails fieldByName = classDetails.findFieldByName( fieldName );
|
||||
if ( !fieldByName.getDirectAnnotationUsages().isEmpty() ) {
|
||||
return fieldByName;
|
||||
if ( !fieldByName.hasDirectAnnotationUsage( Transient.class ) ) {
|
||||
return fieldByName;
|
||||
}
|
||||
}
|
||||
|
||||
// look for the getter
|
||||
for ( MethodDetails method : classDetails.getMethods() ) {
|
||||
if ( method.getMethodKind() == MethodDetails.MethodKind.GETTER
|
||||
&& fieldName.equals( method.resolveAttributeName() ) ) {
|
||||
return method;
|
||||
if ( !method.hasDirectAnnotationUsage( Transient.class ) ) {
|
||||
return method;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -105,8 +105,8 @@ public class BasicTransformationTests {
|
|||
assertThat( transformed.getEmbeddables() ).hasSize( 0 );
|
||||
|
||||
final JaxbEntityImpl ormEntity = transformed.getEntities().get( 0 );
|
||||
assertThat( ormEntity.getName() ).isNull();
|
||||
assertThat( ormEntity.getClazz() ).isEqualTo( "SimpleEntity" );
|
||||
assertThat( ormEntity.getName() ).isEqualTo( "SimpleEntity" );
|
||||
assertThat( ormEntity.getClazz() ).isNull();
|
||||
|
||||
assertThat( ormEntity.getAttributes().getIdAttributes() ).hasSize( 1 );
|
||||
assertThat( ormEntity.getAttributes().getBasicAttributes() ).hasSize( 1 );
|
||||
|
|
|
@ -16,6 +16,8 @@ import java.util.List;
|
|||
import javax.xml.stream.XMLEventFactory;
|
||||
import javax.xml.stream.XMLEventReader;
|
||||
|
||||
import org.hibernate.boot.Metadata;
|
||||
import org.hibernate.boot.MetadataSources;
|
||||
import org.hibernate.boot.jaxb.Origin;
|
||||
import org.hibernate.boot.jaxb.SourceType;
|
||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmHibernateMapping;
|
||||
|
@ -25,6 +27,7 @@ import org.hibernate.boot.jaxb.internal.stax.HbmEventReader;
|
|||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityMappingsImpl;
|
||||
import org.hibernate.boot.jaxb.spi.Binding;
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.boot.spi.MetadataImplementor;
|
||||
import org.hibernate.boot.xsd.MappingXsdSupport;
|
||||
import org.hibernate.orm.test.boot.jaxb.JaxbHelper;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
|
@ -42,10 +45,7 @@ import static org.hibernate.orm.test.boot.jaxb.JaxbHelper.withStaxEventReader;
|
|||
*/
|
||||
public class TransformationHelper {
|
||||
public static JaxbEntityMappingsImpl transform(String resourceName, ServiceRegistry serviceRegistry) {
|
||||
return transform( resourceName, serviceRegistry.getService( ClassLoaderService.class ) );
|
||||
}
|
||||
|
||||
public static JaxbEntityMappingsImpl transform(String resourceName, ClassLoaderService cls) {
|
||||
final ClassLoaderService cls = serviceRegistry.requireService( ClassLoaderService.class );
|
||||
try ( final InputStream inputStream = cls.locateResourceStream( resourceName ) ) {
|
||||
return withStaxEventReader( inputStream, cls, (staxEventReader) -> {
|
||||
final XMLEventReader reader = new HbmEventReader( staxEventReader, XMLEventFactory.newInstance() );
|
||||
|
@ -60,8 +60,14 @@ public class TransformationHelper {
|
|||
assertThat( hbmMapping ).isNotNull();
|
||||
assertThat( hbmMapping.getClazz() ).hasSize( 1 );
|
||||
|
||||
final MetadataImplementor metadata = (MetadataImplementor) new MetadataSources( serviceRegistry ).addHbmXmlBinding( new Binding<>(
|
||||
hbmMapping,
|
||||
new Origin( SourceType.RESOURCE, resourceName )
|
||||
) ).buildMetadata();
|
||||
final List<Binding<JaxbEntityMappingsImpl>> transformed = HbmXmlTransformer.transform(
|
||||
Collections.singletonList( new Binding<>( hbmMapping, new Origin( SourceType.RESOURCE, resourceName ) ) ),
|
||||
metadata,
|
||||
serviceRegistry,
|
||||
UnsupportedFeatureHandling.ERROR
|
||||
);
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import java.util.List;
|
|||
import javax.xml.stream.XMLEventFactory;
|
||||
import javax.xml.stream.XMLEventReader;
|
||||
|
||||
import org.hibernate.boot.MetadataSources;
|
||||
import org.hibernate.boot.jaxb.Origin;
|
||||
import org.hibernate.boot.jaxb.SourceType;
|
||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmHibernateMapping;
|
||||
|
@ -23,6 +24,7 @@ import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityImpl;
|
|||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityMappingsImpl;
|
||||
import org.hibernate.boot.jaxb.spi.Binding;
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.boot.spi.MetadataImplementor;
|
||||
import org.hibernate.boot.xsd.MappingXsdSupport;
|
||||
import org.hibernate.orm.test.boot.jaxb.JaxbHelper;
|
||||
|
||||
|
@ -59,8 +61,14 @@ public class HbmTransformationJaxbTests {
|
|||
assertThat( hbmMapping ).isNotNull();
|
||||
assertThat( hbmMapping.getClazz() ).hasSize( 1 );
|
||||
|
||||
final MetadataImplementor metadata = (MetadataImplementor) new MetadataSources( scope.getRegistry() ).addHbmXmlBinding( new Binding<>(
|
||||
hbmMapping,
|
||||
new Origin( SourceType.RESOURCE, resourceName )
|
||||
) ).buildMetadata();
|
||||
final List<Binding<JaxbEntityMappingsImpl>> transformedBindingList = HbmXmlTransformer.transform(
|
||||
Collections.singletonList( new Binding<>( hbmMapping, new Origin( SourceType.RESOURCE, resourceName ) ) ),
|
||||
metadata,
|
||||
scope.getRegistry(),
|
||||
UnsupportedFeatureHandling.ERROR
|
||||
);
|
||||
final JaxbEntityMappingsImpl transformed = transformedBindingList.get( 0 ).getRoot();
|
||||
|
|
|
@ -10,11 +10,29 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.hibernate.boot.MetadataSources;
|
||||
import org.hibernate.boot.internal.BootstrapContextImpl;
|
||||
import org.hibernate.boot.internal.MetadataBuilderImpl;
|
||||
import org.hibernate.boot.internal.RootMappingDefaults;
|
||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmDiscriminatorSubclassEntityType;
|
||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmHibernateMapping;
|
||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmJoinedSubclassEntityType;
|
||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmUnionSubclassEntityType;
|
||||
import org.hibernate.boot.jaxb.hbm.transform.HbmXmlTransformer;
|
||||
import org.hibernate.boot.jaxb.hbm.transform.TransformationHelper;
|
||||
import org.hibernate.boot.jaxb.hbm.transform.UnsupportedFeatureHandling;
|
||||
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.internal.ManagedResourcesImpl;
|
||||
import org.hibernate.boot.model.process.spi.ManagedResources;
|
||||
import org.hibernate.boot.model.process.spi.MetadataBuildingProcess;
|
||||
import org.hibernate.boot.models.categorize.internal.ClassLoaderServiceLoading;
|
||||
import org.hibernate.boot.models.internal.DomainModelCategorizationCollector;
|
||||
import org.hibernate.boot.models.internal.GlobalRegistrationsImpl;
|
||||
|
@ -25,27 +43,33 @@ 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.BootstrapContext;
|
||||
import org.hibernate.boot.spi.MetadataBuildingOptions;
|
||||
import org.hibernate.boot.spi.MetadataImplementor;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.cfg.MappingSettings;
|
||||
import org.hibernate.engine.config.spi.ConfigurationService;
|
||||
import org.hibernate.models.internal.AnnotationDescriptorRegistryStandard;
|
||||
import org.hibernate.models.internal.BaseLineJavaTypes;
|
||||
import org.hibernate.models.internal.SourceModelBuildingContextImpl;
|
||||
import org.hibernate.models.internal.jandex.JandexBuilders;
|
||||
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.SourceModelBuildingContext;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
|
||||
import org.jboss.jandex.ClassInfo;
|
||||
import org.jboss.jandex.Index;
|
||||
import org.jboss.jandex.IndexView;
|
||||
import org.jboss.jandex.Indexer;
|
||||
|
||||
import static org.hibernate.engine.config.spi.StandardConverters.BOOLEAN;
|
||||
import static org.hibernate.internal.util.collections.CollectionHelper.mutableJoin;
|
||||
import static org.hibernate.models.internal.SimpleClassLoading.SIMPLE_CLASS_LOADING;
|
||||
|
||||
|
@ -129,11 +153,96 @@ public class SourceModelTestHelper {
|
|||
return indexer.complete();
|
||||
}
|
||||
|
||||
public static SourceModelBuildingContext createBuildingContext(
|
||||
ManagedResources managedResources,
|
||||
StandardServiceRegistry serviceRegistry) {
|
||||
final MetadataBuilderImpl.MetadataBuildingOptionsImpl metadataBuildingOptions = new MetadataBuilderImpl.MetadataBuildingOptionsImpl( serviceRegistry );
|
||||
final BootstrapContextImpl bootstrapContext = new BootstrapContextImpl( serviceRegistry, metadataBuildingOptions );
|
||||
metadataBuildingOptions.setBootstrapContext( bootstrapContext );
|
||||
return createBuildingContext(
|
||||
managedResources,
|
||||
false,
|
||||
metadataBuildingOptions,
|
||||
bootstrapContext
|
||||
);
|
||||
}
|
||||
|
||||
public static SourceModelBuildingContext createBuildingContext(
|
||||
ManagedResources managedResources,
|
||||
Index jandexIndex,
|
||||
StandardServiceRegistry serviceRegistry) {
|
||||
final MetadataBuilderImpl.MetadataBuildingOptionsImpl metadataBuildingOptions = new MetadataBuilderImpl.MetadataBuildingOptionsImpl( serviceRegistry );
|
||||
final BootstrapContextTesting bootstrapContext = new BootstrapContextTesting( jandexIndex, serviceRegistry, metadataBuildingOptions );
|
||||
metadataBuildingOptions.setBootstrapContext( bootstrapContext );
|
||||
return createBuildingContext(
|
||||
managedResources,
|
||||
false,
|
||||
metadataBuildingOptions,
|
||||
bootstrapContext
|
||||
);
|
||||
}
|
||||
|
||||
public static SourceModelBuildingContext createBuildingContext(
|
||||
ManagedResources managedResources,
|
||||
boolean buildJandexIndex,
|
||||
MetadataBuildingOptions metadataBuildingOptions,
|
||||
BootstrapContext bootstrapContext) {
|
||||
MetadataImplementor domainModel = MetadataBuildingProcess.complete(
|
||||
managedResources,
|
||||
bootstrapContext,
|
||||
metadataBuildingOptions
|
||||
);
|
||||
|
||||
final ConfigurationService configurationService = bootstrapContext.getServiceRegistry().requireService( ConfigurationService.class );
|
||||
final boolean doTransformation = configurationService.getSetting( MappingSettings.TRANSFORM_HBM_XML, BOOLEAN, false );
|
||||
if ( doTransformation ) {
|
||||
final Collection<Binding<JaxbBindableMappingDescriptor>> xmlMappingBindings = managedResources.getXmlMappingBindings();
|
||||
|
||||
final List<Binding<JaxbEntityMappingsImpl>> mappingXmlBindings = new ArrayList<>();
|
||||
final List<Binding<JaxbHbmHibernateMapping>> hbmXmlBindings = new ArrayList<>();
|
||||
|
||||
xmlMappingBindings.forEach( (binding) -> {
|
||||
if ( binding.getRoot() instanceof JaxbEntityMappingsImpl ) {
|
||||
//noinspection unchecked,rawtypes
|
||||
mappingXmlBindings.add( (Binding) binding );
|
||||
}
|
||||
else {
|
||||
//noinspection unchecked,rawtypes
|
||||
hbmXmlBindings.add( (Binding) binding );
|
||||
}
|
||||
} );
|
||||
|
||||
final List<Binding<JaxbEntityMappingsImpl>> transformed = HbmXmlTransformer.transform(
|
||||
hbmXmlBindings,
|
||||
domainModel,
|
||||
bootstrapContext.getServiceRegistry(),
|
||||
UnsupportedFeatureHandling.fromSetting(
|
||||
configurationService.getSettings().get( AvailableSettings.TRANSFORM_HBM_XML_FEATURE_HANDLING ),
|
||||
UnsupportedFeatureHandling.ERROR
|
||||
)
|
||||
);
|
||||
mappingXmlBindings.addAll( transformed );
|
||||
|
||||
final MetadataSources newSources = new MetadataSources( bootstrapContext.getServiceRegistry() );
|
||||
if ( managedResources.getAnnotatedClassReferences() != null ) {
|
||||
managedResources.getAnnotatedClassReferences().forEach( newSources::addAnnotatedClass );
|
||||
}
|
||||
if ( managedResources.getAnnotatedClassNames() != null ) {
|
||||
managedResources.getAnnotatedClassNames().forEach( newSources::addAnnotatedClassName );
|
||||
}
|
||||
if ( managedResources.getAnnotatedPackageNames() != null ) {
|
||||
managedResources.getAnnotatedPackageNames().forEach( newSources::addPackage );
|
||||
}
|
||||
if ( managedResources.getExtraQueryImports() != null ) {
|
||||
managedResources.getExtraQueryImports().forEach( newSources::addQueryImport );
|
||||
}
|
||||
for ( Binding<JaxbEntityMappingsImpl> mappingXmlBinding : mappingXmlBindings ) {
|
||||
newSources.addMappingXmlBinding( mappingXmlBinding );
|
||||
}
|
||||
|
||||
managedResources = ManagedResourcesImpl.baseline( newSources, bootstrapContext );
|
||||
}
|
||||
|
||||
final ClassLoaderService classLoaderService = bootstrapContext.getServiceRegistry().getService( ClassLoaderService.class );
|
||||
final ClassLoaderServiceLoading classLoading = new ClassLoaderServiceLoading( classLoaderService );
|
||||
|
||||
|
@ -150,6 +259,7 @@ public class SourceModelTestHelper {
|
|||
managedResources.getAnnotatedClassNames(),
|
||||
xmlPreProcessingResult.getMappedClasses()
|
||||
);
|
||||
|
||||
managedResources.getAnnotatedPackageNames().forEach( (packageName) -> {
|
||||
try {
|
||||
final Class<?> packageInfoClass = classLoading.classForName( packageName + ".package-info" );
|
||||
|
@ -202,11 +312,107 @@ public class SourceModelTestHelper {
|
|||
modelCategorizationCollector.apply( classDetails );
|
||||
} );
|
||||
|
||||
// `XmlPreProcessor#preProcessXmlResources` skips hbm.xml files.
|
||||
// we want to look at them here to collect known managed-types
|
||||
managedResources.getXmlMappingBindings().forEach( (binding) -> {
|
||||
final JaxbBindableMappingDescriptor root = binding.getRoot();
|
||||
if ( root instanceof JaxbHbmHibernateMapping hbmRoot ) {
|
||||
collectHbmClasses( hbmRoot, classDetailsRegistry::resolveClassDetails );
|
||||
}
|
||||
} );
|
||||
|
||||
xmlProcessingResult.apply( xmlPreProcessingResult.getPersistenceUnitMetadata() );
|
||||
|
||||
return sourceModelBuildingContext;
|
||||
}
|
||||
|
||||
private static void collectHbmClasses(JaxbHbmHibernateMapping hbmRoot, Consumer<String> classNameConsumer) {
|
||||
// NOTE : at the moment does not collect embeddable names...
|
||||
|
||||
hbmRoot.getClazz().forEach( (hbmRootEntity) -> {
|
||||
final String entityName = TransformationHelper.determineEntityName( hbmRootEntity, hbmRoot );
|
||||
classNameConsumer.accept( entityName );
|
||||
|
||||
hbmRootEntity.getSubclass().forEach( (hbmSubclass) -> visitDiscriminatedSubclass(
|
||||
hbmRoot,
|
||||
hbmSubclass,
|
||||
classNameConsumer
|
||||
) );
|
||||
|
||||
hbmRootEntity.getJoinedSubclass().forEach( (hbmSubclass) -> visitJoinedSubclass(
|
||||
hbmRoot,
|
||||
hbmSubclass,
|
||||
classNameConsumer
|
||||
) );
|
||||
|
||||
hbmRootEntity.getUnionSubclass().forEach( (hbmSubclass) -> visitUnionSubclass(
|
||||
hbmRoot,
|
||||
hbmSubclass,
|
||||
classNameConsumer
|
||||
) );
|
||||
} );
|
||||
|
||||
hbmRoot.getSubclass().forEach( (hbmSubclass) -> visitDiscriminatedSubclass(
|
||||
hbmRoot,
|
||||
hbmSubclass,
|
||||
classNameConsumer
|
||||
) );
|
||||
|
||||
hbmRoot.getJoinedSubclass().forEach( (hbmSubclass) -> visitJoinedSubclass(
|
||||
hbmRoot,
|
||||
hbmSubclass,
|
||||
classNameConsumer
|
||||
) );
|
||||
|
||||
hbmRoot.getUnionSubclass().forEach( (hbmSubclass) -> visitUnionSubclass(
|
||||
hbmRoot,
|
||||
hbmSubclass,
|
||||
classNameConsumer
|
||||
) );
|
||||
}
|
||||
|
||||
private static void visitDiscriminatedSubclass(
|
||||
JaxbHbmHibernateMapping hbmRoot,
|
||||
JaxbHbmDiscriminatorSubclassEntityType hbmEntity,
|
||||
Consumer<String> classNameConsumer) {
|
||||
final String entityName = TransformationHelper.determineEntityName( hbmEntity, hbmRoot );
|
||||
classNameConsumer.accept( entityName );
|
||||
|
||||
hbmEntity.getSubclass().forEach( (hbmSubclass) -> visitDiscriminatedSubclass(
|
||||
hbmRoot,
|
||||
hbmSubclass,
|
||||
classNameConsumer
|
||||
) );
|
||||
}
|
||||
|
||||
private static void visitJoinedSubclass(
|
||||
JaxbHbmHibernateMapping hbmRoot,
|
||||
JaxbHbmJoinedSubclassEntityType hbmEntity,
|
||||
Consumer<String> classNameConsumer) {
|
||||
final String entityName = TransformationHelper.determineEntityName( hbmEntity, hbmRoot );
|
||||
classNameConsumer.accept( entityName );
|
||||
|
||||
hbmEntity.getJoinedSubclass().forEach( (hbmSubclass) -> visitJoinedSubclass(
|
||||
hbmRoot,
|
||||
hbmSubclass,
|
||||
classNameConsumer
|
||||
) );
|
||||
}
|
||||
|
||||
private static void visitUnionSubclass(
|
||||
JaxbHbmHibernateMapping hbmRoot,
|
||||
JaxbHbmUnionSubclassEntityType hbmEntity,
|
||||
Consumer<String> classNameConsumer) {
|
||||
final String entityName = TransformationHelper.determineEntityName( hbmEntity, hbmRoot );
|
||||
classNameConsumer.accept( entityName );
|
||||
|
||||
hbmEntity.getUnionSubclass().forEach( (hbmSubclass) -> visitUnionSubclass(
|
||||
hbmRoot,
|
||||
hbmSubclass,
|
||||
classNameConsumer
|
||||
) );
|
||||
}
|
||||
|
||||
private static IndexView buildJandexIndex(ClassLoaderServiceLoading classLoading, List<String> classNames) {
|
||||
final Indexer indexer = new Indexer();
|
||||
BaseLineJavaTypes.forEachJavaType( (javaType) -> JandexIndexerHelper.apply( javaType, indexer, classLoading ) );
|
||||
|
|
|
@ -8,12 +8,10 @@ package org.hibernate.orm.test.boot.models.hbm._extends;
|
|||
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityMappingsImpl;
|
||||
import org.hibernate.cfg.MappingSettings;
|
||||
import org.hibernate.orm.test.boot.jaxb.hbm.TransformationHelper;
|
||||
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistryScope;
|
||||
import org.hibernate.testing.orm.junit.Setting;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jakarta.persistence.InheritanceType;
|
||||
|
@ -25,7 +23,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
*/
|
||||
@SuppressWarnings("JUnitMalformedDeclaration")
|
||||
public class ExtendsTests {
|
||||
@ServiceRegistry(settings = @Setting(name = MappingSettings.TRANSFORM_HBM_XML, value = "true"))
|
||||
|
||||
@ServiceRegistry()
|
||||
@Test
|
||||
void testDiscriminatedStructured(ServiceRegistryScope registryScope) {
|
||||
final JaxbEntityMappingsImpl transformed = TransformationHelper.transform(
|
||||
|
@ -35,7 +34,7 @@ public class ExtendsTests {
|
|||
verifyHierarchy( transformed, InheritanceType.SINGLE_TABLE );
|
||||
}
|
||||
|
||||
@ServiceRegistry(settings = @Setting(name = MappingSettings.TRANSFORM_HBM_XML, value = "true"))
|
||||
@ServiceRegistry()
|
||||
@Test
|
||||
void testDiscriminatedSeparated(ServiceRegistryScope registryScope) {
|
||||
final JaxbEntityMappingsImpl transformed = TransformationHelper.transform(
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.hibernate.testing.orm.junit.Setting;
|
|||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* Tests for mapping interfaces as managed classes.
|
||||
|
@ -50,10 +51,9 @@ public class InterfaceMappingTests {
|
|||
final Metadata metadata = new MetadataSources( serviceRegistry )
|
||||
.addResource( "mappings/models/hbm/intf/mapped-interface.hbm.xml" )
|
||||
.buildMetadata();
|
||||
fail( "Expecting a failure" );
|
||||
}
|
||||
catch (MappingException expected) {
|
||||
assertThat( expected.getMessage() ).startsWith( "Only classes (not interfaces) may be mapped as @Entity :" );
|
||||
assertThat( expected.getMessage() ).endsWith( IPerson.class.getName() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,17 +6,30 @@
|
|||
*/
|
||||
package org.hibernate.orm.test.boot.models.hbm.joinformula;
|
||||
|
||||
import org.hibernate.boot.Metadata;
|
||||
import org.hibernate.boot.MetadataSources;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||
import org.hibernate.cfg.MappingSettings;
|
||||
import org.hibernate.mapping.Collection;
|
||||
import org.hibernate.mapping.Column;
|
||||
import org.hibernate.mapping.Formula;
|
||||
import org.hibernate.mapping.KeyValue;
|
||||
import org.hibernate.mapping.OneToOne;
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
import org.hibernate.mapping.Property;
|
||||
import org.hibernate.mapping.ToOne;
|
||||
import org.hibernate.mapping.Value;
|
||||
import org.hibernate.orm.test.onetoone.formula.Person;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.DomainModelScope;
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistryScope;
|
||||
import org.hibernate.testing.orm.junit.Setting;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
|
@ -32,11 +45,20 @@ public class OneToOneTests {
|
|||
|
||||
@Test
|
||||
@ServiceRegistry( settings = @Setting( name= MappingSettings.TRANSFORM_HBM_XML, value = "true" ) )
|
||||
@DomainModel(xmlMappings = "org/hibernate/orm/test/onetoone/formula/Person.hbm.xml")
|
||||
void testTransformation(DomainModelScope domainModelScope) {
|
||||
final PersistentClass personEntityBinding = domainModelScope.getDomainModel().getEntityBinding( Person.class.getName() );
|
||||
validateAddress( personEntityBinding.getProperty( "address" ) );
|
||||
validateMailingAddress( personEntityBinding.getProperty( "mailingAddress" ) );
|
||||
void testTransformation(ServiceRegistryScope registryScope) {
|
||||
try {
|
||||
final StandardServiceRegistry serviceRegistry = registryScope.getRegistry();
|
||||
final MetadataSources metadataSources = new MetadataSources( serviceRegistry );
|
||||
metadataSources.addResource( "org/hibernate/orm/test/onetoone/formula/Person.hbm.xml" );
|
||||
final Metadata domainModel = metadataSources.buildMetadata();
|
||||
|
||||
final PersistentClass personEntityBinding = domainModel.getEntityBinding( Person.class.getName() );
|
||||
validateAddress( personEntityBinding.getProperty( "address" ) );
|
||||
validateMailingAddress( personEntityBinding.getProperty( "mailingAddress" ) );
|
||||
}
|
||||
catch (UnsupportedOperationException e) {
|
||||
assertThat( e.getMessage() ).contains( "<key-many-to-one/>" );
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -48,10 +70,16 @@ public class OneToOneTests {
|
|||
}
|
||||
|
||||
private void validateAddress(Property property) {
|
||||
|
||||
final ToOne valueMapping = (ToOne) property.getValue();
|
||||
assertThat( valueMapping.getSelectables() ).hasSize( 2 );
|
||||
assertThat( valueMapping.getSelectables().get(0) ).isInstanceOf( Formula.class );
|
||||
assertThat( valueMapping.getSelectables().get(1) ).isInstanceOf( Formula.class );
|
||||
}
|
||||
|
||||
private void validateMailingAddress(Property property) {
|
||||
|
||||
final ToOne valueMapping = (ToOne) property.getValue();
|
||||
assertThat( valueMapping.getSelectables() ).hasSize( 2 );
|
||||
assertThat( valueMapping.getSelectables().get(0) ).isInstanceOf( Formula.class );
|
||||
assertThat( valueMapping.getSelectables().get(1) ).isInstanceOf( Formula.class );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,17 +51,7 @@ public class AnyTests {
|
|||
.addXmlMappings( "mappings/models/attr/any/simple.xml" )
|
||||
.build();
|
||||
|
||||
final BootstrapContextImpl bootstrapContext = new BootstrapContextImpl(
|
||||
serviceRegistry,
|
||||
new MetadataBuilderImpl.MetadataBuildingOptionsImpl( serviceRegistry )
|
||||
);
|
||||
|
||||
final SourceModelBuildingContext sourceModelBuildingContext = createBuildingContext(
|
||||
managedResources,
|
||||
false,
|
||||
new MetadataBuilderImpl.MetadataBuildingOptionsImpl( bootstrapContext.getServiceRegistry() ),
|
||||
bootstrapContext
|
||||
);
|
||||
final SourceModelBuildingContext sourceModelBuildingContext = createBuildingContext( managedResources, serviceRegistry );
|
||||
|
||||
final ClassDetailsRegistry classDetailsRegistry = sourceModelBuildingContext.getClassDetailsRegistry();
|
||||
|
||||
|
|
|
@ -52,19 +52,9 @@ public class ManyToOneTests {
|
|||
.addXmlMappings( "mappings/models/attr/many-to-one/simple.xml" )
|
||||
.build();
|
||||
|
||||
final BootstrapContextImpl bootstrapContext = new BootstrapContextImpl(
|
||||
serviceRegistry,
|
||||
new MetadataBuilderImpl.MetadataBuildingOptionsImpl( serviceRegistry )
|
||||
);
|
||||
|
||||
final SourceModelBuildingContext sourceModelBuildingContext = createBuildingContext(
|
||||
managedResources,
|
||||
false,
|
||||
new MetadataBuilderImpl.MetadataBuildingOptionsImpl( bootstrapContext.getServiceRegistry() ),
|
||||
bootstrapContext
|
||||
);
|
||||
|
||||
final SourceModelBuildingContext sourceModelBuildingContext = createBuildingContext( managedResources, serviceRegistry );
|
||||
final ClassDetailsRegistry classDetailsRegistry = sourceModelBuildingContext.getClassDetailsRegistry();
|
||||
|
||||
final ClassDetails classDetails = classDetailsRegistry.getClassDetails( SimpleEntity.class.getName() );
|
||||
|
||||
final FieldDetails parentField = classDetails.findFieldByName( "parent" );
|
||||
|
|
|
@ -27,6 +27,7 @@ import static org.hibernate.orm.test.boot.models.SourceModelTestHelper.createBui
|
|||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@SuppressWarnings("JUnitMalformedDeclaration")
|
||||
@ServiceRegistry
|
||||
public class ColumnTests {
|
||||
@Test
|
||||
|
@ -35,15 +36,16 @@ public class ColumnTests {
|
|||
.addXmlMappings( "mappings/models/column/complete.xml" )
|
||||
.build();
|
||||
final StandardServiceRegistry serviceRegistry = scope.getRegistry();
|
||||
final MetadataBuilderImpl.MetadataBuildingOptionsImpl metadataBuildingOptions = new MetadataBuilderImpl.MetadataBuildingOptionsImpl( serviceRegistry );
|
||||
final BootstrapContextImpl bootstrapContext = new BootstrapContextImpl(
|
||||
serviceRegistry,
|
||||
new MetadataBuilderImpl.MetadataBuildingOptionsImpl( serviceRegistry )
|
||||
metadataBuildingOptions
|
||||
);
|
||||
|
||||
metadataBuildingOptions.setBootstrapContext( bootstrapContext );
|
||||
final SourceModelBuildingContext sourceModelBuildingContext = createBuildingContext(
|
||||
managedResources,
|
||||
false,
|
||||
new MetadataBuilderImpl.MetadataBuildingOptionsImpl( bootstrapContext.getServiceRegistry() ),
|
||||
metadataBuildingOptions,
|
||||
bootstrapContext
|
||||
);
|
||||
|
||||
|
@ -67,15 +69,16 @@ public class ColumnTests {
|
|||
.build();
|
||||
|
||||
final StandardServiceRegistry serviceRegistry = scope.getRegistry();
|
||||
final MetadataBuilderImpl.MetadataBuildingOptionsImpl metadataBuildingOptions = new MetadataBuilderImpl.MetadataBuildingOptionsImpl( serviceRegistry );
|
||||
final BootstrapContextImpl bootstrapContext = new BootstrapContextImpl(
|
||||
serviceRegistry,
|
||||
new MetadataBuilderImpl.MetadataBuildingOptionsImpl( serviceRegistry )
|
||||
metadataBuildingOptions
|
||||
);
|
||||
|
||||
metadataBuildingOptions.setBootstrapContext( bootstrapContext );
|
||||
final SourceModelBuildingContext sourceModelBuildingContext = createBuildingContext(
|
||||
managedResources,
|
||||
false,
|
||||
new MetadataBuilderImpl.MetadataBuildingOptionsImpl( bootstrapContext.getServiceRegistry() ),
|
||||
metadataBuildingOptions,
|
||||
bootstrapContext
|
||||
);
|
||||
|
||||
|
|
|
@ -7,11 +7,10 @@
|
|||
package org.hibernate.orm.test.boot.models.xml.column.transform;
|
||||
|
||||
import org.hibernate.annotations.ColumnTransformer;
|
||||
import org.hibernate.boot.internal.BootstrapContextImpl;
|
||||
import org.hibernate.boot.internal.MetadataBuilderImpl;
|
||||
import org.hibernate.boot.model.process.spi.ManagedResources;
|
||||
import org.hibernate.boot.model.source.internal.annotations.AdditionalManagedResourcesImpl;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.cfg.MappingSettings;
|
||||
import org.hibernate.mapping.Column;
|
||||
import org.hibernate.mapping.Property;
|
||||
|
@ -41,17 +40,7 @@ public class ModelTests {
|
|||
.addXmlMappings( "mappings/models/column/transform/mapping.xml" )
|
||||
.build();
|
||||
final StandardServiceRegistry serviceRegistry = scope.getRegistry();
|
||||
final BootstrapContextImpl bootstrapContext = new BootstrapContextImpl(
|
||||
serviceRegistry,
|
||||
new MetadataBuilderImpl.MetadataBuildingOptionsImpl( serviceRegistry )
|
||||
);
|
||||
|
||||
final SourceModelBuildingContext sourceModelBuildingContext = createBuildingContext(
|
||||
managedResources,
|
||||
false,
|
||||
new MetadataBuilderImpl.MetadataBuildingOptionsImpl( bootstrapContext.getServiceRegistry() ),
|
||||
bootstrapContext
|
||||
);
|
||||
final SourceModelBuildingContext sourceModelBuildingContext = createBuildingContext( managedResources, serviceRegistry );
|
||||
|
||||
final ClassDetails classDetails = sourceModelBuildingContext.getClassDetailsRegistry().getClassDetails( Item.class.getName() );
|
||||
final FieldDetails costField = classDetails.findFieldByName( "cost" );
|
||||
|
@ -61,24 +50,19 @@ public class ModelTests {
|
|||
assertThat( transformerAnn.write() ).isEqualTo( "? * 100.00" );
|
||||
}
|
||||
|
||||
@ServiceRegistry(settings = @Setting(name = MappingSettings.TRANSFORM_HBM_XML, value = "true"))
|
||||
@ServiceRegistry(settings = {
|
||||
@Setting(name = MappingSettings.TRANSFORM_HBM_XML, value = "true"),
|
||||
@Setting( name = AvailableSettings.VALIDATE_XML, value = "true")
|
||||
})
|
||||
@Test
|
||||
void testHbmXml(ServiceRegistryScope scope) {
|
||||
final ManagedResources managedResources = new AdditionalManagedResourcesImpl.Builder( true, true )
|
||||
.addXmlMappings( "mappings/models/column/transform/hbm.xml" )
|
||||
final String hbmXmlResourceName = "mappings/models/column/transform/hbm.xml";
|
||||
|
||||
final ManagedResources managedResources = new AdditionalManagedResourcesImpl.Builder( scope.getRegistry() )
|
||||
.addXmlMappings( hbmXmlResourceName )
|
||||
.build();
|
||||
final StandardServiceRegistry serviceRegistry = scope.getRegistry();
|
||||
final BootstrapContextImpl bootstrapContext = new BootstrapContextImpl(
|
||||
serviceRegistry,
|
||||
new MetadataBuilderImpl.MetadataBuildingOptionsImpl( serviceRegistry )
|
||||
);
|
||||
|
||||
final SourceModelBuildingContext sourceModelBuildingContext = createBuildingContext(
|
||||
managedResources,
|
||||
false,
|
||||
new MetadataBuilderImpl.MetadataBuildingOptionsImpl( bootstrapContext.getServiceRegistry() ),
|
||||
bootstrapContext
|
||||
);
|
||||
final SourceModelBuildingContext sourceModelBuildingContext = createBuildingContext( managedResources, serviceRegistry );
|
||||
|
||||
final ClassDetails classDetails = sourceModelBuildingContext.getClassDetailsRegistry().getClassDetails( Item.class.getName() );
|
||||
final FieldDetails costField = classDetails.findFieldByName( "cost" );
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* 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.orm.test.boot.models.xml.complete;
|
||||
|
||||
import org.hibernate.boot.model.process.spi.ManagedResources;
|
||||
import org.hibernate.boot.model.source.internal.annotations.AdditionalManagedResourcesImpl;
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
import org.hibernate.mapping.Property;
|
||||
import org.hibernate.models.spi.ClassDetails;
|
||||
import org.hibernate.models.spi.ClassDetailsRegistry;
|
||||
import org.hibernate.models.spi.SourceModelBuildingContext;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.DomainModelScope;
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistryScope;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jakarta.persistence.Transient;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.hibernate.orm.test.boot.models.SourceModelTestHelper.createBuildingContext;
|
||||
|
||||
/**
|
||||
* Test metadata-complete mapping which maps only some "attributes"
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@SuppressWarnings("JUnitMalformedDeclaration")
|
||||
public class CompletePartialTests {
|
||||
@Test
|
||||
@ServiceRegistry
|
||||
void testSourceModel(ServiceRegistryScope registryScope) {
|
||||
final ManagedResources managedResources = new AdditionalManagedResourcesImpl.Builder()
|
||||
.addXmlMappings( "mappings/models/complete/partial-complete.xml" )
|
||||
.build();
|
||||
|
||||
final SourceModelBuildingContext sourceModelBuildingContext = createBuildingContext(
|
||||
managedResources,
|
||||
registryScope.getRegistry()
|
||||
);
|
||||
final ClassDetailsRegistry classDetailsRegistry = sourceModelBuildingContext.getClassDetailsRegistry();
|
||||
final ClassDetails classDetails = classDetailsRegistry.getClassDetails( Thing.class.getName() );
|
||||
|
||||
// NOTE : `#createBuildingContext` applies `XmlProcessor`, so `@Transient` handling is applied...
|
||||
|
||||
assertThat( classDetails.getFields() ).hasSize( 3 );
|
||||
classDetails.forEachField( (i, fieldDetails) -> {
|
||||
assertThat( fieldDetails.isPersistable() ).isTrue();
|
||||
final boolean expectTransient = fieldDetails.getName().equals( "somethingElse" );
|
||||
assertThat( fieldDetails.hasDirectAnnotationUsage( Transient.class ) ).isEqualTo( expectTransient );
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
@ServiceRegistry
|
||||
@DomainModel( xmlMappings = "mappings/models/complete/partial-complete.xml" )
|
||||
public void testBootModel(DomainModelScope domainModelScope) {
|
||||
final PersistentClass entityBinding = domainModelScope.getEntityBinding( Thing.class );
|
||||
assertThat( entityBinding.getIdentifierProperty().getName() ).isEqualTo( "id" );
|
||||
assertThat( entityBinding.getProperties().stream().map( Property::getName ) ).containsOnly( "name" );
|
||||
}
|
||||
}
|
|
@ -19,6 +19,8 @@ import org.hibernate.models.spi.SourceModelBuildingContext;
|
|||
import org.hibernate.orm.test.boot.models.BootstrapContextTesting;
|
||||
import org.hibernate.orm.test.boot.models.SourceModelTestHelper;
|
||||
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistryScope;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.jboss.jandex.Index;
|
||||
|
@ -29,48 +31,36 @@ import jakarta.persistence.Inheritance;
|
|||
import static jakarta.persistence.InheritanceType.JOINED;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.hibernate.models.internal.SimpleClassLoading.SIMPLE_CLASS_LOADING;
|
||||
import static org.hibernate.orm.test.boot.models.SourceModelTestHelper.buildJandexIndex;
|
||||
import static org.hibernate.orm.test.boot.models.SourceModelTestHelper.createBuildingContext;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@SuppressWarnings("JUnitMalformedDeclaration")
|
||||
public class CompleteXmlInheritanceTests {
|
||||
@Test
|
||||
void testIt() {
|
||||
@ServiceRegistry
|
||||
void testModel(ServiceRegistryScope registryScope) {
|
||||
|
||||
final AdditionalManagedResourcesImpl.Builder managedResourcesBuilder = new AdditionalManagedResourcesImpl.Builder();
|
||||
managedResourcesBuilder.addXmlMappings( "mappings/models/complete/simple-inherited.xml" );
|
||||
final ManagedResources managedResources = managedResourcesBuilder.build();
|
||||
|
||||
final Index jandexIndex = SourceModelTestHelper.buildJandexIndex(
|
||||
SIMPLE_CLASS_LOADING,
|
||||
Root.class,
|
||||
Sub.class
|
||||
final SourceModelBuildingContext sourceModelBuildingContext = createBuildingContext(
|
||||
managedResources,
|
||||
buildJandexIndex( SIMPLE_CLASS_LOADING, Root.class, Sub.class ),
|
||||
registryScope.getRegistry()
|
||||
);
|
||||
|
||||
try (StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().build()) {
|
||||
final BootstrapContextTesting bootstrapContext = new BootstrapContextTesting(
|
||||
jandexIndex,
|
||||
serviceRegistry,
|
||||
new MetadataBuildingOptionsImpl( serviceRegistry )
|
||||
);
|
||||
final ClassDetailsRegistry classDetailsRegistry = sourceModelBuildingContext.getClassDetailsRegistry();
|
||||
final ClassDetails root = classDetailsRegistry.getClassDetails( Root.class.getName() );
|
||||
|
||||
final SourceModelBuildingContext sourceModelBuildingContext = createBuildingContext(
|
||||
managedResources,
|
||||
false,
|
||||
new MetadataBuilderImpl.MetadataBuildingOptionsImpl( bootstrapContext.getServiceRegistry() ),
|
||||
bootstrapContext
|
||||
);
|
||||
final Inheritance inheritance = root.getDirectAnnotationUsage( Inheritance.class );
|
||||
assertThat( inheritance.strategy() ).isEqualTo( JOINED );
|
||||
|
||||
final ClassDetailsRegistry classDetailsRegistry = sourceModelBuildingContext.getClassDetailsRegistry();
|
||||
final ClassDetails root = classDetailsRegistry.getClassDetails( Root.class.getName() );
|
||||
|
||||
final Inheritance inheritance = root.getDirectAnnotationUsage( Inheritance.class );
|
||||
assertThat( inheritance.strategy() ).isEqualTo( JOINED );
|
||||
|
||||
assertThat( root.getClassName() ).isEqualTo( Root.class.getName() );
|
||||
final FieldDetails idAttr = root.findFieldByName( "id" );
|
||||
assertThat( idAttr.getDirectAnnotationUsage( Id.class ) ).isNotNull();
|
||||
}
|
||||
assertThat( root.getClassName() ).isEqualTo( Root.class.getName() );
|
||||
final FieldDetails idAttr = root.findFieldByName( "id" );
|
||||
assertThat( idAttr.getDirectAnnotationUsage( Id.class ) ).isNotNull();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,14 +6,7 @@
|
|||
*/
|
||||
package org.hibernate.orm.test.boot.models.xml.complete;
|
||||
|
||||
import org.hibernate.boot.internal.BootstrapContextImpl;
|
||||
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.boot.model.source.internal.annotations.AdditionalManagedResourcesImpl;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||
|
@ -22,50 +15,45 @@ import org.hibernate.models.spi.ClassDetailsRegistry;
|
|||
import org.hibernate.models.spi.FieldDetails;
|
||||
import org.hibernate.models.spi.SourceModelBuildingContext;
|
||||
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistryScope;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jakarta.persistence.AccessType;
|
||||
import jakarta.persistence.Basic;
|
||||
import jakarta.persistence.Embedded;
|
||||
import jakarta.persistence.Id;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.hibernate.boot.models.categorize.spi.AttributeMetadata.AttributeNature.BASIC;
|
||||
import static org.hibernate.boot.models.categorize.spi.AttributeMetadata.AttributeNature.EMBEDDED;
|
||||
import static org.hibernate.boot.models.categorize.spi.ManagedResourcesProcessor.processManagedResources;
|
||||
import static org.hibernate.orm.test.boot.models.SourceModelTestHelper.createBuildingContext;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@SuppressWarnings("JUnitMalformedDeclaration")
|
||||
public class CompleteXmlWithEmbeddableTests {
|
||||
@Test
|
||||
void testIt() {
|
||||
@ServiceRegistry
|
||||
void testModel(ServiceRegistryScope registryScope) {
|
||||
final AdditionalManagedResourcesImpl.Builder managedResourcesBuilder = new AdditionalManagedResourcesImpl.Builder();
|
||||
managedResourcesBuilder.addXmlMappings( "mappings/models/complete/simple-person.xml" );
|
||||
final ManagedResources managedResources = managedResourcesBuilder.build();
|
||||
|
||||
final SourceModelBuildingContext sourceModelBuildingContext = createBuildingContext(
|
||||
managedResources,
|
||||
registryScope.getRegistry()
|
||||
);
|
||||
|
||||
final ClassDetailsRegistry classDetailsRegistry = sourceModelBuildingContext.getClassDetailsRegistry();
|
||||
final ClassDetails personClassDetails = classDetailsRegistry.getClassDetails( SimplePerson.class.getName() );
|
||||
|
||||
final FieldDetails idAttribute = personClassDetails.findFieldByName( "id" );
|
||||
assertThat( idAttribute.getDirectAnnotationUsage( Basic.class ) ).isNotNull();
|
||||
assertThat( idAttribute.getDirectAnnotationUsage( Id.class ) ).isNotNull();
|
||||
|
||||
final FieldDetails nameAttribute = personClassDetails.findFieldByName( "name" );
|
||||
assertThat( nameAttribute.getDirectAnnotationUsage( Embedded.class ) ).isNotNull();
|
||||
|
||||
try (StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().build()) {
|
||||
final BootstrapContextImpl bootstrapContext = new BootstrapContextImpl(
|
||||
serviceRegistry,
|
||||
new MetadataBuilderImpl.MetadataBuildingOptionsImpl( serviceRegistry )
|
||||
);
|
||||
final SourceModelBuildingContext sourceModelBuildingContext = createBuildingContext(
|
||||
managedResources,
|
||||
false,
|
||||
new MetadataBuilderImpl.MetadataBuildingOptionsImpl( bootstrapContext.getServiceRegistry() ),
|
||||
bootstrapContext
|
||||
);
|
||||
|
||||
final ClassDetailsRegistry classDetailsRegistry = sourceModelBuildingContext.getClassDetailsRegistry();
|
||||
final ClassDetails personClassDetails = classDetailsRegistry.getClassDetails( SimplePerson.class.getName() );
|
||||
|
||||
final FieldDetails idAttribute = personClassDetails.findFieldByName( "id" );
|
||||
assertThat( idAttribute.getDirectAnnotationUsage( Basic.class ) ).isNotNull();
|
||||
assertThat( idAttribute.getDirectAnnotationUsage( Id.class ) ).isNotNull();
|
||||
|
||||
final FieldDetails nameAttribute = personClassDetails.findFieldByName( "name" );
|
||||
assertThat( nameAttribute.getDirectAnnotationUsage( Embedded.class ) ).isNotNull();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ package org.hibernate.orm.test.boot.models.xml.complete;
|
|||
import org.hibernate.annotations.DiscriminatorFormula;
|
||||
import org.hibernate.boot.internal.BootstrapContextImpl;
|
||||
import org.hibernate.boot.internal.MetadataBuilderImpl;
|
||||
import org.hibernate.boot.internal.MetadataBuilderImpl.MetadataBuildingOptionsImpl;
|
||||
import org.hibernate.boot.model.process.spi.ManagedResources;
|
||||
import org.hibernate.boot.model.source.internal.annotations.AdditionalManagedResourcesImpl;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||
|
@ -18,6 +19,8 @@ import org.hibernate.models.spi.ClassDetailsRegistry;
|
|||
import org.hibernate.models.spi.SourceModelBuildingContext;
|
||||
import org.hibernate.orm.test.boot.models.xml.SimpleEntity;
|
||||
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistryScope;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jakarta.persistence.DiscriminatorColumn;
|
||||
|
@ -29,73 +32,67 @@ import static org.hibernate.orm.test.boot.models.SourceModelTestHelper.createBui
|
|||
|
||||
public class DiscriminatorValueTest {
|
||||
@Test
|
||||
void testDiscriminatorValue() {
|
||||
@ServiceRegistry
|
||||
void testDiscriminatorValue(ServiceRegistryScope registryScope) {
|
||||
final ManagedResources managedResources = new AdditionalManagedResourcesImpl.Builder()
|
||||
.addXmlMappings( "mappings/models/complete/discriminator-value.xml" )
|
||||
.build();
|
||||
try (StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().build()) {
|
||||
final BootstrapContextImpl bootstrapContext = new BootstrapContextImpl(
|
||||
serviceRegistry,
|
||||
new MetadataBuilderImpl.MetadataBuildingOptionsImpl( serviceRegistry )
|
||||
);
|
||||
final SourceModelBuildingContext sourceModelBuildingContext = createBuildingContext(
|
||||
managedResources,
|
||||
false,
|
||||
new MetadataBuilderImpl.MetadataBuildingOptionsImpl( bootstrapContext.getServiceRegistry() ),
|
||||
bootstrapContext
|
||||
);
|
||||
|
||||
final ClassDetailsRegistry classDetailsRegistry = sourceModelBuildingContext.getClassDetailsRegistry();
|
||||
final SourceModelBuildingContext sourceModelBuildingContext = createBuildingContext(
|
||||
managedResources,
|
||||
registryScope.getRegistry()
|
||||
);
|
||||
final ClassDetailsRegistry classDetailsRegistry = sourceModelBuildingContext.getClassDetailsRegistry();
|
||||
|
||||
{
|
||||
final ClassDetails rootClassDetails = classDetailsRegistry.getClassDetails( Root.class.getName() );
|
||||
assertThat( rootClassDetails.hasDirectAnnotationUsage( DiscriminatorValue.class ) ).isFalse();
|
||||
assertThat( rootClassDetails.hasDirectAnnotationUsage( DiscriminatorFormula.class ) ).isFalse();
|
||||
{
|
||||
final ClassDetails rootClassDetails = classDetailsRegistry.getClassDetails( Root.class.getName() );
|
||||
assertThat( rootClassDetails.hasDirectAnnotationUsage( DiscriminatorValue.class ) ).isFalse();
|
||||
assertThat( rootClassDetails.hasDirectAnnotationUsage( DiscriminatorFormula.class ) ).isFalse();
|
||||
|
||||
final DiscriminatorColumn discriminatorColumn = rootClassDetails.getDirectAnnotationUsage(
|
||||
DiscriminatorColumn.class );
|
||||
assertThat( discriminatorColumn ).isNotNull();
|
||||
assertThat( discriminatorColumn.name() ).isEqualTo( "TYPE_COLUMN" );
|
||||
assertThat( discriminatorColumn.discriminatorType() ).isEqualTo( DiscriminatorType.INTEGER );
|
||||
final DiscriminatorColumn discriminatorColumn = rootClassDetails.getDirectAnnotationUsage(
|
||||
DiscriminatorColumn.class );
|
||||
assertThat( discriminatorColumn ).isNotNull();
|
||||
assertThat( discriminatorColumn.name() ).isEqualTo( "TYPE_COLUMN" );
|
||||
assertThat( discriminatorColumn.discriminatorType() ).isEqualTo( DiscriminatorType.INTEGER );
|
||||
|
||||
final ClassDetails subClassDetails = classDetailsRegistry.getClassDetails( Sub.class.getName() );
|
||||
assertThat( subClassDetails.hasDirectAnnotationUsage( DiscriminatorColumn.class ) ).isFalse();
|
||||
assertThat( subClassDetails.hasDirectAnnotationUsage( DiscriminatorFormula.class ) ).isFalse();
|
||||
final ClassDetails subClassDetails = classDetailsRegistry.getClassDetails( Sub.class.getName() );
|
||||
assertThat( subClassDetails.hasDirectAnnotationUsage( DiscriminatorColumn.class ) ).isFalse();
|
||||
assertThat( subClassDetails.hasDirectAnnotationUsage( DiscriminatorFormula.class ) ).isFalse();
|
||||
|
||||
final DiscriminatorValue discriminatorValue = subClassDetails.getDirectAnnotationUsage(
|
||||
DiscriminatorValue.class );
|
||||
assertThat( discriminatorValue.value() ).isEqualTo( "R" );
|
||||
}
|
||||
|
||||
{
|
||||
final ClassDetails simplePersonClassDetails = classDetailsRegistry.getClassDetails( SimplePerson.class.getName() );
|
||||
assertThat( simplePersonClassDetails.hasDirectAnnotationUsage( DiscriminatorValue.class ) ).isFalse();
|
||||
assertThat( simplePersonClassDetails.hasDirectAnnotationUsage( DiscriminatorFormula.class ) ).isFalse();
|
||||
final DiscriminatorColumn discriminatorColumn = simplePersonClassDetails.getDirectAnnotationUsage(
|
||||
DiscriminatorColumn.class );
|
||||
assertThat( discriminatorColumn ).isNotNull();
|
||||
assertThat( discriminatorColumn.name() ).isEqualTo( "DTYPE" );
|
||||
assertThat( discriminatorColumn.discriminatorType() ).isEqualTo( DiscriminatorType.STRING );
|
||||
}
|
||||
|
||||
{
|
||||
final ClassDetails simpleEntityClassDetails = classDetailsRegistry.getClassDetails( SimpleEntity.class.getName() );
|
||||
|
||||
final DiscriminatorValue discriminatorValue = simpleEntityClassDetails.getDirectAnnotationUsage(
|
||||
DiscriminatorValue.class );
|
||||
assertThat( discriminatorValue ).isNull();
|
||||
|
||||
final DiscriminatorColumn discriminatorColumn = simpleEntityClassDetails.getDirectAnnotationUsage(
|
||||
DiscriminatorColumn.class );
|
||||
assertThat( discriminatorColumn ).isNull();
|
||||
|
||||
final DiscriminatorFormula discriminatorFormula = simpleEntityClassDetails.getDirectAnnotationUsage(
|
||||
DiscriminatorFormula.class );
|
||||
assertThat( discriminatorFormula ).isNotNull();
|
||||
assertThat( discriminatorFormula.value() ).isEqualTo(
|
||||
"CASE WHEN VALUE1 IS NOT NULL THEN 1 WHEN VALUE2 IS NOT NULL THEN 2 END" );
|
||||
assertThat( discriminatorFormula.discriminatorType() ).isEqualTo( DiscriminatorType.STRING );
|
||||
}
|
||||
final DiscriminatorValue discriminatorValue = subClassDetails.getDirectAnnotationUsage(
|
||||
DiscriminatorValue.class );
|
||||
assertThat( discriminatorValue.value() ).isEqualTo( "R" );
|
||||
}
|
||||
|
||||
{
|
||||
final ClassDetails simplePersonClassDetails = classDetailsRegistry.getClassDetails( SimplePerson.class.getName() );
|
||||
assertThat( simplePersonClassDetails.hasDirectAnnotationUsage( DiscriminatorValue.class ) ).isFalse();
|
||||
assertThat( simplePersonClassDetails.hasDirectAnnotationUsage( DiscriminatorFormula.class ) ).isFalse();
|
||||
final DiscriminatorColumn discriminatorColumn = simplePersonClassDetails.getDirectAnnotationUsage(
|
||||
DiscriminatorColumn.class );
|
||||
assertThat( discriminatorColumn ).isNotNull();
|
||||
assertThat( discriminatorColumn.name() ).isEqualTo( "DTYPE" );
|
||||
assertThat( discriminatorColumn.discriminatorType() ).isEqualTo( DiscriminatorType.STRING );
|
||||
}
|
||||
|
||||
{
|
||||
final ClassDetails simpleEntityClassDetails = classDetailsRegistry.getClassDetails( SimpleEntity.class.getName() );
|
||||
|
||||
final DiscriminatorValue discriminatorValue = simpleEntityClassDetails.getDirectAnnotationUsage(
|
||||
DiscriminatorValue.class );
|
||||
assertThat( discriminatorValue ).isNull();
|
||||
|
||||
final DiscriminatorColumn discriminatorColumn = simpleEntityClassDetails.getDirectAnnotationUsage(
|
||||
DiscriminatorColumn.class );
|
||||
assertThat( discriminatorColumn ).isNull();
|
||||
|
||||
final DiscriminatorFormula discriminatorFormula = simpleEntityClassDetails.getDirectAnnotationUsage(
|
||||
DiscriminatorFormula.class );
|
||||
assertThat( discriminatorFormula ).isNotNull();
|
||||
assertThat( discriminatorFormula.value() ).isEqualTo(
|
||||
"CASE WHEN VALUE1 IS NOT NULL THEN 1 WHEN VALUE2 IS NOT NULL THEN 2 END" );
|
||||
assertThat( discriminatorFormula.discriminatorType() ).isEqualTo( DiscriminatorType.STRING );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,18 +11,16 @@ import org.hibernate.annotations.ResultCheckStyle;
|
|||
import org.hibernate.annotations.SQLInsert;
|
||||
import org.hibernate.annotations.SQLRestriction;
|
||||
import org.hibernate.annotations.SqlFragmentAlias;
|
||||
import org.hibernate.boot.internal.BootstrapContextImpl;
|
||||
import org.hibernate.boot.internal.MetadataBuilderImpl;
|
||||
import org.hibernate.boot.model.process.spi.ManagedResources;
|
||||
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.ClassDetails;
|
||||
import org.hibernate.models.spi.ClassDetailsRegistry;
|
||||
import org.hibernate.models.spi.FieldDetails;
|
||||
import org.hibernate.models.spi.SourceModelBuildingContext;
|
||||
import org.hibernate.orm.test.boot.models.xml.SimpleEntity;
|
||||
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistryScope;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jakarta.persistence.Basic;
|
||||
|
@ -35,50 +33,40 @@ import static org.hibernate.orm.test.boot.models.SourceModelTestHelper.createBui
|
|||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@SuppressWarnings("JUnitMalformedDeclaration")
|
||||
public class SimpleCompleteXmlTests {
|
||||
@Test
|
||||
void testSimpleCompleteEntity() {
|
||||
@ServiceRegistry
|
||||
void testSimpleCompleteEntity(ServiceRegistryScope registryScope) {
|
||||
final AdditionalManagedResourcesImpl.Builder managedResourcesBuilder = new AdditionalManagedResourcesImpl.Builder();
|
||||
managedResourcesBuilder.addXmlMappings( "mappings/models/complete/simple-complete.xml" );
|
||||
final ManagedResources managedResources = managedResourcesBuilder.build();
|
||||
|
||||
try (StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().build()) {
|
||||
final BootstrapContextImpl bootstrapContext = new BootstrapContextImpl(
|
||||
serviceRegistry,
|
||||
new MetadataBuilderImpl.MetadataBuildingOptionsImpl( serviceRegistry )
|
||||
);
|
||||
final SourceModelBuildingContext sourceModelBuildingContext = createBuildingContext(
|
||||
managedResources,
|
||||
false,
|
||||
new MetadataBuilderImpl.MetadataBuildingOptionsImpl( bootstrapContext.getServiceRegistry() ),
|
||||
bootstrapContext
|
||||
);
|
||||
final SourceModelBuildingContext sourceModelBuildingContext = createBuildingContext( managedResources, registryScope.getRegistry() );
|
||||
final ClassDetailsRegistry classDetailsRegistry = sourceModelBuildingContext.getClassDetailsRegistry();
|
||||
|
||||
final ClassDetailsRegistry classDetailsRegistry = sourceModelBuildingContext.getClassDetailsRegistry();
|
||||
final ClassDetails classDetails = classDetailsRegistry.getClassDetails( SimpleEntity.class.getName() );
|
||||
|
||||
final ClassDetails classDetails = classDetailsRegistry.getClassDetails( SimpleEntity.class.getName() );
|
||||
final FieldDetails idField = classDetails.findFieldByName( "id" );
|
||||
assertThat( idField.getDirectAnnotationUsage( Basic.class ) ).isNotNull();
|
||||
assertThat( idField.getDirectAnnotationUsage( Id.class ) ).isNotNull();
|
||||
final Column idColumnAnn = idField.getDirectAnnotationUsage( Column.class );
|
||||
assertThat( idColumnAnn ).isNotNull();
|
||||
assertThat( idColumnAnn.name() ).isEqualTo( "pk" );
|
||||
|
||||
final FieldDetails idField = classDetails.findFieldByName( "id" );
|
||||
assertThat( idField.getDirectAnnotationUsage( Basic.class ) ).isNotNull();
|
||||
assertThat( idField.getDirectAnnotationUsage( Id.class ) ).isNotNull();
|
||||
final Column idColumnAnn = idField.getDirectAnnotationUsage( Column.class );
|
||||
assertThat( idColumnAnn ).isNotNull();
|
||||
assertThat( idColumnAnn.name() ).isEqualTo( "pk" );
|
||||
final FieldDetails nameField = classDetails.findFieldByName( "name" );
|
||||
assertThat( nameField.getDirectAnnotationUsage( Basic.class ) ).isNotNull();
|
||||
final Column nameColumnAnn = nameField.getDirectAnnotationUsage( Column.class );
|
||||
assertThat( nameColumnAnn ).isNotNull();
|
||||
assertThat( nameColumnAnn.name() ).isEqualTo( "description" );
|
||||
|
||||
final FieldDetails nameField = classDetails.findFieldByName( "name" );
|
||||
assertThat( nameField.getDirectAnnotationUsage( Basic.class ) ).isNotNull();
|
||||
final Column nameColumnAnn = nameField.getDirectAnnotationUsage( Column.class );
|
||||
assertThat( nameColumnAnn ).isNotNull();
|
||||
assertThat( nameColumnAnn.name() ).isEqualTo( "description" );
|
||||
final SQLRestriction sqlRestriction = classDetails.getDirectAnnotationUsage( SQLRestriction.class );
|
||||
assertThat( sqlRestriction ).isNotNull();
|
||||
assertThat( sqlRestriction.value() ).isEqualTo( "name is not null" );
|
||||
|
||||
final SQLRestriction sqlRestriction = classDetails.getDirectAnnotationUsage( SQLRestriction.class );
|
||||
assertThat( sqlRestriction ).isNotNull();
|
||||
assertThat( sqlRestriction.value() ).isEqualTo( "name is not null" );
|
||||
validateSqlInsert( classDetails.getDirectAnnotationUsage( SQLInsert.class ));
|
||||
|
||||
validateSqlInsert( classDetails.getDirectAnnotationUsage( SQLInsert.class ));
|
||||
|
||||
validateFilterUsage( classDetails.getAnnotationUsage( Filter.class, sourceModelBuildingContext ) );
|
||||
}
|
||||
validateFilterUsage( classDetails.getAnnotationUsage( Filter.class, sourceModelBuildingContext ) );
|
||||
}
|
||||
|
||||
private void validateFilterUsage(Filter filter) {
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
* 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.orm.test.boot.models.xml.complete;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class Thing {
|
||||
private Integer id;
|
||||
private String name;
|
||||
private String somethingElse;
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* 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.orm.test.boot.models.xml.dynamic;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@Entity
|
||||
public class Address {
|
||||
@Id
|
||||
private Integer id;
|
||||
private String street;
|
||||
private String city;
|
||||
private String state;
|
||||
private String zip;
|
||||
}
|
|
@ -12,25 +12,21 @@ import java.util.Set;
|
|||
import org.hibernate.annotations.Cascade;
|
||||
import org.hibernate.annotations.CascadeType;
|
||||
import org.hibernate.annotations.JavaType;
|
||||
import org.hibernate.annotations.NotFound;
|
||||
import org.hibernate.annotations.NotFoundAction;
|
||||
import org.hibernate.annotations.OnDelete;
|
||||
import org.hibernate.annotations.OnDeleteAction;
|
||||
import org.hibernate.annotations.SortNatural;
|
||||
import org.hibernate.boot.internal.BootstrapContextImpl;
|
||||
import org.hibernate.boot.internal.CollectionClassification;
|
||||
import org.hibernate.boot.internal.LimitedCollectionClassification;
|
||||
import org.hibernate.boot.internal.MetadataBuilderImpl;
|
||||
import org.hibernate.boot.internal.Target;
|
||||
import org.hibernate.boot.model.process.spi.ManagedResources;
|
||||
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.ClassDetails;
|
||||
import org.hibernate.models.spi.ClassDetailsRegistry;
|
||||
import org.hibernate.models.spi.FieldDetails;
|
||||
import org.hibernate.models.spi.SourceModelBuildingContext;
|
||||
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistryScope;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jakarta.persistence.CheckConstraint;
|
||||
|
@ -49,167 +45,129 @@ import static org.hibernate.orm.test.boot.models.SourceModelTestHelper.createBui
|
|||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@SuppressWarnings("JUnitMalformedDeclaration")
|
||||
public class DynamicModelTests {
|
||||
@Test
|
||||
void testSimpleDynamicModel() {
|
||||
@ServiceRegistry
|
||||
void testSimpleDynamicModel(ServiceRegistryScope registryScope) {
|
||||
final ManagedResources managedResources = new AdditionalManagedResourcesImpl.Builder()
|
||||
.addXmlMappings( "mappings/models/dynamic/dynamic-simple.xml" )
|
||||
.build();
|
||||
try (StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().build()) {
|
||||
final BootstrapContextImpl bootstrapContext = new BootstrapContextImpl(
|
||||
serviceRegistry,
|
||||
new MetadataBuilderImpl.MetadataBuildingOptionsImpl( serviceRegistry )
|
||||
);
|
||||
final SourceModelBuildingContext sourceModelBuildingContext = createBuildingContext(
|
||||
managedResources,
|
||||
false,
|
||||
new MetadataBuilderImpl.MetadataBuildingOptionsImpl( bootstrapContext.getServiceRegistry() ),
|
||||
bootstrapContext
|
||||
);
|
||||
final SourceModelBuildingContext sourceModelBuildingContext = createBuildingContext( managedResources, registryScope.getRegistry() );
|
||||
|
||||
final ClassDetailsRegistry classDetailsRegistry = sourceModelBuildingContext.getClassDetailsRegistry();
|
||||
final ClassDetailsRegistry classDetailsRegistry = sourceModelBuildingContext.getClassDetailsRegistry();
|
||||
|
||||
final ClassDetails classDetails = classDetailsRegistry.getClassDetails( "SimpleEntity" );
|
||||
assertThat( classDetails.getClassName() ).isNull();
|
||||
assertThat( classDetails.getName() ).isEqualTo( "SimpleEntity" );
|
||||
final ClassDetails classDetails = classDetailsRegistry.getClassDetails( "SimpleEntity" );
|
||||
assertThat( classDetails.getClassName() ).isNull();
|
||||
assertThat( classDetails.getName() ).isEqualTo( "SimpleEntity" );
|
||||
|
||||
final FieldDetails idField = classDetails.findFieldByName( "id" );
|
||||
assertThat( idField.getType().determineRawClass().getClassName() ).isEqualTo( Integer.class.getName() );
|
||||
final FieldDetails idField = classDetails.findFieldByName( "id" );
|
||||
assertThat( idField.getType().determineRawClass().getClassName() ).isEqualTo( Integer.class.getName() );
|
||||
|
||||
final FieldDetails nameField = classDetails.findFieldByName( "name" );
|
||||
assertThat( nameField.getType().determineRawClass().getClassName() ).isEqualTo( String.class.getName() );
|
||||
assertThat( nameField.getDirectAnnotationUsage( JavaType.class ) ).isNotNull();
|
||||
final FieldDetails nameField = classDetails.findFieldByName( "name" );
|
||||
assertThat( nameField.getType().determineRawClass().getClassName() ).isEqualTo( String.class.getName() );
|
||||
assertThat( nameField.getDirectAnnotationUsage( JavaType.class ) ).isNotNull();
|
||||
|
||||
final FieldDetails qtyField = classDetails.findFieldByName( "quantity" );
|
||||
assertThat( qtyField.getType().determineRawClass().getClassName() ).isEqualTo( int.class.getName() );
|
||||
}
|
||||
final FieldDetails qtyField = classDetails.findFieldByName( "quantity" );
|
||||
assertThat( qtyField.getType().determineRawClass().getClassName() ).isEqualTo( int.class.getName() );
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSemiSimpleDynamicModel() {
|
||||
@ServiceRegistry
|
||||
void testSemiSimpleDynamicModel(ServiceRegistryScope registryScope) {
|
||||
final ManagedResources managedResources = new AdditionalManagedResourcesImpl.Builder()
|
||||
.addXmlMappings( "mappings/models/dynamic/dynamic-semi-simple.xml" )
|
||||
.build();
|
||||
try (StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().build()) {
|
||||
final BootstrapContextImpl bootstrapContext = new BootstrapContextImpl(
|
||||
serviceRegistry,
|
||||
new MetadataBuilderImpl.MetadataBuildingOptionsImpl( serviceRegistry )
|
||||
);
|
||||
final SourceModelBuildingContext sourceModelBuildingContext = createBuildingContext(
|
||||
managedResources,
|
||||
false,
|
||||
new MetadataBuilderImpl.MetadataBuildingOptionsImpl( bootstrapContext.getServiceRegistry() ),
|
||||
bootstrapContext
|
||||
);
|
||||
|
||||
final ClassDetailsRegistry classDetailsRegistry = sourceModelBuildingContext.getClassDetailsRegistry();
|
||||
final SourceModelBuildingContext sourceModelBuildingContext = createBuildingContext( managedResources, registryScope.getRegistry() );
|
||||
|
||||
final ClassDetails classDetails = classDetailsRegistry.getClassDetails( "Contact" );
|
||||
assertThat( classDetails.getClassName() ).isNull();
|
||||
assertThat( classDetails.getName() ).isEqualTo( "Contact" );
|
||||
final ClassDetailsRegistry classDetailsRegistry = sourceModelBuildingContext.getClassDetailsRegistry();
|
||||
|
||||
final FieldDetails idField = classDetails.findFieldByName( "id" );
|
||||
assertThat( idField.getType().determineRawClass().getClassName() ).isEqualTo( Integer.class.getName() );
|
||||
final ClassDetails classDetails = classDetailsRegistry.getClassDetails( "Contact" );
|
||||
assertThat( classDetails.getClassName() ).isNull();
|
||||
assertThat( classDetails.getName() ).isEqualTo( "Contact" );
|
||||
|
||||
final FieldDetails nameField = classDetails.findFieldByName( "name" );
|
||||
assertThat( nameField.getType().determineRawClass().getClassName() ).isNull();
|
||||
assertThat( nameField.getType().getName() ).isEqualTo( "Name" );
|
||||
assertThat( nameField.getDirectAnnotationUsage( Target.class ) ).isNotNull();
|
||||
assertThat( nameField.getDirectAnnotationUsage( Target.class ).value() ).isEqualTo( "Name" );
|
||||
final FieldDetails idField = classDetails.findFieldByName( "id" );
|
||||
assertThat( idField.getType().determineRawClass().getClassName() ).isEqualTo( Integer.class.getName() );
|
||||
|
||||
assertThat( nameField.getType().determineRawClass().getFields() ).hasSize( 2 );
|
||||
final FieldDetails nameField = classDetails.findFieldByName( "name" );
|
||||
assertThat( nameField.getType().determineRawClass().getClassName() ).isNull();
|
||||
assertThat( nameField.getType().getName() ).isEqualTo( "Name" );
|
||||
assertThat( nameField.getDirectAnnotationUsage( Target.class ) ).isNotNull();
|
||||
assertThat( nameField.getDirectAnnotationUsage( Target.class ).value() ).isEqualTo( "Name" );
|
||||
|
||||
final FieldDetails labels = classDetails.findFieldByName( "labels" );
|
||||
assertThat( labels.getType().determineRawClass().getClassName() ).isEqualTo( Set.class.getName() );
|
||||
final ElementCollection elementCollection = labels.getDirectAnnotationUsage( ElementCollection.class );
|
||||
assertThat( elementCollection.targetClass() ).isEqualTo( void.class );
|
||||
final Target targetUsage = labels.getDirectAnnotationUsage( Target.class );
|
||||
assertThat( targetUsage.value() ).isEqualTo( "string" );
|
||||
assertThat( nameField.getType().determineRawClass().getFields() ).hasSize( 2 );
|
||||
|
||||
final CollectionClassification collectionClassification = labels.getDirectAnnotationUsage( CollectionClassification.class );
|
||||
assertThat( collectionClassification.value() ).isEqualTo( LimitedCollectionClassification.SET );
|
||||
final FieldDetails labels = classDetails.findFieldByName( "labels" );
|
||||
assertThat( labels.getType().determineRawClass().getClassName() ).isEqualTo( Set.class.getName() );
|
||||
final ElementCollection elementCollection = labels.getDirectAnnotationUsage( ElementCollection.class );
|
||||
assertThat( elementCollection.targetClass() ).isEqualTo( void.class );
|
||||
final Target targetUsage = labels.getDirectAnnotationUsage( Target.class );
|
||||
assertThat( targetUsage.value() ).isEqualTo( "string" );
|
||||
|
||||
assertThat( labels.getDirectAnnotationUsage( SortNatural.class ) ).isNotNull();
|
||||
final CollectionClassification collectionClassification = labels.getDirectAnnotationUsage( CollectionClassification.class );
|
||||
assertThat( collectionClassification.value() ).isEqualTo( LimitedCollectionClassification.SET );
|
||||
|
||||
final CollectionTable collectionTable = labels.getDirectAnnotationUsage( CollectionTable.class );
|
||||
assertThat( collectionTable.name() ).isEqualTo( "labels" );
|
||||
assertThat( labels.getDirectAnnotationUsage( SortNatural.class ) ).isNotNull();
|
||||
|
||||
final JoinColumn[] joinColumns = collectionTable.joinColumns();
|
||||
assertThat( joinColumns ).hasSize( 1 );
|
||||
assertThat( joinColumns[0].name() ).isEqualTo( "contact_fk" );
|
||||
}
|
||||
final CollectionTable collectionTable = labels.getDirectAnnotationUsage( CollectionTable.class );
|
||||
assertThat( collectionTable.name() ).isEqualTo( "labels" );
|
||||
|
||||
final JoinColumn[] joinColumns = collectionTable.joinColumns();
|
||||
assertThat( joinColumns ).hasSize( 1 );
|
||||
assertThat( joinColumns[0].name() ).isEqualTo( "contact_fk" );
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIdClass() {
|
||||
@ServiceRegistry
|
||||
void testIdClass(ServiceRegistryScope registryScope) {
|
||||
// todo (7.0) : how is this dynamic?
|
||||
|
||||
final ManagedResources managedResources = new AdditionalManagedResourcesImpl.Builder()
|
||||
.addXmlMappings( "mappings/models/dynamic/dynamic-id-class.xml" )
|
||||
.build();
|
||||
try (StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().build()) {
|
||||
final BootstrapContextImpl bootstrapContext = new BootstrapContextImpl(
|
||||
serviceRegistry,
|
||||
new MetadataBuilderImpl.MetadataBuildingOptionsImpl( serviceRegistry )
|
||||
);
|
||||
final SourceModelBuildingContext sourceModelBuildingContext = createBuildingContext(
|
||||
managedResources,
|
||||
false,
|
||||
new MetadataBuilderImpl.MetadataBuildingOptionsImpl( bootstrapContext.getServiceRegistry() ),
|
||||
bootstrapContext
|
||||
);
|
||||
final SourceModelBuildingContext sourceModelBuildingContext = createBuildingContext( managedResources, registryScope.getRegistry() );
|
||||
|
||||
final ClassDetailsRegistry classDetailsRegistry = sourceModelBuildingContext.getClassDetailsRegistry();
|
||||
final ClassDetails classDetails = classDetailsRegistry.getClassDetails( Employee.class.getName() );
|
||||
final ClassDetailsRegistry classDetailsRegistry = sourceModelBuildingContext.getClassDetailsRegistry();
|
||||
final ClassDetails classDetails = classDetailsRegistry.getClassDetails( Employee.class.getName() );
|
||||
|
||||
final IdClass idClass = classDetails.getDirectAnnotationUsage( IdClass.class );
|
||||
assertThat( idClass ).isNotNull();
|
||||
assertThat( idClass.value().getName() ).isEqualTo( EmployeePK.class.getName() );
|
||||
}
|
||||
final IdClass idClass = classDetails.getDirectAnnotationUsage( IdClass.class );
|
||||
assertThat( idClass ).isNotNull();
|
||||
assertThat( idClass.value().getName() ).isEqualTo( EmployeePK.class.getName() );
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOneToMany() {
|
||||
@ServiceRegistry
|
||||
void testOneToMany(ServiceRegistryScope registryScope) {
|
||||
// todo (7.0) : how is this dynamic?
|
||||
|
||||
final ManagedResources managedResources = new AdditionalManagedResourcesImpl.Builder()
|
||||
.addXmlMappings( "mappings/models/dynamic/dynamic-plurals.xml" )
|
||||
.build();
|
||||
try (StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().build()) {
|
||||
final BootstrapContextImpl bootstrapContext = new BootstrapContextImpl(
|
||||
serviceRegistry,
|
||||
new MetadataBuilderImpl.MetadataBuildingOptionsImpl( serviceRegistry )
|
||||
);
|
||||
final SourceModelBuildingContext sourceModelBuildingContext = createBuildingContext(
|
||||
managedResources,
|
||||
false,
|
||||
new MetadataBuilderImpl.MetadataBuildingOptionsImpl( bootstrapContext.getServiceRegistry() ),
|
||||
bootstrapContext
|
||||
);
|
||||
final ClassDetailsRegistry classDetailsRegistry = sourceModelBuildingContext.getClassDetailsRegistry();
|
||||
final SourceModelBuildingContext sourceModelBuildingContext = createBuildingContext( managedResources, registryScope.getRegistry() );
|
||||
final ClassDetailsRegistry classDetailsRegistry = sourceModelBuildingContext.getClassDetailsRegistry();
|
||||
|
||||
final ClassDetails classDetails = classDetailsRegistry.getClassDetails( Employee.class.getName() );
|
||||
assertThat( classDetails.getName() ).isEqualTo( Employee.class.getName() );
|
||||
final ClassDetails classDetails = classDetailsRegistry.getClassDetails( Employee.class.getName() );
|
||||
assertThat( classDetails.getName() ).isEqualTo( Employee.class.getName() );
|
||||
|
||||
final FieldDetails oneToMany = classDetails.findFieldByName( "oneToMany" );
|
||||
assertThat( oneToMany.getType().determineRawClass().getClassName() ).isEqualTo( List.class.getName() );
|
||||
final OneToMany oneToManyAnn = oneToMany.getDirectAnnotationUsage( OneToMany.class );
|
||||
assertThat( oneToManyAnn.fetch() ).isEqualTo( FetchType.EAGER );
|
||||
assertThat( oneToMany.getDirectAnnotationUsage( NotFound.class ).action() ).isEqualTo( NotFoundAction.IGNORE );
|
||||
assertThat( oneToMany.getDirectAnnotationUsage( OnDelete.class ).action() ).isEqualTo( OnDeleteAction.CASCADE );
|
||||
final JoinColumn joinColumn = oneToMany.getAnnotationUsage( JoinColumn.class, sourceModelBuildingContext );
|
||||
assertThat( joinColumn.name() ).isEqualTo( "employee_id" );
|
||||
assertThat( joinColumn.insertable() ).isEqualTo( Boolean.FALSE );
|
||||
assertThat( joinColumn.updatable() ).isEqualTo( Boolean.FALSE );
|
||||
final ForeignKey foreignKey = joinColumn.foreignKey();
|
||||
assertThat( foreignKey.name() ).isEqualTo( "employee_fk" );
|
||||
assertThat( foreignKey.value() ).isEqualTo( ConstraintMode.NO_CONSTRAINT );
|
||||
final CheckConstraint[] checkConstraints = joinColumn.check();
|
||||
assertThat( checkConstraints ).hasSize( 1 );
|
||||
assertThat( checkConstraints[0].name() ).isEqualTo( "employee_id_nn" );
|
||||
assertThat( checkConstraints[0].constraint() ).isEqualTo( "employee_id is not null" );
|
||||
assertThat( oneToMany.getDirectAnnotationUsage( Cascade.class ).value() )
|
||||
.contains( CascadeType.PERSIST, CascadeType.REMOVE, CascadeType.LOCK );
|
||||
}
|
||||
final FieldDetails oneToMany = classDetails.findFieldByName( "addresses" );
|
||||
assertThat( oneToMany.getType().determineRawClass().getClassName() ).isEqualTo( List.class.getName() );
|
||||
final OneToMany oneToManyAnn = oneToMany.getDirectAnnotationUsage( OneToMany.class );
|
||||
assertThat( oneToManyAnn.fetch() ).isEqualTo( FetchType.EAGER );
|
||||
assertThat( oneToMany.getDirectAnnotationUsage( OnDelete.class ).action() ).isEqualTo( OnDeleteAction.CASCADE );
|
||||
final JoinColumn joinColumn = oneToMany.getAnnotationUsage( JoinColumn.class, sourceModelBuildingContext );
|
||||
assertThat( joinColumn.name() ).isEqualTo( "employee_id" );
|
||||
assertThat( joinColumn.referencedColumnName() ).isEqualTo( "emp_num" );
|
||||
assertThat( joinColumn.insertable() ).isEqualTo( Boolean.FALSE );
|
||||
assertThat( joinColumn.updatable() ).isEqualTo( Boolean.FALSE );
|
||||
final ForeignKey foreignKey = joinColumn.foreignKey();
|
||||
assertThat( foreignKey.name() ).isEqualTo( "employee_address_fk" );
|
||||
assertThat( foreignKey.value() ).isEqualTo( ConstraintMode.NO_CONSTRAINT );
|
||||
final CheckConstraint[] checkConstraints = joinColumn.check();
|
||||
assertThat( checkConstraints ).hasSize( 1 );
|
||||
assertThat( checkConstraints[0].name() ).isEqualTo( "employee_id_nn" );
|
||||
assertThat( checkConstraints[0].constraint() ).isEqualTo( "employee_id is not null" );
|
||||
assertThat( oneToMany.getDirectAnnotationUsage( Cascade.class ).value() )
|
||||
.contains( CascadeType.PERSIST, CascadeType.REMOVE, CascadeType.LOCK );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.hibernate.orm.test.boot.models.xml.SimpleEntity;
|
|||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.OneToMany;
|
||||
|
||||
@Entity
|
||||
public class Employee {
|
||||
|
@ -20,5 +21,6 @@ public class Employee {
|
|||
@Id
|
||||
private int number;
|
||||
|
||||
private List<SimpleEntity> oneToMany;
|
||||
@OneToMany
|
||||
private List<Address> addresses;
|
||||
}
|
||||
|
|
|
@ -6,16 +6,14 @@
|
|||
*/
|
||||
package org.hibernate.orm.test.boot.models.xml.dynamic;
|
||||
|
||||
import org.hibernate.boot.internal.BootstrapContextImpl;
|
||||
import org.hibernate.boot.internal.MetadataBuilderImpl;
|
||||
import org.hibernate.boot.model.process.spi.ManagedResources;
|
||||
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.ClassDetails;
|
||||
import org.hibernate.models.spi.ClassDetailsRegistry;
|
||||
import org.hibernate.models.spi.SourceModelBuildingContext;
|
||||
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistryScope;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jakarta.persistence.NamedAttributeNode;
|
||||
|
@ -25,75 +23,66 @@ import jakarta.persistence.NamedSubgraph;
|
|||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.hibernate.orm.test.boot.models.SourceModelTestHelper.createBuildingContext;
|
||||
|
||||
@SuppressWarnings("JUnitMalformedDeclaration")
|
||||
public class NamedEntityGraphTest {
|
||||
@Test
|
||||
void testNamedEntityGraph() {
|
||||
@ServiceRegistry
|
||||
void testNamedEntityGraph(ServiceRegistryScope registryScope) {
|
||||
final ManagedResources managedResources = new AdditionalManagedResourcesImpl.Builder()
|
||||
.addXmlMappings( "mappings/models/dynamic/dynamic-named-entity-graph.xml" )
|
||||
.build();
|
||||
try (StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().build()) {
|
||||
final BootstrapContextImpl bootstrapContext = new BootstrapContextImpl(
|
||||
serviceRegistry,
|
||||
new MetadataBuilderImpl.MetadataBuildingOptionsImpl( serviceRegistry )
|
||||
);
|
||||
final SourceModelBuildingContext sourceModelBuildingContext = createBuildingContext(
|
||||
managedResources,
|
||||
false,
|
||||
new MetadataBuilderImpl.MetadataBuildingOptionsImpl( bootstrapContext.getServiceRegistry() ),
|
||||
bootstrapContext
|
||||
);
|
||||
final ClassDetailsRegistry classDetailsRegistry = sourceModelBuildingContext.getClassDetailsRegistry();
|
||||
final SourceModelBuildingContext sourceModelBuildingContext = createBuildingContext( managedResources, registryScope.getRegistry() );
|
||||
final ClassDetailsRegistry classDetailsRegistry = sourceModelBuildingContext.getClassDetailsRegistry();
|
||||
|
||||
{
|
||||
final ClassDetails employeeClassDetails = classDetailsRegistry.getClassDetails( "Employee" );
|
||||
final NamedEntityGraph namedEntityGraph = employeeClassDetails.getAnnotationUsage( NamedEntityGraph.class, sourceModelBuildingContext );
|
||||
assertThat( namedEntityGraph ).isNotNull();
|
||||
{
|
||||
final ClassDetails employeeClassDetails = classDetailsRegistry.getClassDetails( "Employee" );
|
||||
final NamedEntityGraph namedEntityGraph = employeeClassDetails.getAnnotationUsage( NamedEntityGraph.class, sourceModelBuildingContext );
|
||||
assertThat( namedEntityGraph ).isNotNull();
|
||||
|
||||
assertThat( namedEntityGraph.name() ).isEqualTo( "employee" );
|
||||
assertThat( namedEntityGraph.includeAllAttributes() ).isTrue();
|
||||
assertThat( namedEntityGraph.name() ).isEqualTo( "employee" );
|
||||
assertThat( namedEntityGraph.includeAllAttributes() ).isTrue();
|
||||
|
||||
final NamedAttributeNode[] attributeNodes = namedEntityGraph.attributeNodes();
|
||||
assertThat( attributeNodes ).hasSize( 2 );
|
||||
final NamedAttributeNode[] attributeNodes = namedEntityGraph.attributeNodes();
|
||||
assertThat( attributeNodes ).hasSize( 2 );
|
||||
|
||||
final NamedAttributeNode firstAttributeNode = attributeNodes[0];
|
||||
checkAttributeNode( firstAttributeNode, "name", "", "" );
|
||||
final NamedAttributeNode firstAttributeNode = attributeNodes[0];
|
||||
checkAttributeNode( firstAttributeNode, "name", "", "" );
|
||||
|
||||
final NamedAttributeNode secondAttributeNode = attributeNodes[1];
|
||||
checkAttributeNode( secondAttributeNode, "address", "employee.address", "" );
|
||||
final NamedAttributeNode secondAttributeNode = attributeNodes[1];
|
||||
checkAttributeNode( secondAttributeNode, "address", "employee.address", "" );
|
||||
|
||||
|
||||
final NamedSubgraph[] subgraphs = namedEntityGraph.subgraphs();
|
||||
assertThat( subgraphs ).hasSize( 2 );
|
||||
final NamedSubgraph[] subgraphs = namedEntityGraph.subgraphs();
|
||||
assertThat( subgraphs ).hasSize( 2 );
|
||||
|
||||
final NamedSubgraph firstSubgraph = subgraphs[0];
|
||||
assertThat( firstSubgraph.name() ).isEqualTo( "first.subgraph" );
|
||||
assertThat( firstSubgraph.type() ).isEqualTo( void.class );
|
||||
final NamedSubgraph firstSubgraph = subgraphs[0];
|
||||
assertThat( firstSubgraph.name() ).isEqualTo( "first.subgraph" );
|
||||
assertThat( firstSubgraph.type() ).isEqualTo( void.class );
|
||||
|
||||
final NamedAttributeNode[] firstSubgraphAttributeNodes = firstSubgraph.attributeNodes();
|
||||
assertThat( firstSubgraphAttributeNodes ).hasSize( 1 );
|
||||
checkAttributeNode( firstSubgraphAttributeNodes[0], "city", "", "" );
|
||||
final NamedAttributeNode[] firstSubgraphAttributeNodes = firstSubgraph.attributeNodes();
|
||||
assertThat( firstSubgraphAttributeNodes ).hasSize( 1 );
|
||||
checkAttributeNode( firstSubgraphAttributeNodes[0], "city", "", "" );
|
||||
|
||||
final NamedSubgraph secondSubgraph = subgraphs[1];
|
||||
assertThat( secondSubgraph.name() ).isEqualTo( "second.subgraph" );
|
||||
assertThat( secondSubgraph.type() ).isEqualTo( String.class );
|
||||
final NamedSubgraph secondSubgraph = subgraphs[1];
|
||||
assertThat( secondSubgraph.name() ).isEqualTo( "second.subgraph" );
|
||||
assertThat( secondSubgraph.type() ).isEqualTo( String.class );
|
||||
|
||||
final NamedAttributeNode[] secondSubgraphAttributeNodes = secondSubgraph.attributeNodes();
|
||||
assertThat( secondSubgraphAttributeNodes ).hasSize( 3 );
|
||||
final NamedAttributeNode[] secondSubgraphAttributeNodes = secondSubgraph.attributeNodes();
|
||||
assertThat( secondSubgraphAttributeNodes ).hasSize( 3 );
|
||||
|
||||
checkAttributeNode( secondSubgraphAttributeNodes[0], "city", "sub1", "" );
|
||||
checkAttributeNode( secondSubgraphAttributeNodes[1], "name", "sub", "" );
|
||||
checkAttributeNode( secondSubgraphAttributeNodes[2], "surname", "", "" );
|
||||
checkAttributeNode( secondSubgraphAttributeNodes[0], "city", "sub1", "" );
|
||||
checkAttributeNode( secondSubgraphAttributeNodes[1], "name", "sub", "" );
|
||||
checkAttributeNode( secondSubgraphAttributeNodes[2], "surname", "", "" );
|
||||
|
||||
|
||||
final NamedSubgraph[] subClassSubgraphUsages = namedEntityGraph.subclassSubgraphs();
|
||||
assertThat( subClassSubgraphUsages ).isEmpty();
|
||||
}
|
||||
final NamedSubgraph[] subClassSubgraphUsages = namedEntityGraph.subclassSubgraphs();
|
||||
assertThat( subClassSubgraphUsages ).isEmpty();
|
||||
}
|
||||
|
||||
{
|
||||
final ClassDetails addressClassDetails = classDetailsRegistry.getClassDetails( "Address" );
|
||||
final NamedEntityGraph namedEntityGraph = addressClassDetails.getDirectAnnotationUsage( NamedEntityGraph.class );
|
||||
assertThat( namedEntityGraph ).isNull();
|
||||
}
|
||||
{
|
||||
final ClassDetails addressClassDetails = classDetailsRegistry.getClassDetails( "Address" );
|
||||
final NamedEntityGraph namedEntityGraph = addressClassDetails.getDirectAnnotationUsage( NamedEntityGraph.class );
|
||||
assertThat( namedEntityGraph ).isNull();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,57 +7,49 @@
|
|||
package org.hibernate.orm.test.boot.models.xml.dynamic;
|
||||
|
||||
import org.hibernate.annotations.RowId;
|
||||
import org.hibernate.boot.internal.BootstrapContextImpl;
|
||||
import org.hibernate.boot.internal.MetadataBuilderImpl;
|
||||
import org.hibernate.boot.model.process.spi.ManagedResources;
|
||||
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.ClassDetails;
|
||||
import org.hibernate.models.spi.ClassDetailsRegistry;
|
||||
import org.hibernate.models.spi.SourceModelBuildingContext;
|
||||
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistryScope;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.hibernate.orm.test.boot.models.SourceModelTestHelper.createBuildingContext;
|
||||
|
||||
@SuppressWarnings("JUnitMalformedDeclaration")
|
||||
public class RowIdTest {
|
||||
@Test
|
||||
void testSimpleDynamicModel() {
|
||||
@ServiceRegistry
|
||||
void testSimpleDynamicModel(ServiceRegistryScope registryScope) {
|
||||
final ManagedResources managedResources = new AdditionalManagedResourcesImpl.Builder()
|
||||
.addXmlMappings( "mappings/models/dynamic/dynamic-rowid.xml" )
|
||||
.build();
|
||||
try (StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().build()) {
|
||||
final BootstrapContextImpl bootstrapContext = new BootstrapContextImpl(
|
||||
serviceRegistry,
|
||||
new MetadataBuilderImpl.MetadataBuildingOptionsImpl( serviceRegistry )
|
||||
);
|
||||
final SourceModelBuildingContext sourceModelBuildingContext = createBuildingContext(
|
||||
managedResources,
|
||||
false,
|
||||
new MetadataBuilderImpl.MetadataBuildingOptionsImpl( bootstrapContext.getServiceRegistry() ),
|
||||
bootstrapContext
|
||||
);
|
||||
final ClassDetailsRegistry classDetailsRegistry = sourceModelBuildingContext.getClassDetailsRegistry();
|
||||
final SourceModelBuildingContext sourceModelBuildingContext = createBuildingContext(
|
||||
managedResources,
|
||||
registryScope.getRegistry()
|
||||
);
|
||||
final ClassDetailsRegistry classDetailsRegistry = sourceModelBuildingContext.getClassDetailsRegistry();
|
||||
|
||||
{
|
||||
final ClassDetails classDetails = classDetailsRegistry.getClassDetails( "EntityWithoutRowId" );
|
||||
final RowId rowId = classDetails.getDirectAnnotationUsage( RowId.class );
|
||||
assertThat( rowId ).isNull();
|
||||
}
|
||||
{
|
||||
final ClassDetails classDetails = classDetailsRegistry.getClassDetails( "EntityWithoutRowId" );
|
||||
final RowId rowId = classDetails.getDirectAnnotationUsage( RowId.class );
|
||||
assertThat( rowId ).isNull();
|
||||
}
|
||||
|
||||
{
|
||||
final ClassDetails classDetails = classDetailsRegistry.getClassDetails( "EntityWithRowIdNoValue" );
|
||||
final RowId rowId = classDetails.getDirectAnnotationUsage( RowId.class );
|
||||
assertThat( rowId.value() ).isEmpty();
|
||||
}
|
||||
{
|
||||
final ClassDetails classDetails = classDetailsRegistry.getClassDetails( "EntityWithRowIdNoValue" );
|
||||
final RowId rowId = classDetails.getDirectAnnotationUsage( RowId.class );
|
||||
assertThat( rowId.value() ).isEmpty();
|
||||
}
|
||||
|
||||
{
|
||||
final ClassDetails classDetails = classDetailsRegistry.getClassDetails( "EntityWithRowId" );
|
||||
final RowId rowId = classDetails.getDirectAnnotationUsage( RowId.class );
|
||||
assertThat( rowId.value() ).isEqualTo( "ROW_ID" );
|
||||
}
|
||||
{
|
||||
final ClassDetails classDetails = classDetailsRegistry.getClassDetails( "EntityWithRowId" );
|
||||
final RowId rowId = classDetails.getDirectAnnotationUsage( RowId.class );
|
||||
assertThat( rowId.value() ).isEqualTo( "ROW_ID" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,17 +8,15 @@ package org.hibernate.orm.test.boot.models.xml.dynamic;
|
|||
|
||||
|
||||
import org.hibernate.annotations.TenantId;
|
||||
import org.hibernate.boot.internal.BootstrapContextImpl;
|
||||
import org.hibernate.boot.internal.MetadataBuilderImpl;
|
||||
import org.hibernate.boot.model.process.spi.ManagedResources;
|
||||
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.ClassDetails;
|
||||
import org.hibernate.models.spi.ClassDetailsRegistry;
|
||||
import org.hibernate.models.spi.FieldDetails;
|
||||
import org.hibernate.models.spi.SourceModelBuildingContext;
|
||||
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistryScope;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jakarta.persistence.Basic;
|
||||
|
@ -29,41 +27,31 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
import static org.hibernate.orm.test.boot.models.SourceModelTestHelper.createBuildingContext;
|
||||
|
||||
|
||||
@SuppressWarnings("JUnitMalformedDeclaration")
|
||||
public class TenantIdTest {
|
||||
@Test
|
||||
void testSimpleDynamicModel() {
|
||||
@ServiceRegistry
|
||||
void testSimpleDynamicModel(ServiceRegistryScope registryScope) {
|
||||
final ManagedResources managedResources = new AdditionalManagedResourcesImpl.Builder()
|
||||
.addXmlMappings( "mappings/models/dynamic/dynamic-tenantid.xml" )
|
||||
.build();
|
||||
try (StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().build()) {
|
||||
final BootstrapContextImpl bootstrapContext = new BootstrapContextImpl(
|
||||
serviceRegistry,
|
||||
new MetadataBuilderImpl.MetadataBuildingOptionsImpl( serviceRegistry )
|
||||
);
|
||||
final SourceModelBuildingContext sourceModelBuildingContext = createBuildingContext(
|
||||
managedResources,
|
||||
false,
|
||||
new MetadataBuilderImpl.MetadataBuildingOptionsImpl( bootstrapContext.getServiceRegistry() ),
|
||||
bootstrapContext
|
||||
);
|
||||
final ClassDetailsRegistry classDetailsRegistry = sourceModelBuildingContext.getClassDetailsRegistry();
|
||||
final SourceModelBuildingContext sourceModelBuildingContext = createBuildingContext( managedResources, registryScope.getRegistry() );
|
||||
final ClassDetailsRegistry classDetailsRegistry = sourceModelBuildingContext.getClassDetailsRegistry();
|
||||
|
||||
final ClassDetails classDetails = classDetailsRegistry.getClassDetails( "EntityWithTenantId" );
|
||||
final ClassDetails classDetails = classDetailsRegistry.getClassDetails( "EntityWithTenantId" );
|
||||
final FieldDetails tenantIdField = classDetails.findFieldByName( "tenantId" );
|
||||
|
||||
final FieldDetails tenantIdField = classDetails.findFieldByName( "tenantId" );
|
||||
final TenantId tenantId = tenantIdField.getDirectAnnotationUsage( TenantId.class );
|
||||
assertThat( tenantId ).isNotNull();
|
||||
|
||||
final TenantId tenantId = tenantIdField.getDirectAnnotationUsage( TenantId.class );
|
||||
assertThat( tenantId ).isNotNull();
|
||||
final Basic basic = tenantIdField.getDirectAnnotationUsage( Basic.class );
|
||||
assertThat( basic ).isNotNull();
|
||||
assertThat( basic.fetch() ).isEqualTo( FetchType.EAGER );
|
||||
assertThat( basic.optional() ).isTrue();
|
||||
|
||||
final Basic basic = tenantIdField.getDirectAnnotationUsage( Basic.class );
|
||||
assertThat( basic ).isNotNull();
|
||||
assertThat( basic.fetch() ).isEqualTo( FetchType.EAGER );
|
||||
assertThat( basic.optional() ).isTrue();
|
||||
|
||||
final Column column = tenantIdField.getDirectAnnotationUsage( Column.class );
|
||||
assertThat( column ).isNotNull();
|
||||
assertThat( column.name() ).isEqualTo( "TENANT_ID" );
|
||||
assertThat( column.insertable() ).isFalse();
|
||||
}
|
||||
final Column column = tenantIdField.getDirectAnnotationUsage( Column.class );
|
||||
assertThat( column ).isNotNull();
|
||||
assertThat( column.name() ).isEqualTo( "TENANT_ID" );
|
||||
assertThat( column.insertable() ).isFalse();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,13 +11,14 @@ import java.util.List;
|
|||
import org.hibernate.boot.internal.BootstrapContextImpl;
|
||||
import org.hibernate.boot.internal.MetadataBuilderImpl;
|
||||
import org.hibernate.boot.model.process.spi.ManagedResources;
|
||||
import org.hibernate.boot.model.source.internal.annotations.AdditionalManagedResourcesImpl;
|
||||
import org.hibernate.boot.models.categorize.spi.CategorizedDomainModel;
|
||||
import org.hibernate.boot.models.spi.JpaEventListener;
|
||||
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.MethodDetails;
|
||||
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistryScope;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
@ -27,32 +28,34 @@ import static org.hibernate.models.spi.ClassDetails.VOID_CLASS_DETAILS;
|
|||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@SuppressWarnings("JUnitMalformedDeclaration")
|
||||
public class JpaEventListenerTests {
|
||||
@Test
|
||||
void testGlobalRegistration() {
|
||||
@ServiceRegistry
|
||||
void testGlobalRegistration(ServiceRegistryScope registryScope) {
|
||||
final ManagedResources managedResources = new AdditionalManagedResourcesImpl.Builder()
|
||||
.addXmlMappings( "mappings/models/globals.xml" )
|
||||
.build();
|
||||
|
||||
try (StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().build()) {
|
||||
final BootstrapContextImpl bootstrapContext = new BootstrapContextImpl(
|
||||
serviceRegistry,
|
||||
new MetadataBuilderImpl.MetadataBuildingOptionsImpl( serviceRegistry )
|
||||
);
|
||||
final CategorizedDomainModel categorizedDomainModel = processManagedResources(
|
||||
managedResources,
|
||||
bootstrapContext
|
||||
);
|
||||
final List<JpaEventListener> registrations = categorizedDomainModel
|
||||
.getGlobalRegistrations()
|
||||
.getEntityListenerRegistrations();
|
||||
assertThat( registrations ).hasSize( 1 );
|
||||
final JpaEventListener registration = registrations.get( 0 );
|
||||
final MethodDetails postPersistMethod = registration.getPostPersistMethod();
|
||||
assertThat( postPersistMethod ).isNotNull();
|
||||
assertThat( postPersistMethod.getReturnType() ).isEqualTo( VOID_CLASS_DETAILS );
|
||||
assertThat( postPersistMethod.getArgumentTypes() ).hasSize( 1 );
|
||||
}
|
||||
final StandardServiceRegistry serviceRegistry = registryScope.getRegistry();
|
||||
final BootstrapContextImpl bootstrapContext = new BootstrapContextImpl(
|
||||
serviceRegistry,
|
||||
new MetadataBuilderImpl.MetadataBuildingOptionsImpl( serviceRegistry )
|
||||
);
|
||||
final CategorizedDomainModel categorizedDomainModel = processManagedResources(
|
||||
managedResources,
|
||||
bootstrapContext
|
||||
);
|
||||
final List<JpaEventListener> registrations = categorizedDomainModel
|
||||
.getGlobalRegistrations()
|
||||
.getEntityListenerRegistrations();
|
||||
assertThat( registrations ).hasSize( 1 );
|
||||
final JpaEventListener registration = registrations.get( 0 );
|
||||
final MethodDetails postPersistMethod = registration.getPostPersistMethod();
|
||||
assertThat( postPersistMethod ).isNotNull();
|
||||
assertThat( postPersistMethod.getReturnType() ).isEqualTo( VOID_CLASS_DETAILS );
|
||||
assertThat( postPersistMethod.getArgumentTypes() ).hasSize( 1 );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,18 +9,16 @@ package org.hibernate.orm.test.boot.models.xml.lifecycle;
|
|||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.hibernate.boot.internal.BootstrapContextImpl;
|
||||
import org.hibernate.boot.internal.MetadataBuilderImpl;
|
||||
import org.hibernate.boot.model.process.spi.ManagedResources;
|
||||
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.ClassDetails;
|
||||
import org.hibernate.models.spi.ClassDetailsRegistry;
|
||||
import org.hibernate.models.spi.MethodDetails;
|
||||
import org.hibernate.models.spi.SourceModelBuildingContext;
|
||||
import org.hibernate.orm.test.boot.models.xml.SimpleEntity;
|
||||
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistryScope;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jakarta.persistence.EntityListeners;
|
||||
|
@ -40,59 +38,53 @@ import static org.hibernate.orm.test.boot.models.SourceModelTestHelper.createBui
|
|||
*/
|
||||
public class EntityLifecycleTests {
|
||||
@Test
|
||||
void testEntityLifecycle() {
|
||||
@ServiceRegistry
|
||||
void testEntityLifecycle(ServiceRegistryScope registryScope) {
|
||||
final ManagedResources managedResources = new AdditionalManagedResourcesImpl.Builder()
|
||||
.addXmlMappings( "mappings/models/lifecycle/entity-lifecycle.xml" )
|
||||
.build();
|
||||
try (StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().build()) {
|
||||
final BootstrapContextImpl bootstrapContext = new BootstrapContextImpl(
|
||||
serviceRegistry,
|
||||
new MetadataBuilderImpl.MetadataBuildingOptionsImpl( serviceRegistry )
|
||||
);
|
||||
final SourceModelBuildingContext sourceModelBuildingContext = createBuildingContext(
|
||||
managedResources,
|
||||
false,
|
||||
new MetadataBuilderImpl.MetadataBuildingOptionsImpl( bootstrapContext.getServiceRegistry() ),
|
||||
bootstrapContext
|
||||
);
|
||||
final ClassDetailsRegistry classDetailsRegistry = sourceModelBuildingContext.getClassDetailsRegistry();
|
||||
final ClassDetails classDetails = classDetailsRegistry.getClassDetails( SimpleEntity.class.getName() );
|
||||
assertThat( classDetails.getName() ).isEqualTo( SimpleEntity.class.getName() );
|
||||
final SourceModelBuildingContext sourceModelBuildingContext = createBuildingContext(
|
||||
managedResources,
|
||||
registryScope.getRegistry()
|
||||
);
|
||||
final ClassDetailsRegistry classDetailsRegistry = sourceModelBuildingContext.getClassDetailsRegistry();
|
||||
final ClassDetails classDetails = classDetailsRegistry.getClassDetails( SimpleEntity.class.getName() );
|
||||
assertThat( classDetails.getName() ).isEqualTo( SimpleEntity.class.getName() );
|
||||
|
||||
// lifecycle callback methods
|
||||
getMethodDetails( classDetails, "prePersist" ).forEach( method -> {
|
||||
final PrePersist prePersist = method.getDirectAnnotationUsage( PrePersist.class );
|
||||
if ( !method.getArgumentTypes().isEmpty() ) {
|
||||
assertThat( prePersist ).isNull();
|
||||
}
|
||||
else {
|
||||
assertThat( prePersist ).isNotNull();
|
||||
}
|
||||
} );
|
||||
assertThat( getMethodDetails( classDetails, "preRemove" ).get( 0 ).getDirectAnnotationUsage( PreRemove.class ) ).isNotNull();
|
||||
assertThat( getMethodDetails( classDetails, "preUpdate" ).get( 0 ).getDirectAnnotationUsage( PreUpdate.class ) ).isNotNull();
|
||||
// lifecycle callback methods
|
||||
getMethodDetails( classDetails, "prePersist" ).forEach( method -> {
|
||||
final PrePersist prePersist = method.getDirectAnnotationUsage( PrePersist.class );
|
||||
if ( !method.getArgumentTypes().isEmpty() ) {
|
||||
assertThat( prePersist ).isNull();
|
||||
}
|
||||
else {
|
||||
assertThat( prePersist ).isNotNull();
|
||||
}
|
||||
} );
|
||||
assertThat( getMethodDetails( classDetails, "preRemove" ).get( 0 ).getDirectAnnotationUsage( PreRemove.class ) ).isNotNull();
|
||||
assertThat( getMethodDetails( classDetails, "preUpdate" ).get( 0 ).getDirectAnnotationUsage( PreUpdate.class ) ).isNotNull();
|
||||
|
||||
// entity listeners
|
||||
final EntityListeners entityListenersAnn = classDetails.getDirectAnnotationUsage( EntityListeners.class );
|
||||
assertThat( entityListenersAnn ).isNotNull();
|
||||
final Class<?>[] entityListeners = entityListenersAnn.value();
|
||||
assertThat( entityListeners ).hasSize( 1 );
|
||||
final Class<?> listener = entityListeners[0];
|
||||
assertThat( listener.getName() ).isEqualTo( SimpleEntityListener.class.getName() );
|
||||
final ClassDetails listenerClassDetails = classDetailsRegistry.getClassDetails( listener.getName() );
|
||||
getMethodDetails( listenerClassDetails, "postPersist" ).forEach( method -> {
|
||||
final PostPersist prePersist = method.getDirectAnnotationUsage( PostPersist.class );
|
||||
if ( method.getArgumentTypes().size() != 1 ) {
|
||||
assertThat( prePersist ).isNull();
|
||||
}
|
||||
else {
|
||||
assertThat( prePersist ).isNotNull();
|
||||
}
|
||||
} );
|
||||
assertThat( getMethodDetails( listenerClassDetails, "postRemove" ).get( 0 ).getDirectAnnotationUsage( PostRemove.class ) ).isNotNull();
|
||||
assertThat( getMethodDetails( listenerClassDetails, "postUpdate" ).get( 0 ).getDirectAnnotationUsage( PostUpdate.class ) ).isNotNull();
|
||||
assertThat( getMethodDetails( listenerClassDetails, "postLoad" ).get( 0 ).getDirectAnnotationUsage( PostLoad.class ) ).isNotNull();
|
||||
|
||||
// entity listeners
|
||||
final EntityListeners entityListenersAnn = classDetails.getDirectAnnotationUsage( EntityListeners.class );
|
||||
assertThat( entityListenersAnn ).isNotNull();
|
||||
final Class<?>[] entityListeners = entityListenersAnn.value();
|
||||
assertThat( entityListeners ).hasSize( 1 );
|
||||
final Class<?> listener = entityListeners[0];
|
||||
assertThat( listener.getName() ).isEqualTo( SimpleEntityListener.class.getName() );
|
||||
final ClassDetails listenerClassDetails = classDetailsRegistry.getClassDetails( listener.getName() );
|
||||
getMethodDetails( listenerClassDetails, "postPersist" ).forEach( method -> {
|
||||
final PostPersist prePersist = method.getDirectAnnotationUsage( PostPersist.class );
|
||||
if ( method.getArgumentTypes().size() != 1 ) {
|
||||
assertThat( prePersist ).isNull();
|
||||
}
|
||||
else {
|
||||
assertThat( prePersist ).isNotNull();
|
||||
}
|
||||
} );
|
||||
assertThat( getMethodDetails( listenerClassDetails, "postRemove" ).get( 0 ).getDirectAnnotationUsage( PostRemove.class ) ).isNotNull();
|
||||
assertThat( getMethodDetails( listenerClassDetails, "postUpdate" ).get( 0 ).getDirectAnnotationUsage( PostUpdate.class ) ).isNotNull();
|
||||
assertThat( getMethodDetails( listenerClassDetails, "postLoad" ).get( 0 ).getDirectAnnotationUsage( PostLoad.class ) ).isNotNull();
|
||||
}
|
||||
}
|
||||
|
||||
private List<MethodDetails> getMethodDetails(ClassDetails classDetails, String name) {
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
/*
|
||||
* 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.orm.test.hbm.query;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.query.named.NamedObjectRepository;
|
||||
import org.hibernate.query.sqm.spi.NamedSqmQueryMemento;
|
||||
|
||||
import org.hibernate.testing.bytecode.enhancement.EnhancementOptions;
|
||||
import org.hibernate.testing.bytecode.enhancement.extension.BytecodeEnhanced;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.JiraKey;
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||
import org.hibernate.testing.orm.junit.Setting;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@DomainModel(
|
||||
xmlMappings = {
|
||||
"org/hibernate/orm/test/hbm/query/HbmOverridesAnnotation.orm.xml",
|
||||
"org/hibernate/orm/test/hbm/query/HbmOverridesAnnotation.hbm.xml"
|
||||
}
|
||||
)
|
||||
@ServiceRegistry(
|
||||
settings = {
|
||||
@Setting( name ="hibernate.enable_specj_proprietary_syntax", value = "true"),
|
||||
@Setting( name ="hibernate.transform_hbm_xml.enabled", value = "true"),
|
||||
}
|
||||
)
|
||||
@SessionFactory
|
||||
@BytecodeEnhanced
|
||||
@EnhancementOptions(inlineDirtyChecking = true, lazyLoading = true, extendedEnhancement = true)
|
||||
public class HbmNamedQueryConfigurationTest {
|
||||
|
||||
@Test
|
||||
@JiraKey("HHH-15619")
|
||||
@JiraKey("HHH-15620")
|
||||
public void testHbmOverride(SessionFactoryScope scope) {
|
||||
NamedObjectRepository namedObjectRepository = scope.getSessionFactory()
|
||||
.getQueryEngine()
|
||||
.getNamedObjectRepository();
|
||||
NamedSqmQueryMemento<?> sqmQueryMemento = namedObjectRepository.getSqmQueryMemento( Bar.FIND_ALL );
|
||||
assertTrue( sqmQueryMemento.getCacheable() );
|
||||
}
|
||||
|
||||
}
|
|
@ -26,6 +26,7 @@ import org.hibernate.testing.orm.junit.BootstrapServiceRegistry;
|
|||
import org.hibernate.testing.orm.junit.BootstrapServiceRegistry.JavaService;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.DomainModelScope;
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class AdditionalMappingContributorBasicColumnTests {
|
||||
|
@ -37,6 +38,7 @@ public class AdditionalMappingContributorBasicColumnTests {
|
|||
impl = NameColumnOrmXmlContributor.class
|
||||
)
|
||||
)
|
||||
@ServiceRegistry
|
||||
@DomainModel
|
||||
@SuppressWarnings("JUnitMalformedDeclaration")
|
||||
void name(DomainModelScope domainModelScope) {
|
||||
|
@ -50,6 +52,7 @@ public class AdditionalMappingContributorBasicColumnTests {
|
|||
impl = UniqueColumnOrmXmlContributor.class
|
||||
)
|
||||
)
|
||||
@ServiceRegistry
|
||||
@DomainModel
|
||||
@SuppressWarnings("JUnitMalformedDeclaration")
|
||||
void unique(DomainModelScope domainModelScope) {
|
||||
|
@ -63,6 +66,7 @@ public class AdditionalMappingContributorBasicColumnTests {
|
|||
impl = NullableColumnOrmXmlContributor.class
|
||||
)
|
||||
)
|
||||
@ServiceRegistry
|
||||
@DomainModel
|
||||
@SuppressWarnings("JUnitMalformedDeclaration")
|
||||
void nullable(DomainModelScope domainModelScope) {
|
||||
|
@ -76,6 +80,7 @@ public class AdditionalMappingContributorBasicColumnTests {
|
|||
impl = LengthColumnOrmXmlContributor.class
|
||||
)
|
||||
)
|
||||
@ServiceRegistry
|
||||
@DomainModel
|
||||
@SuppressWarnings("JUnitMalformedDeclaration")
|
||||
void length(DomainModelScope domainModelScope) {
|
||||
|
@ -89,6 +94,7 @@ public class AdditionalMappingContributorBasicColumnTests {
|
|||
impl = PrecisionColumnOrmXmlContributor.class
|
||||
)
|
||||
)
|
||||
@ServiceRegistry
|
||||
@DomainModel
|
||||
@SuppressWarnings("JUnitMalformedDeclaration")
|
||||
void precision(DomainModelScope domainModelScope) {
|
||||
|
@ -102,6 +108,7 @@ public class AdditionalMappingContributorBasicColumnTests {
|
|||
impl = ScaleColumnOrmXmlContributor.class
|
||||
)
|
||||
)
|
||||
@ServiceRegistry
|
||||
@DomainModel
|
||||
@SuppressWarnings("JUnitMalformedDeclaration")
|
||||
void scale(DomainModelScope domainModelScope) {
|
||||
|
|
|
@ -55,11 +55,13 @@ logger.sql-result-ast.name=org.hibernate.orm.sql.results.graph.AST
|
|||
logger.sqm-tree.name=org.hibernate.orm.query.sqm.ast
|
||||
#logger.sqm-tree.level=debug
|
||||
|
||||
# Logs the result of hbm.xml -> mapping.xml transformation
|
||||
logger.hbm-xml.name=org.hibernate.orm.boot.models.hbm-transform
|
||||
#logger.hbm-xml.level=debug
|
||||
logger.hbm-xml.level=debug
|
||||
|
||||
# Logs the result of mapping.xml -> annotations
|
||||
logger.xml.name=org.hibernate.orm.boot.models.xml
|
||||
#logger.xml.level=debug
|
||||
logger.xml.level=debug
|
||||
|
||||
###############################################################################
|
||||
# package/class name based logging
|
||||
|
|
|
@ -22,10 +22,10 @@
|
|||
<property name="part1"/>
|
||||
<property name="part2"/>
|
||||
</component>
|
||||
<many-to-one name="another"/>
|
||||
<many-to-one name="another" class="BasicEntity"/>
|
||||
<bag name="others">
|
||||
<key/>
|
||||
<one-to-many/>
|
||||
<one-to-many class="BasicEntity"/>
|
||||
</bag>
|
||||
</class>
|
||||
</hibernate-mapping>
|
|
@ -6,8 +6,8 @@
|
|||
~ See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
-->
|
||||
<hibernate-mapping xmlns="http://www.hibernate.org/xsd/orm/hbm">
|
||||
<class name="SimpleEntity">
|
||||
<id/>
|
||||
<property name="name" />
|
||||
<class entity-name="SimpleEntity">
|
||||
<id name="id" type="integer"/>
|
||||
<property name="name" type="string"/>
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
|
|
|
@ -6,9 +6,10 @@
|
|||
-->
|
||||
<entity-mappings xmlns="http://www.hibernate.org/xsd/orm/mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
version="3.2">
|
||||
version="7.0">
|
||||
<package>org.hibernate.orm.test.boot.models.xml.column</package>
|
||||
<entity class="AnEntity" metadata-complete="true" access="FIELD">
|
||||
<secondary-table name="tbl"/>
|
||||
<attributes>
|
||||
<id name="id"/>
|
||||
<basic name="name" >
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
-->
|
||||
<entity-mappings xmlns="http://www.hibernate.org/xsd/orm/mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
version="3.2">
|
||||
version="7.0">
|
||||
<package>org.hibernate.orm.test.boot.models.xml.complete</package>
|
||||
|
||||
<entity class="Root" metadata-complete="true" access="FIELD">
|
||||
|
@ -16,7 +16,9 @@
|
|||
<id name="id">
|
||||
<column name="pk"/>
|
||||
</id>
|
||||
<basic name="name"/>
|
||||
<basic name="name">
|
||||
<type value="string"/>
|
||||
</basic>
|
||||
</attributes>
|
||||
</entity>
|
||||
<entity class="Sub" metadata-complete="true" access="FIELD">
|
||||
|
@ -31,6 +33,7 @@
|
|||
<discriminator-column/>
|
||||
<attributes>
|
||||
<id name="id"/>
|
||||
<embedded name="name"/>
|
||||
</attributes>
|
||||
</entity>
|
||||
|
||||
|
@ -42,4 +45,11 @@
|
|||
<id name="id"/>
|
||||
</attributes>
|
||||
</entity>
|
||||
|
||||
<embeddable class="Name" metadata-complete="true">
|
||||
<attributes>
|
||||
<basic name="first"/>
|
||||
<basic name="last"/>
|
||||
</attributes>
|
||||
</embeddable>
|
||||
</entity-mappings>
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
<entity-mappings xmlns="http://www.hibernate.org/xsd/orm/mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
version="7.0">
|
||||
<package>org.hibernate.orm.test.boot.models.xml.complete</package>
|
||||
<access>FIELD</access>
|
||||
<entity class="Thing" metadata-complete="true">
|
||||
<attributes>
|
||||
<id name="id"/>
|
||||
<basic name="name"/>
|
||||
</attributes>
|
||||
</entity>
|
||||
</entity-mappings>
|
|
@ -7,7 +7,7 @@
|
|||
<entity-mappings xmlns="http://www.hibernate.org/xsd/orm/mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
version="7.0">
|
||||
<entity class="org.hibernate.orm.test.boot.models.xml.dynamic.Employee" access="FIELD">
|
||||
<entity class="org.hibernate.orm.test.boot.models.xml.dynamic.Employee" access="FIELD" metadata-complete="true">
|
||||
<id-class class="org.hibernate.orm.test.boot.models.xml.dynamic.EmployeePK"/>
|
||||
<attributes>
|
||||
<id name="name"/>
|
||||
|
|
|
@ -11,10 +11,12 @@
|
|||
<id-class class="org.hibernate.orm.test.boot.models.xml.dynamic.EmployeePK"/>
|
||||
<attributes>
|
||||
<id name="name"/>
|
||||
<id name="number"/>
|
||||
<one-to-many name="oneToMany" fetch="EAGER" not-found="IGNORE">
|
||||
<join-column name="employee_id" insertable="false" updatable="false">
|
||||
<foreign-key name="employee_fk" constraint-mode="NO_CONSTRAINT"/>
|
||||
<id name="number">
|
||||
<column name="emp_num"/>
|
||||
</id>
|
||||
<one-to-many name="addresses" fetch="EAGER">
|
||||
<join-column name="employee_id" referenced-column-name="emp_num" insertable="false" updatable="false">
|
||||
<foreign-key name="employee_address_fk" constraint-mode="NO_CONSTRAINT"/>
|
||||
<check-constraint name="employee_id_nn" constraint="employee_id is not null"/>
|
||||
</join-column>
|
||||
<cascade>
|
||||
|
@ -26,4 +28,14 @@
|
|||
</one-to-many>
|
||||
</attributes>
|
||||
</entity>
|
||||
|
||||
<entity class="org.hibernate.orm.test.boot.models.xml.dynamic.Address" access="FIELD">
|
||||
<attributes>
|
||||
<id name="id"/>
|
||||
<basic name="street"/>
|
||||
<basic name="city"/>
|
||||
<basic name="state"/>
|
||||
<basic name="zip"/>
|
||||
</attributes>
|
||||
</entity>
|
||||
</entity-mappings>
|
|
@ -9,7 +9,7 @@
|
|||
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
||||
|
||||
<hibernate-mapping package="org.hibernate.test.hbm._extends">
|
||||
<hibernate-mapping>
|
||||
<subclass entity-name="Leaf" discriminator-value="L" extends="Branch">
|
||||
</subclass>
|
||||
|
||||
|
@ -17,8 +17,8 @@
|
|||
</subclass>
|
||||
|
||||
<class entity-name="Root" discriminator-value="R">
|
||||
<id/>
|
||||
<id name="id" type="integer"/>
|
||||
<discriminator column="the_type"/>
|
||||
<property name="name"/>
|
||||
<property name="name" type="string"/>
|
||||
</class>
|
||||
</hibernate-mapping>
|
|
@ -11,9 +11,9 @@
|
|||
|
||||
<hibernate-mapping package="org.hibernate.test.hbm._extends">
|
||||
<class entity-name="Root" discriminator-value="R">
|
||||
<id/>
|
||||
<discriminator column="the_type"/>
|
||||
<property name="name"/>
|
||||
<id name="id" type="integer"/>
|
||||
<discriminator column="the_type" type="string"/>
|
||||
<property name="name" type="string"/>
|
||||
<subclass entity-name="Branch" discriminator-value="B">
|
||||
<subclass entity-name="Leaf" discriminator-value="L">
|
||||
</subclass>
|
||||
|
|
|
@ -19,6 +19,11 @@
|
|||
<join-formula>name</join-formula>
|
||||
<join-formula>'HOME'</join-formula>
|
||||
</one-to-one>
|
||||
|
||||
<one-to-one name="mailingAddress">
|
||||
<join-formula>name</join-formula>
|
||||
<join-formula>'HOME'</join-formula>
|
||||
</one-to-one>
|
||||
</attributes>
|
||||
</entity>
|
||||
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
<!DOCTYPE hibernate-mapping PUBLIC
|
||||
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
||||
|
||||
<hibernate-mapping package="">
|
||||
|
||||
<class name="Person">
|
||||
<id name="id"/>
|
||||
|
||||
<component name="name" class="Name">
|
||||
<property name="first"/>
|
||||
<property name="last"/>
|
||||
</component>
|
||||
|
||||
<component name="homeAddress" class="Address">
|
||||
<property name="city" column="home_address_city"/>
|
||||
<property name="zipCode" column="home_address_zip"/>
|
||||
</component>
|
||||
|
||||
<component name="workAddress" class="Address">
|
||||
<property name="city" column="work_address_city"/>
|
||||
<property name="zipCode" column="work_address_zip"/>
|
||||
</component>
|
||||
</class>
|
||||
|
||||
</hibernate-mapping>
|
|
@ -0,0 +1,55 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<entity-mappings xmlns="http://www.hibernate.org/xsd/orm/mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
version="7.0">
|
||||
<package></package>
|
||||
|
||||
<entity class="Person">
|
||||
<attributes>
|
||||
<id name="id"/>
|
||||
|
||||
<embedded name="name"/>
|
||||
|
||||
<embedded name="homeAddress">
|
||||
<attribute-override name="city">
|
||||
<column name="home_address_city"/>
|
||||
</attribute-override>
|
||||
<attribute-override name="zipCode">
|
||||
<column name="home_address_zip"/>
|
||||
</attribute-override>
|
||||
</embedded>
|
||||
|
||||
<embedded name="workAddress">
|
||||
<attribute-override name="city">
|
||||
<column name="work_address_city"/>
|
||||
</attribute-override>
|
||||
<attribute-override name="zipCode">
|
||||
<column name="work_address_zip"/>
|
||||
</attribute-override>
|
||||
</embedded>
|
||||
</attributes>
|
||||
</entity>
|
||||
|
||||
<embeddable class="Name">
|
||||
<attributes>
|
||||
<basic name="first"/>
|
||||
<basic name="last"/>
|
||||
</attributes>
|
||||
</embeddable>
|
||||
|
||||
<embeddable class="Address">
|
||||
<attributes>
|
||||
<basic name="city"/>
|
||||
<basic name="zip"/>
|
||||
</attributes>
|
||||
</embeddable>
|
||||
|
||||
</entity-mappings>
|
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
||||
|
||||
<hibernate-mapping package="org.hibernate.orm.test.hbm.query">
|
||||
<query name="Bar.findAll" cacheable="true">
|
||||
select b from Bar b
|
||||
</query>
|
||||
</hibernate-mapping>
|
|
@ -1,20 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<entity-mappings
|
||||
xmlns="http://java.sun.com/xml/ns/persistence/orm"
|
||||
version="2.0">
|
||||
<entity class="org.hibernate.orm.test.hbm.query.Bar">
|
||||
<attributes>
|
||||
<embedded-id name="id">
|
||||
<attribute-override name="id1">
|
||||
<column name="bar_id1"/>
|
||||
</attribute-override>
|
||||
<attribute-override name="id2">
|
||||
<column name="bar_id2"/>
|
||||
</attribute-override>
|
||||
</embedded-id>
|
||||
<basic name="name">
|
||||
<column name="bar_name"/>
|
||||
</basic>
|
||||
</attributes>
|
||||
</entity>
|
||||
</entity-mappings>
|
|
@ -72,7 +72,7 @@ dependencyResolutionManagement {
|
|||
def byteBuddyVersion = version "byteBuddy", "1.14.18"
|
||||
def classmateVersion = version "classmate", "1.5.1"
|
||||
def geolatteVersion = version "geolatte", "1.9.1"
|
||||
def hibernateModelsVersion = version "hibernateModels", "0.8.5"
|
||||
def hibernateModelsVersion = version "hibernateModels", "0.8.6"
|
||||
def jandexVersion = version "jandex", "3.2.0"
|
||||
def hcannVersion = version "hcann", "7.0.1.Final"
|
||||
def jacksonVersion = version "jackson", "2.17.0"
|
||||
|
|
Loading…
Reference in New Issue