various cleanups + improvements in org.hiberate.boot.model.internal
1. improve/cleanup logging (remove some log messages that don't naively seem more useful than lots of things we don't log) 2. report problems in AttributeConverter application using an error instead of a debug-level log message 3. various misc minor code cleanups in the Binders
This commit is contained in:
parent
17ea897a9d
commit
d1c046e17c
|
@ -21,7 +21,6 @@ import org.hibernate.boot.model.source.spi.AttributePath;
|
|||
import org.hibernate.boot.models.JpaAnnotations;
|
||||
import org.hibernate.boot.models.annotations.internal.ColumnJpaAnnotation;
|
||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||
import org.hibernate.internal.CoreLogging;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.models.spi.AnnotationTarget;
|
||||
import org.hibernate.models.spi.ClassDetails;
|
||||
|
@ -30,8 +29,6 @@ import org.hibernate.models.spi.SourceModelBuildingContext;
|
|||
import org.hibernate.usertype.internal.AbstractTimeZoneStorageCompositeUserType;
|
||||
import org.hibernate.usertype.internal.OffsetTimeCompositeUserType;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import jakarta.persistence.AssociationOverride;
|
||||
import jakarta.persistence.AttributeOverride;
|
||||
import jakarta.persistence.Column;
|
||||
|
@ -53,7 +50,6 @@ import static org.hibernate.internal.util.collections.CollectionHelper.isNotEmpt
|
|||
* @author Emmanuel Bernard
|
||||
*/
|
||||
public abstract class AbstractPropertyHolder implements PropertyHolder {
|
||||
private static final Logger log = CoreLogging.logger( AbstractPropertyHolder.class );
|
||||
|
||||
private final String path;
|
||||
protected final AbstractPropertyHolder parent;
|
||||
|
@ -106,8 +102,6 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
|
|||
}
|
||||
}
|
||||
|
||||
log.debugf( "Attempting to locate auto-apply AttributeConverter for attributeMember [%s:%s]", path, attributeMember.getName() );
|
||||
|
||||
return context.getMetadataCollector()
|
||||
.getConverterRegistry()
|
||||
.getAttributeConverterAutoApplyHandler()
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
*/
|
||||
package org.hibernate.boot.model.internal;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -39,11 +38,10 @@ import org.hibernate.mapping.Table;
|
|||
import org.hibernate.models.spi.MemberDetails;
|
||||
import org.hibernate.models.spi.SourceModelBuildingContext;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import static org.hibernate.boot.model.internal.BinderHelper.getPath;
|
||||
import static org.hibernate.boot.model.internal.BinderHelper.getRelativePath;
|
||||
import static org.hibernate.boot.model.internal.DialectOverridesAnnotationHelper.getOverridableAnnotation;
|
||||
import static org.hibernate.internal.CoreLogging.messageLogger;
|
||||
import static org.hibernate.internal.util.StringHelper.isBlank;
|
||||
import static org.hibernate.internal.util.StringHelper.isEmpty;
|
||||
import static org.hibernate.internal.util.StringHelper.isNotEmpty;
|
||||
|
@ -69,7 +67,7 @@ import static org.hibernate.internal.util.collections.CollectionHelper.isNotEmpt
|
|||
*/
|
||||
public class AnnotatedColumn {
|
||||
|
||||
private static final CoreMessageLogger LOG = Logger.getMessageLogger( MethodHandles.lookup(), CoreMessageLogger.class, AnnotatedColumn.class.getName() );
|
||||
private static final CoreMessageLogger LOG = messageLogger( AnnotatedColumn.class );
|
||||
|
||||
private Column mappingColumn;
|
||||
private boolean insertable = true;
|
||||
|
@ -244,7 +242,9 @@ public class AnnotatedColumn {
|
|||
|
||||
public void bind() {
|
||||
if ( isNotEmpty( formulaString ) ) {
|
||||
LOG.debugf( "Binding formula %s", formulaString );
|
||||
if ( LOG.isDebugEnabled() ) {
|
||||
LOG.debug( "Binding formula: " + formulaString );
|
||||
}
|
||||
formula = new Formula();
|
||||
formula.setFormula( formulaString );
|
||||
}
|
||||
|
@ -277,7 +277,7 @@ public class AnnotatedColumn {
|
|||
mappingColumn.setGeneratedAs( generatedAs );
|
||||
}
|
||||
if ( LOG.isDebugEnabled() ) {
|
||||
LOG.debugf( "Binding column: %s", toString() );
|
||||
LOG.debug( "Binding column: " + logicalColumnName );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -709,7 +709,9 @@ public class AnnotatedColumn {
|
|||
+ " '@AttributeOverride's but the overridden property has " + overriddenCols.length
|
||||
+ " columns (every column must have exactly one '@AttributeOverride')" );
|
||||
}
|
||||
LOG.debugf( "Column(s) overridden for property %s", inferredData.getPropertyName() );
|
||||
if ( LOG.isDebugEnabled() ) {
|
||||
LOG.debug( "Column mapping overridden for property: " + inferredData.getPropertyName() );
|
||||
}
|
||||
return isEmpty( overriddenCols ) ? null : overriddenCols;
|
||||
}
|
||||
else {
|
||||
|
@ -1020,14 +1022,11 @@ public class AnnotatedColumn {
|
|||
public String toString() {
|
||||
final StringBuilder string = new StringBuilder();
|
||||
string.append( getClass().getSimpleName() ).append( "(" );
|
||||
if ( isNotEmpty( logicalColumnName ) ) {
|
||||
string.append( "column='" ).append( logicalColumnName ).append( "'," );
|
||||
}
|
||||
if ( isNotEmpty( formulaString ) ) {
|
||||
string.append( "formula='" ).append( formulaString ).append( "'," );
|
||||
string.append( "formula='" ).append( formulaString );
|
||||
}
|
||||
if ( string.charAt( string.length()-1 ) == ',' ) {
|
||||
string.setLength( string.length()-1 );
|
||||
else if ( isNotEmpty( logicalColumnName ) ) {
|
||||
string.append( "column='" ).append( logicalColumnName );
|
||||
}
|
||||
string.append( ")" );
|
||||
return string.toString();
|
||||
|
|
|
@ -46,6 +46,7 @@ import jakarta.persistence.Table;
|
|||
|
||||
import static org.hibernate.boot.model.internal.AnnotatedClassType.EMBEDDABLE;
|
||||
import static org.hibernate.boot.model.internal.AnnotatedClassType.ENTITY;
|
||||
import static org.hibernate.boot.model.internal.EntityBinder.bindEntityClass;
|
||||
import static org.hibernate.boot.model.internal.FilterDefBinder.bindFilterDefs;
|
||||
import static org.hibernate.boot.model.internal.GeneratorParameters.interpretSequenceGenerator;
|
||||
import static org.hibernate.boot.model.internal.GeneratorParameters.interpretTableGenerator;
|
||||
|
@ -79,7 +80,7 @@ public final class AnnotationBinder {
|
|||
interpretSequenceGenerator( generatorRegistration.configuration(), definitionBuilder );
|
||||
final IdentifierGeneratorDefinition idGenDef = definitionBuilder.build();
|
||||
if ( LOG.isTraceEnabled() ) {
|
||||
LOG.tracef( "Adding global sequence generator with name: %s", name );
|
||||
LOG.trace( "Adding global sequence generator with name: " + name );
|
||||
}
|
||||
context.getMetadataCollector().addDefaultIdentifierGenerator( idGenDef );
|
||||
} );
|
||||
|
@ -89,7 +90,7 @@ public final class AnnotationBinder {
|
|||
interpretTableGenerator( generatorRegistration.configuration(), definitionBuilder );
|
||||
final IdentifierGeneratorDefinition idGenDef = definitionBuilder.build();
|
||||
if ( LOG.isTraceEnabled() ) {
|
||||
LOG.tracef( "Adding global table generator with name: %s", name );
|
||||
LOG.trace( "Adding global table generator with name: " + name );
|
||||
}
|
||||
context.getMetadataCollector().addDefaultIdentifierGenerator( idGenDef );
|
||||
} );
|
||||
|
@ -217,7 +218,7 @@ public final class AnnotationBinder {
|
|||
// try to find class level generators
|
||||
// GeneratorBinder.registerGlobalGenerators( classDetails, context );
|
||||
if ( context.getMetadataCollector().getClassType( classDetails ) == ENTITY ) {
|
||||
EntityBinder.bindEntityClass( classDetails, inheritanceStatePerClass, context );
|
||||
bindEntityClass( classDetails, inheritanceStatePerClass, context );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -5,7 +5,6 @@
|
|||
package org.hibernate.boot.model.internal;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -117,7 +116,6 @@ import org.hibernate.usertype.CompositeUserType;
|
|||
import org.hibernate.usertype.ParameterizedType;
|
||||
import org.hibernate.usertype.UserCollectionType;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import jakarta.persistence.Access;
|
||||
import jakarta.persistence.AttributeOverride;
|
||||
|
@ -168,6 +166,7 @@ import static org.hibernate.boot.model.internal.EmbeddableBinder.fillEmbeddable;
|
|||
import static org.hibernate.boot.model.internal.GeneratorBinder.visitIdGeneratorDefinitions;
|
||||
import static org.hibernate.boot.model.internal.PropertyHolderBuilder.buildPropertyHolder;
|
||||
import static org.hibernate.engine.spi.ExecuteUpdateResultCheckStyle.fromResultCheckStyle;
|
||||
import static org.hibernate.internal.CoreLogging.messageLogger;
|
||||
import static org.hibernate.internal.util.ReflectHelper.getDefaultSupplier;
|
||||
import static org.hibernate.internal.util.StringHelper.getNonEmptyOrConjunctionIfBothNonEmpty;
|
||||
import static org.hibernate.internal.util.StringHelper.isBlank;
|
||||
|
@ -185,7 +184,7 @@ import static org.hibernate.mapping.MappingHelper.createLocalUserCollectionTypeB
|
|||
* @author Emmanuel Bernard
|
||||
*/
|
||||
public abstract class CollectionBinder {
|
||||
private static final CoreMessageLogger LOG = Logger.getMessageLogger( MethodHandles.lookup(), CoreMessageLogger.class, CollectionBinder.class.getName() );
|
||||
private static final CoreMessageLogger LOG = messageLogger( CollectionBinder.class );
|
||||
|
||||
private static final List<Class<?>> INFERRED_CLASS_PRIORITY = List.of(
|
||||
List.class,
|
||||
|
@ -1207,7 +1206,9 @@ public abstract class CollectionBinder {
|
|||
public void bind() {
|
||||
collection = createCollection( propertyHolder.getPersistentClass() );
|
||||
final String role = qualify( propertyHolder.getPath(), propertyName );
|
||||
LOG.debugf( "Collection role: %s", role );
|
||||
if ( LOG.isDebugEnabled() ) {
|
||||
LOG.debug( "Binding collection role: " + role );
|
||||
}
|
||||
collection.setRole( role );
|
||||
collection.setMappedByProperty( mappedBy );
|
||||
|
||||
|
@ -1642,7 +1643,7 @@ public abstract class CollectionBinder {
|
|||
}
|
||||
|
||||
/**
|
||||
* return true if it's a Fk, false if it's an association table
|
||||
* @return true if it's a foreign key, false if it's an association table
|
||||
*/
|
||||
protected boolean bindStarToManySecondPass(Map<String, PersistentClass> persistentClasses) {
|
||||
if ( noAssociationTable( persistentClasses ) ) {
|
||||
|
@ -1740,9 +1741,6 @@ public abstract class CollectionBinder {
|
|||
else {
|
||||
collection.setCollectionTable( foreignJoinColumns.getTable() );
|
||||
}
|
||||
if ( LOG.isDebugEnabled() ) {
|
||||
LOG.debugf( "Mapping collection: %s -> %s", getRole(), collection.getCollectionTable().getName() );
|
||||
}
|
||||
|
||||
bindSynchronize();
|
||||
bindFilters( false );
|
||||
|
@ -2952,7 +2950,7 @@ public abstract class CollectionBinder {
|
|||
|
||||
private void logOneToManySecondPass() {
|
||||
if ( LOG.isDebugEnabled() ) {
|
||||
LOG.debugf( "Binding a OneToMany: %s through a foreign key", safeCollectionRole() );
|
||||
LOG.debug( "Binding @OneToMany through foreign key: " + safeCollectionRole() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2962,16 +2960,16 @@ public abstract class CollectionBinder {
|
|||
boolean isManyToAny) {
|
||||
if ( LOG.isDebugEnabled() ) {
|
||||
if ( isCollectionOfEntities && isOneToMany ) {
|
||||
LOG.debugf( "Binding a OneToMany: %s through an association table", safeCollectionRole() );
|
||||
LOG.debug( "Binding @OneToMany through association table: " + safeCollectionRole() );
|
||||
}
|
||||
else if ( isCollectionOfEntities ) {
|
||||
LOG.debugf( "Binding a ManyToMany: %s", safeCollectionRole() );
|
||||
LOG.debug( "Binding @ManyToMany through association table: " + safeCollectionRole() );
|
||||
}
|
||||
else if ( isManyToAny ) {
|
||||
LOG.debugf( "Binding a ManyToAny: %s", safeCollectionRole() );
|
||||
LOG.debug( "Binding @ManyToAny: " + safeCollectionRole() );
|
||||
}
|
||||
else {
|
||||
LOG.debugf( "Binding a collection of element: %s", safeCollectionRole() );
|
||||
LOG.debug( "Binding @ElementCollection to collection table: " + safeCollectionRole() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ import org.hibernate.annotations.ManyToAny;
|
|||
import org.hibernate.annotations.MapKeyType;
|
||||
import org.hibernate.boot.model.convert.spi.ConverterDescriptor;
|
||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||
import org.hibernate.internal.CoreLogging;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.mapping.Collection;
|
||||
import org.hibernate.mapping.Join;
|
||||
|
@ -36,6 +35,7 @@ import jakarta.persistence.MapKeyTemporal;
|
|||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.Temporal;
|
||||
|
||||
import static org.hibernate.internal.CoreLogging.messageLogger;
|
||||
import static org.hibernate.internal.util.StringHelper.isEmpty;
|
||||
import static org.hibernate.internal.util.StringHelper.isNotEmpty;
|
||||
|
||||
|
@ -44,7 +44,7 @@ import static org.hibernate.internal.util.StringHelper.isNotEmpty;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public class CollectionPropertyHolder extends AbstractPropertyHolder {
|
||||
private static final CoreMessageLogger log = CoreLogging.messageLogger( CollectionPropertyHolder.class );
|
||||
private static final CoreMessageLogger LOG = messageLogger( CollectionPropertyHolder.class );
|
||||
|
||||
private final Collection collection;
|
||||
|
||||
|
@ -111,11 +111,7 @@ public class CollectionPropertyHolder extends AbstractPropertyHolder {
|
|||
final AttributeConversionInfo info = new AttributeConversionInfo( convertAnnotation, collectionProperty );
|
||||
final String attributeName = info.getAttributeName();
|
||||
if ( collection.isMap() ) {
|
||||
final boolean specCompliant = isNotEmpty( attributeName )
|
||||
&& ( attributeName.startsWith( "key" ) || attributeName.startsWith( "value" ) );
|
||||
if ( !specCompliant ) {
|
||||
log.nonCompliantMapConversion( collection.getRole() );
|
||||
}
|
||||
logSpecNoncompliance( attributeName, collection.getRole() );
|
||||
}
|
||||
|
||||
if ( isEmpty( attributeName ) ) {
|
||||
|
@ -187,6 +183,14 @@ public class CollectionPropertyHolder extends AbstractPropertyHolder {
|
|||
}
|
||||
}
|
||||
|
||||
private static void logSpecNoncompliance(String attributeName, String role) {
|
||||
final boolean specCompliant = isNotEmpty( attributeName )
|
||||
&& (attributeName.startsWith( "key" ) || attributeName.startsWith( "value" ) );
|
||||
if ( !specCompliant ) {
|
||||
LOG.nonCompliantMapConversion( role );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if path has the given prefix and remove it.
|
||||
*
|
||||
|
@ -202,12 +206,12 @@ public class CollectionPropertyHolder extends AbstractPropertyHolder {
|
|||
if ( path.equals(prefix) ) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (path.startsWith(prefix + ".")) {
|
||||
else if ( path.startsWith(prefix + ".") ) {
|
||||
return path.substring( prefix.length() + 1 );
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
else {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -402,14 +406,6 @@ public class CollectionPropertyHolder extends AbstractPropertyHolder {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.debugf(
|
||||
"Attempting to locate auto-apply AttributeConverter for collection element [%s]",
|
||||
collection.getRole()
|
||||
);
|
||||
|
||||
// todo : do we need to pass along `XClass elementXClass`?
|
||||
|
||||
return getContext().getMetadataCollector()
|
||||
.getConverterRegistry()
|
||||
.getAttributeConverterAutoApplyHandler()
|
||||
|
@ -433,14 +429,6 @@ public class CollectionPropertyHolder extends AbstractPropertyHolder {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.debugf(
|
||||
"Attempting to locate auto-apply AttributeConverter for collection key [%s]",
|
||||
collection.getRole()
|
||||
);
|
||||
|
||||
// todo : do we need to pass along `XClass keyXClass`?
|
||||
|
||||
return getContext().getMetadataCollector()
|
||||
.getConverterRegistry()
|
||||
.getAttributeConverterAutoApplyHandler()
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
*/
|
||||
package org.hibernate.boot.model.internal;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.MappingException;
|
||||
|
@ -17,7 +16,7 @@ import org.hibernate.mapping.PersistentClass;
|
|||
import org.hibernate.mapping.Selectable;
|
||||
import org.hibernate.mapping.Value;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
import static org.hibernate.internal.CoreLogging.messageLogger;
|
||||
|
||||
/**
|
||||
* Collection second pass
|
||||
|
@ -26,7 +25,7 @@ import org.jboss.logging.Logger;
|
|||
*/
|
||||
public abstract class CollectionSecondPass implements SecondPass {
|
||||
|
||||
private static final CoreMessageLogger LOG = Logger.getMessageLogger( MethodHandles.lookup(), CoreMessageLogger.class, CollectionSecondPass.class.getName() );
|
||||
private static final CoreMessageLogger LOG = messageLogger( CollectionSecondPass.class);
|
||||
|
||||
private final Collection collection;
|
||||
|
||||
|
@ -38,7 +37,7 @@ public abstract class CollectionSecondPass implements SecondPass {
|
|||
public void doSecondPass(Map<String, PersistentClass> persistentClasses)
|
||||
throws MappingException {
|
||||
if ( LOG.isDebugEnabled() ) {
|
||||
LOG.debugf( "Second pass for collection: %s", collection.getRole() );
|
||||
LOG.debug( "Second pass for collection: " + collection.getRole() );
|
||||
}
|
||||
|
||||
secondPass( persistentClasses );
|
||||
|
|
|
@ -364,7 +364,9 @@ public class EmbeddableBinder {
|
|||
);
|
||||
|
||||
final String subpath = getPath( propertyHolder, inferredData );
|
||||
LOG.tracev( "Binding component with path: {0}", subpath );
|
||||
if ( LOG.isDebugEnabled() ) {
|
||||
LOG.debug( "Binding component with path: " + subpath );
|
||||
}
|
||||
final PropertyHolder subholder = buildPropertyHolder(
|
||||
component,
|
||||
subpath,
|
||||
|
@ -602,7 +604,6 @@ public class EmbeddableBinder {
|
|||
PropertyHolder holder,
|
||||
MetadataBuildingContext context) {
|
||||
assert component.getDiscriminator() == null;
|
||||
LOG.tracev( "Setting discriminator for embeddable {0}", component.getComponentClassName() );
|
||||
final AnnotatedColumns columns = new AnnotatedColumns();
|
||||
columns.setPropertyHolder( holder );
|
||||
columns.setBuildingContext( context );
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
package org.hibernate.boot.model.internal;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
@ -106,8 +105,6 @@ import org.hibernate.models.spi.SourceModelBuildingContext;
|
|||
import org.hibernate.models.spi.TypeDetails;
|
||||
import org.hibernate.spi.NavigablePath;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import jakarta.persistence.Access;
|
||||
import jakarta.persistence.AssociationOverride;
|
||||
import jakarta.persistence.AttributeOverride;
|
||||
|
@ -136,6 +133,7 @@ import static org.hibernate.boot.model.internal.AnnotatedDiscriminatorColumn.bui
|
|||
import static org.hibernate.boot.model.internal.AnnotatedJoinColumn.buildInheritanceJoinColumn;
|
||||
import static org.hibernate.boot.model.internal.BinderHelper.extractFromPackage;
|
||||
import static org.hibernate.boot.model.internal.BinderHelper.getMappedSuperclassOrNull;
|
||||
import static org.hibernate.boot.model.internal.BinderHelper.getPath;
|
||||
import static org.hibernate.boot.model.internal.BinderHelper.hasToOneAnnotation;
|
||||
import static org.hibernate.boot.model.internal.BinderHelper.noConstraint;
|
||||
import static org.hibernate.boot.model.internal.BinderHelper.toAliasEntityMap;
|
||||
|
@ -152,6 +150,7 @@ import static org.hibernate.boot.model.internal.TableBinder.bindForeignKey;
|
|||
import static org.hibernate.boot.model.naming.Identifier.toIdentifier;
|
||||
import static org.hibernate.engine.OptimisticLockStyle.fromLockType;
|
||||
import static org.hibernate.engine.spi.ExecuteUpdateResultCheckStyle.fromResultCheckStyle;
|
||||
import static org.hibernate.internal.CoreLogging.messageLogger;
|
||||
import static org.hibernate.internal.util.ReflectHelper.getDefaultSupplier;
|
||||
import static org.hibernate.internal.util.StringHelper.isBlank;
|
||||
import static org.hibernate.internal.util.StringHelper.isEmpty;
|
||||
|
@ -170,7 +169,7 @@ import static org.hibernate.internal.util.collections.CollectionHelper.isNotEmpt
|
|||
*/
|
||||
public class EntityBinder {
|
||||
|
||||
private static final CoreMessageLogger LOG = Logger.getMessageLogger( MethodHandles.lookup(), CoreMessageLogger.class, EntityBinder.class.getName() );
|
||||
private static final CoreMessageLogger LOG = messageLogger( EntityBinder.class );
|
||||
private static final String NATURAL_ID_CACHE_SUFFIX = "##NaturalId";
|
||||
|
||||
private final MetadataBuildingContext context;
|
||||
|
@ -217,7 +216,7 @@ public class EntityBinder {
|
|||
Map<ClassDetails, InheritanceState> inheritanceStates,
|
||||
MetadataBuildingContext context) {
|
||||
if ( LOG.isDebugEnabled() ) {
|
||||
LOG.debugf( "Binding entity from annotated class: %s", clazzToProcess.getName() );
|
||||
LOG.debug( "Binding entity from annotated class: " + clazzToProcess.getName() );
|
||||
}
|
||||
|
||||
final InFlightMetadataCollector collector = context.getMetadataCollector();
|
||||
|
@ -962,10 +961,8 @@ public class EntityBinder {
|
|||
discriminatorColumn.linkWithValue( discriminatorColumnBinding );
|
||||
discriminatorColumnBinding.setTypeName( discriminatorColumn.getDiscriminatorTypeName() );
|
||||
rootClass.setPolymorphic( true );
|
||||
final String rootEntityName = rootClass.getEntityName();
|
||||
LOG.tracev( "Setting discriminator for entity {0}", rootEntityName);
|
||||
getMetadataCollector()
|
||||
.addSecondPass( new DiscriminatorColumnSecondPass( rootEntityName,
|
||||
.addSecondPass( new DiscriminatorColumnSecondPass( rootClass.getEntityName(),
|
||||
context.getMetadataCollector().getDatabase().getDialect() ) );
|
||||
}
|
||||
}
|
||||
|
@ -1045,14 +1042,20 @@ public class EntityBinder {
|
|||
if ( discriminatorColumn != null ) {
|
||||
final boolean ignore = context.getBuildingOptions().ignoreExplicitDiscriminatorsForJoinedInheritance();
|
||||
if ( ignore ) {
|
||||
LOG.debugf( "Ignoring explicit @DiscriminatorColumn annotation on: %s", annotatedClass.getName() );
|
||||
if ( LOG.isDebugEnabled() ) {
|
||||
LOG.debug( "Ignoring explicit @DiscriminatorColumn annotation on: "
|
||||
+ annotatedClass.getName() );
|
||||
}
|
||||
}
|
||||
return !ignore;
|
||||
}
|
||||
else {
|
||||
final boolean createImplicit = context.getBuildingOptions().createImplicitDiscriminatorsForJoinedInheritance();
|
||||
if ( createImplicit ) {
|
||||
LOG.debugf( "Inferring implicit @DiscriminatorColumn using defaults for: %s", annotatedClass.getName() );
|
||||
if ( LOG.isDebugEnabled() ) {
|
||||
LOG.debug( "Inferring implicit @DiscriminatorColumn using defaults for: "
|
||||
+ annotatedClass.getName() );
|
||||
}
|
||||
}
|
||||
return createImplicit;
|
||||
}
|
||||
|
@ -1073,8 +1076,7 @@ public class EntityBinder {
|
|||
if ( !idPropertiesIfIdClass.contains( propertyName ) ) {
|
||||
final MemberDetails property = propertyAnnotatedElement.getAttributeMember();
|
||||
boolean hasIdAnnotation = hasIdAnnotation( property );
|
||||
if ( !idPropertiesIfIdClass.isEmpty() && !isIgnoreIdAnnotations()
|
||||
&& hasIdAnnotation ) {
|
||||
if ( !idPropertiesIfIdClass.isEmpty() && !isIgnoreIdAnnotations() && hasIdAnnotation ) {
|
||||
missingEntityProperties.add( propertyName );
|
||||
}
|
||||
else {
|
||||
|
@ -1082,10 +1084,8 @@ public class EntityBinder {
|
|||
inheritanceState.getType() == SINGLE_TABLE
|
||||
&& inheritanceState.hasParents();
|
||||
if ( !hasIdAnnotation && property.hasAnnotationUsage( GeneratedValue.class, getSourceModelContext() ) ) {
|
||||
throw new AnnotationException(
|
||||
"Property '"
|
||||
+ BinderHelper.getPath( propertyHolder, propertyAnnotatedElement )
|
||||
+ "' is annotated @GeneratedValue but is not part of an identifier" );
|
||||
throw new AnnotationException( "Property '" + getPath( propertyHolder, propertyAnnotatedElement )
|
||||
+ "' is annotated '@GeneratedValue' but is not part of an identifier" );
|
||||
}
|
||||
processElementAnnotations(
|
||||
propertyHolder,
|
||||
|
@ -1194,7 +1194,6 @@ public class EntityBinder {
|
|||
context
|
||||
);
|
||||
}
|
||||
LOG.trace( "Subclass joined column(s) created" );
|
||||
return joinColumns;
|
||||
}
|
||||
|
||||
|
@ -1389,7 +1388,6 @@ public class EntityBinder {
|
|||
}
|
||||
|
||||
private void registerImportName() {
|
||||
LOG.debugf( "Import with entity name %s", name );
|
||||
try {
|
||||
final InFlightMetadataCollector metadataCollector = getMetadataCollector();
|
||||
metadataCollector.addImport( name, persistentClass.getEntityName() );
|
||||
|
@ -1883,7 +1881,6 @@ public class EntityBinder {
|
|||
getMetadataCollector().addEntityTableXref( entityName, logicalName, table, denormalizedSuperTableXref );
|
||||
|
||||
if ( persistentClass instanceof TableOwner tableOwner ) {
|
||||
LOG.debugf( "Bind entity %s on table %s", entityName, table.getName() );
|
||||
tableOwner.setTable( table );
|
||||
}
|
||||
else {
|
||||
|
@ -2163,8 +2160,6 @@ public class EntityBinder {
|
|||
|
||||
// Somehow keep joins() for later.
|
||||
// Has to do the work later because it needs PersistentClass id!
|
||||
LOG.debugf( "Adding secondary table to entity %s -> %s",
|
||||
entityName, join.getTable().getName() );
|
||||
|
||||
handleSecondaryRowManagement( join );
|
||||
processSecondaryTableCustomSql( join );
|
||||
|
|
|
@ -96,7 +96,9 @@ public class FilterDefBinder {
|
|||
parameterResolvers
|
||||
);
|
||||
|
||||
LOG.debugf( "Binding filter definition: %s", filterDefinition.getFilterName() );
|
||||
if ( LOG.isDebugEnabled() ) {
|
||||
LOG.debug( "Binding filter definition: " + filterDefinition.getFilterName() );
|
||||
}
|
||||
context.getMetadataCollector().addFilterDefinition( filterDefinition );
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,6 @@ import org.hibernate.id.IdentityGenerator;
|
|||
import org.hibernate.id.PersistentIdentifierGenerator;
|
||||
import org.hibernate.id.enhanced.SequenceStyleGenerator;
|
||||
import org.hibernate.id.uuid.UuidValueGenerator;
|
||||
import org.hibernate.internal.CoreLogging;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.mapping.GeneratorCreator;
|
||||
import org.hibernate.mapping.KeyValue;
|
||||
|
@ -70,6 +69,7 @@ import static org.hibernate.boot.model.internal.GeneratorParameters.interpretSeq
|
|||
import static org.hibernate.boot.model.internal.GeneratorParameters.interpretTableGenerator;
|
||||
import static org.hibernate.boot.model.internal.GeneratorStrategies.generatorClass;
|
||||
import static org.hibernate.id.IdentifierGenerator.GENERATOR_NAME;
|
||||
import static org.hibernate.internal.CoreLogging.messageLogger;
|
||||
import static org.hibernate.internal.util.NullnessUtil.castNonNull;
|
||||
import static org.hibernate.internal.util.StringHelper.isNotEmpty;
|
||||
import static org.hibernate.internal.util.StringHelper.qualify;
|
||||
|
@ -82,7 +82,7 @@ import static org.hibernate.internal.util.collections.CollectionHelper.combineUn
|
|||
*/
|
||||
public class GeneratorBinder {
|
||||
|
||||
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( GeneratorBinder.class );
|
||||
private static final CoreMessageLogger LOG = messageLogger( GeneratorBinder.class );
|
||||
|
||||
public static final String ASSIGNED_GENERATOR_NAME = "assigned";
|
||||
public static final GeneratorCreator ASSIGNED_IDENTIFIER_GENERATOR_CREATOR =
|
||||
|
@ -243,8 +243,6 @@ public class GeneratorBinder {
|
|||
return globalDefinition;
|
||||
}
|
||||
else {
|
||||
LOG.debugf( "Could not resolve explicit IdentifierGeneratorDefinition - using implicit interpretation (%s)",
|
||||
name );
|
||||
final GeneratedValue generatedValue = idAttributeMember.getDirectAnnotationUsage( GeneratedValue.class );
|
||||
if ( generatedValue == null ) {
|
||||
throw new AssertionFailure( "No @GeneratedValue annotation" );
|
||||
|
@ -315,7 +313,6 @@ public class GeneratorBinder {
|
|||
LOG.tracev( "Added generator with name: {0}, strategy: {0}",
|
||||
definitionBuilder.getName(), definitionBuilder.getStrategy() );
|
||||
}
|
||||
|
||||
return definitionBuilder.build();
|
||||
}
|
||||
|
||||
|
@ -323,7 +320,7 @@ public class GeneratorBinder {
|
|||
final IdentifierGeneratorDefinition.Builder definitionBuilder = new IdentifierGeneratorDefinition.Builder();
|
||||
interpretSequenceGenerator( generatorAnnotation, definitionBuilder );
|
||||
if ( LOG.isTraceEnabled() ) {
|
||||
LOG.tracev( "Add sequence generator with name: {0}", definitionBuilder.getName() );
|
||||
LOG.tracev( "Added sequence generator with name: {0}", definitionBuilder.getName() );
|
||||
}
|
||||
return definitionBuilder.build();
|
||||
}
|
||||
|
@ -332,7 +329,7 @@ public class GeneratorBinder {
|
|||
final IdentifierGeneratorDefinition.Builder definitionBuilder = new IdentifierGeneratorDefinition.Builder();
|
||||
interpretTableGenerator( generatorAnnotation, definitionBuilder );
|
||||
if ( LOG.isTraceEnabled() ) {
|
||||
LOG.tracev( "Add sequence generator with name: {0}", definitionBuilder.getName() );
|
||||
LOG.tracev( "Added sequence generator with name: {0}", definitionBuilder.getName() );
|
||||
}
|
||||
return definitionBuilder.build();
|
||||
}
|
||||
|
|
|
@ -104,13 +104,13 @@ public class IdBagBinder extends BagBinder {
|
|||
|
||||
switch (namedGenerator) {
|
||||
case "identity": {
|
||||
throw new MappingException("IDENTITY generation not supported for CollectionId");
|
||||
throw new MappingException("IDENTITY generation not supported for @CollectionId");
|
||||
}
|
||||
case "assigned": {
|
||||
throw new MappingException("Assigned generation not supported for CollectionId");
|
||||
throw new MappingException("Assigned generation not supported for @CollectionId");
|
||||
}
|
||||
case "native": {
|
||||
throw new MappingException("Native generation not supported for CollectionId");
|
||||
throw new MappingException("Native generation not supported for @CollectionId");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
package org.hibernate.boot.model.internal;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
@ -43,7 +42,6 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
|||
import org.hibernate.generator.BeforeExecutionGenerator;
|
||||
import org.hibernate.generator.EventType;
|
||||
import org.hibernate.generator.EventTypeSets;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.mapping.Component;
|
||||
import org.hibernate.mapping.Join;
|
||||
import org.hibernate.mapping.KeyValue;
|
||||
|
@ -65,7 +63,6 @@ import org.hibernate.models.spi.TypeDetails;
|
|||
import org.hibernate.models.spi.TypeVariableScope;
|
||||
import org.hibernate.usertype.CompositeUserType;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import jakarta.persistence.Basic;
|
||||
import jakarta.persistence.Column;
|
||||
|
@ -110,7 +107,6 @@ import static org.hibernate.internal.util.collections.CollectionHelper.isEmpty;
|
|||
* @author Emmanuel Bernard
|
||||
*/
|
||||
public class PropertyBinder {
|
||||
private static final CoreMessageLogger LOG = Logger.getMessageLogger( MethodHandles.lookup(), CoreMessageLogger.class, PropertyBinder.class.getName() );
|
||||
|
||||
private MetadataBuildingContext buildingContext;
|
||||
|
||||
|
@ -198,7 +194,7 @@ public class PropertyBinder {
|
|||
this.value = value;
|
||||
}
|
||||
|
||||
public void setComponentElement(Component componentElement) {
|
||||
private void setComponentElement(Component componentElement) {
|
||||
this.componentElement = componentElement;
|
||||
}
|
||||
|
||||
|
@ -260,7 +256,6 @@ public class PropertyBinder {
|
|||
private Property makePropertyAndValue() {
|
||||
validateBind();
|
||||
|
||||
LOG.debugf( "MetadataSourceProcessor property %s with lazy=%s", name, lazy );
|
||||
final String containerClassName = holder.getClassName();
|
||||
holder.startingProperty( memberDetails );
|
||||
|
||||
|
@ -306,8 +301,8 @@ public class PropertyBinder {
|
|||
}
|
||||
catch ( Exception e ) {
|
||||
throw new AnnotationException( "error processing @AttributeBinderType annotation '"
|
||||
+ metaAnnotatedDescriptor.getAnnotationType().getName() + "' for property "
|
||||
+ qualify( holder.getPath(), name ), e );
|
||||
+ metaAnnotatedDescriptor.getAnnotationType().getName() + "' for property '"
|
||||
+ qualify( holder.getPath(), name ) + "'", e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -334,9 +329,7 @@ public class PropertyBinder {
|
|||
else {
|
||||
holder.addProperty( property, memberDetails, columns, declaringClass );
|
||||
}
|
||||
|
||||
callAttributeBindersInSecondPass( property );
|
||||
|
||||
return property;
|
||||
}
|
||||
|
||||
|
@ -365,10 +358,10 @@ public class PropertyBinder {
|
|||
rootClass.setEmbeddedIdentifier( true );
|
||||
}
|
||||
else {
|
||||
rootClass.setIdentifierProperty(property);
|
||||
rootClass.setIdentifierProperty( property );
|
||||
final MappedSuperclass superclass =
|
||||
getMappedSuperclassOrNull( declaringClass, inheritanceStatePerClass, buildingContext );
|
||||
setDeclaredIdentifier( rootClass, superclass, property);
|
||||
setDeclaredIdentifier( rootClass, superclass, property );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -428,7 +421,6 @@ public class PropertyBinder {
|
|||
public Property makeProperty() {
|
||||
validateMake();
|
||||
validateAnnotationsAgainstType();
|
||||
LOG.debugf( "Building property %s", name );
|
||||
Property property = new Property();
|
||||
property.setName( name );
|
||||
property.setValue( value );
|
||||
|
@ -444,7 +436,6 @@ public class PropertyBinder {
|
|||
handleMutability( property );
|
||||
handleOptional( property );
|
||||
inferOptimisticLocking( property );
|
||||
LOG.tracev( "Cascading {0} with {1}", name, cascade );
|
||||
return property;
|
||||
}
|
||||
|
||||
|
@ -535,11 +526,12 @@ public class PropertyBinder {
|
|||
|
||||
private void validateAnnotationsAgainstType() {
|
||||
if ( memberDetails != null ) {
|
||||
if ( !(memberDetails.getType() instanceof ArrayTypeDetails) ) {
|
||||
final TypeDetails type = memberDetails.getType();
|
||||
if ( !(type instanceof ArrayTypeDetails) ) {
|
||||
checkAnnotation( OrderColumn.class, List.class );
|
||||
if ( memberDetails.hasDirectAnnotationUsage( OrderBy.class )
|
||||
&& !memberDetails.getType().isImplementor( Collection.class )
|
||||
&& !memberDetails.getType().isImplementor( Map.class ) ) {
|
||||
&& !type.isImplementor( Collection.class )
|
||||
&& !type.isImplementor( Map.class ) ) {
|
||||
throw new AnnotationException( "Property '" + qualify( holder.getPath(), name )
|
||||
+ "' is annotated '@OrderBy' but is not of type 'Collection' or 'Map'" );
|
||||
}
|
||||
|
@ -654,13 +646,9 @@ public class PropertyBinder {
|
|||
final Id existingIdProperty = attributeMember.getDirectAnnotationUsage( Id.class );
|
||||
if ( incomingIdProperty != null && existingIdProperty == null ) {
|
||||
throw new MappingException(
|
||||
String.format(
|
||||
"You cannot override the [%s] non-identifier property from the [%s] base class or @MappedSuperclass and make it an identifier in the [%s] subclass",
|
||||
attributeMember.getName(),
|
||||
attributeMember.getDeclaringType().getName(),
|
||||
property.getDeclaringType().getName()
|
||||
)
|
||||
);
|
||||
"Attribute '" + attributeMember.getName()
|
||||
+ "' is declared by '" + attributeMember.getDeclaringType().getName()
|
||||
+ "' and may not be redeclared as an '@Id' by '" + property.getDeclaringType().getName() + "'" );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -703,13 +691,10 @@ public class PropertyBinder {
|
|||
}
|
||||
|
||||
private static boolean isJoinColumnPresent(String columnName, MemberDetails property, SourceModelBuildingContext modelContext) {
|
||||
//The detection of a configured individual JoinColumn differs between Annotation
|
||||
//and XML configuration processing.
|
||||
final JoinColumn[] joinColumnAnnotations = property.getRepeatedAnnotationUsages(
|
||||
JpaAnnotations.JOIN_COLUMN,
|
||||
modelContext
|
||||
);
|
||||
for ( JoinColumn joinColumnAnnotation : joinColumnAnnotations ) {
|
||||
// The detection of a configured individual JoinColumn differs
|
||||
// between Annotation and XML configuration processing.
|
||||
for ( JoinColumn joinColumnAnnotation :
|
||||
property.getRepeatedAnnotationUsages( JpaAnnotations.JOIN_COLUMN, modelContext ) ) {
|
||||
if ( joinColumnAnnotation.name().equals( columnName ) ) {
|
||||
return true;
|
||||
}
|
||||
|
@ -736,26 +721,10 @@ public class PropertyBinder {
|
|||
MetadataBuildingContext context,
|
||||
Map<ClassDetails, InheritanceState> inheritanceStatePerClass) throws MappingException {
|
||||
|
||||
if ( alreadyProcessedBySuper( propertyHolder, inferredData, entityBinder ) ) {
|
||||
LOG.debugf(
|
||||
"Skipping attribute [%s : %s] as it was already processed as part of super hierarchy",
|
||||
inferredData.getClassOrElementName(),
|
||||
inferredData.getPropertyName()
|
||||
);
|
||||
}
|
||||
else {
|
||||
if ( !alreadyProcessedBySuper( propertyHolder, inferredData, entityBinder ) ) {
|
||||
// inSecondPass can only be used to apply right away the second pass of a composite-element
|
||||
// Because it's a value type, there is no bidirectional association, hence second pass
|
||||
// ordering does not matter
|
||||
|
||||
if ( LOG.isTraceEnabled() ) {
|
||||
LOG.tracev(
|
||||
"Processing annotations of {0}.{1}" ,
|
||||
propertyHolder.getEntityName(),
|
||||
inferredData.getPropertyName()
|
||||
);
|
||||
}
|
||||
|
||||
final MemberDetails property = inferredData.getAttributeMember();
|
||||
if ( property.hasDirectAnnotationUsage( Parent.class ) ) {
|
||||
handleParentProperty( propertyHolder, inferredData, property );
|
||||
|
@ -994,9 +963,6 @@ public class PropertyBinder {
|
|||
AnnotatedColumns columns,
|
||||
PropertyBinder propertyBinder) {
|
||||
checkVersionProperty( propertyHolder, isIdentifierMapper );
|
||||
if ( LOG.isTraceEnabled() ) {
|
||||
LOG.tracev( "{0} is a version property", inferredData.getPropertyName() );
|
||||
}
|
||||
final RootClass rootClass = (RootClass) propertyHolder.getPersistentClass();
|
||||
propertyBinder.setColumns( columns );
|
||||
final Property property = propertyBinder.makePropertyValueAndBind();
|
||||
|
@ -1019,12 +985,6 @@ public class PropertyBinder {
|
|||
}
|
||||
|
||||
rootClass.setOptimisticLockStyle( OptimisticLockStyle.VERSION );
|
||||
if ( LOG.isTraceEnabled() ) {
|
||||
final SimpleValue versionValue = (SimpleValue) rootClass.getVersion().getValue();
|
||||
LOG.tracev( "Version name: {0}, unsavedValue: {1}",
|
||||
rootClass.getVersion().getName(),
|
||||
versionValue.getNullValue() );
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkVersionProperty(PropertyHolder propertyHolder, boolean isIdentifierMapper) {
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
*/
|
||||
package org.hibernate.boot.model.internal;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
|
@ -42,8 +41,6 @@ import org.hibernate.query.sql.internal.ParameterParser;
|
|||
import org.hibernate.query.sql.spi.ParameterRecognizer;
|
||||
import org.hibernate.type.BasicType;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import jakarta.persistence.CacheRetrieveMode;
|
||||
import jakarta.persistence.CacheStoreMode;
|
||||
import jakarta.persistence.NamedNativeQuery;
|
||||
|
@ -55,6 +52,7 @@ import jakarta.persistence.SqlResultSetMapping;
|
|||
import jakarta.persistence.StoredProcedureParameter;
|
||||
|
||||
import static java.lang.Boolean.TRUE;
|
||||
import static org.hibernate.internal.CoreLogging.messageLogger;
|
||||
import static org.hibernate.internal.util.StringHelper.nullIfEmpty;
|
||||
import static org.hibernate.internal.util.collections.ArrayHelper.isEmpty;
|
||||
import static org.hibernate.internal.util.collections.CollectionHelper.determineProperSizing;
|
||||
|
@ -70,7 +68,7 @@ import static org.hibernate.models.internal.util.StringHelper.isEmpty;
|
|||
* @author Emmanuel Bernard
|
||||
*/
|
||||
public abstract class QueryBinder {
|
||||
private static final CoreMessageLogger LOG = Logger.getMessageLogger( MethodHandles.lookup(), CoreMessageLogger.class, QueryBinder.class.getName() );
|
||||
private static final CoreMessageLogger LOG = messageLogger( QueryBinder.class );
|
||||
|
||||
public static void bindQuery(
|
||||
NamedQuery namedQuery,
|
||||
|
@ -464,7 +462,7 @@ public abstract class QueryBinder {
|
|||
else {
|
||||
context.getMetadataCollector().addNamedProcedureCallDefinition( definition );
|
||||
}
|
||||
LOG.debugf( "Bound named stored procedure query : %s => %s",
|
||||
LOG.debugf( "Bound named stored procedure query: %s => %s",
|
||||
definition.getRegistrationName(), definition.getProcedureName() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
*/
|
||||
package org.hibernate.boot.model.internal;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.AnnotationException;
|
||||
|
@ -20,7 +19,6 @@ import org.hibernate.boot.model.source.spi.AttributePath;
|
|||
import org.hibernate.boot.spi.InFlightMetadataCollector;
|
||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.mapping.Any;
|
||||
import org.hibernate.mapping.CheckConstraint;
|
||||
import org.hibernate.mapping.Collection;
|
||||
|
@ -38,8 +36,6 @@ import org.hibernate.mapping.Table;
|
|||
import org.hibernate.mapping.ToOne;
|
||||
import org.hibernate.mapping.Value;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import jakarta.persistence.Index;
|
||||
import jakarta.persistence.UniqueConstraint;
|
||||
|
||||
|
@ -56,7 +52,6 @@ import static org.hibernate.internal.util.collections.CollectionHelper.isNotEmpt
|
|||
* @author Emmanuel Bernard
|
||||
*/
|
||||
public class TableBinder {
|
||||
private static final CoreMessageLogger LOG = Logger.getMessageLogger( MethodHandles.lookup(), CoreMessageLogger.class, TableBinder.class.getName() );
|
||||
|
||||
private MetadataBuildingContext buildingContext;
|
||||
|
||||
|
@ -809,7 +804,6 @@ public class TableBinder {
|
|||
}
|
||||
|
||||
private static List<Column> mappedByColumns(PersistentClass associatedClass, String mappedByProperty) {
|
||||
LOG.debugf( "Retrieving property %s.%s", associatedClass.getEntityName(), mappedByProperty );
|
||||
final Value value = associatedClass.getRecursiveProperty( mappedByProperty ).getValue();
|
||||
if ( value instanceof Collection ) {
|
||||
final Value element = ((Collection) value).getElement();
|
||||
|
|
|
@ -121,25 +121,27 @@ public class XMLContext implements Serializable {
|
|||
|
||||
private void addClass(List<? extends JaxbManagedType> managedTypes, String packageName, Default defaults, List<String> addedClasses) {
|
||||
for ( JaxbManagedType element : managedTypes) {
|
||||
String className = buildSafeClassName( element.getClazz(), packageName );
|
||||
final String className = buildSafeClassName( element.getClazz(), packageName );
|
||||
if ( managedTypeOverride.containsKey( className ) ) {
|
||||
//maybe switch it to warn?
|
||||
throw new IllegalStateException( "Duplicate XML entry for " + className );
|
||||
}
|
||||
addedClasses.add( className );
|
||||
managedTypeOverride.put( className, element );
|
||||
Default mergedDefaults = new Default();
|
||||
final Default mergedDefaults = new Default();
|
||||
// Apply entity mapping defaults
|
||||
mergedDefaults.overrideWithCatalogAndSchema( defaults );
|
||||
// ... then apply entity settings
|
||||
Default fileDefaults = new Default();
|
||||
final Default fileDefaults = new Default();
|
||||
fileDefaults.setMetadataComplete( element.isMetadataComplete() );
|
||||
fileDefaults.setAccess( element.getAccess() );
|
||||
mergedDefaults.overrideWithCatalogAndSchema( fileDefaults );
|
||||
// ... and we get the merged defaults for that entity
|
||||
defaultsOverride.put( className, mergedDefaults );
|
||||
|
||||
LOG.debugf( "Adding XML overriding information for %s", className );
|
||||
if ( LOG.isDebugEnabled() ) {
|
||||
LOG.debug( "Adding XML overriding information for class: " + className );
|
||||
}
|
||||
if ( element instanceof JaxbEntityImpl ) {
|
||||
addEntityListenerClasses( ( (JaxbEntityImpl) element ).getEntityListenerContainer(), packageName, addedClasses );
|
||||
}
|
||||
|
@ -150,20 +152,23 @@ public class XMLContext implements Serializable {
|
|||
}
|
||||
|
||||
private List<String> addEntityListenerClasses(JaxbEntityListenerContainerImpl listeners, String packageName, List<String> addedClasses) {
|
||||
List<String> localAddedClasses = new ArrayList<>();
|
||||
final List<String> localAddedClasses = new ArrayList<>();
|
||||
if ( listeners != null ) {
|
||||
List<JaxbEntityListenerImpl> elements = listeners.getEntityListeners();
|
||||
final List<JaxbEntityListenerImpl> elements = listeners.getEntityListeners();
|
||||
for ( JaxbEntityListenerImpl listener : elements ) {
|
||||
String listenerClassName = buildSafeClassName( listener.getClazz(), packageName );
|
||||
final String listenerClassName = buildSafeClassName( listener.getClazz(), packageName );
|
||||
if ( entityListenerOverride.containsKey( listenerClassName ) ) {
|
||||
LOG.duplicateListener( listenerClassName );
|
||||
continue;
|
||||
}
|
||||
localAddedClasses.add( listenerClassName );
|
||||
entityListenerOverride.put( listenerClassName, listener );
|
||||
else {
|
||||
localAddedClasses.add( listenerClassName );
|
||||
entityListenerOverride.put( listenerClassName, listener );
|
||||
}
|
||||
}
|
||||
}
|
||||
LOG.debugf( "Adding XML overriding information for listeners: %s", localAddedClasses );
|
||||
if ( LOG.isDebugEnabled() ) {
|
||||
LOG.debug( "Adding XML overriding information for entity listener classes: " + localAddedClasses );
|
||||
}
|
||||
addedClasses.addAll( localAddedClasses );
|
||||
return localAddedClasses;
|
||||
}
|
||||
|
|
|
@ -555,7 +555,7 @@ public interface CoreMessageLogger extends BasicLogger {
|
|||
@LogMessage(level = WARN)
|
||||
@Message(
|
||||
id = 449,
|
||||
value = "@Convert annotation applied to Map attribute [%s] did not explicitly specify attributeName " +
|
||||
value = "@Convert annotation applied to Map attribute [%s] did not explicitly specify 'attributeName' " +
|
||||
"using 'key'/'value' as required by spec; attempting to DoTheRightThing"
|
||||
)
|
||||
void nonCompliantMapConversion(String collectionRole);
|
||||
|
|
|
@ -13,7 +13,6 @@ import org.hibernate.testing.orm.junit.JiraKey;
|
|||
import org.hibernate.testing.util.ServiceRegistryUtil;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
|
||||
|
@ -36,10 +35,7 @@ public class MappedSuperClassIdPropertyBasicAttributeOverrideTest {
|
|||
fail( "Should throw exception!" );
|
||||
}
|
||||
catch (MappingException expected) {
|
||||
assertEquals(
|
||||
"You cannot override the [uid] non-identifier property from the [org.hibernate.orm.test.annotations.override.mappedsuperclass.MappedSuperClassWithUuidAsBasic] base class or @MappedSuperclass and make it an identifier in the [org.hibernate.orm.test.annotations.override.mappedsuperclass.SubclassWithUuidAsId] subclass",
|
||||
expected.getMessage()
|
||||
);
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -299,8 +299,10 @@ public class MapKeyAttributeConverterTest extends BaseNonConfigCoreFunctionalTes
|
|||
|
||||
private ImplicitEnumMapKey enumImplicit;
|
||||
@Enumerated
|
||||
@Convert(disableConversion = true)
|
||||
private ImplicitEnumMapKey enumImplicitOverrideOrdinal;
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Convert(disableConversion = true)
|
||||
private ImplicitEnumMapKey enumImplicitOverrideString;
|
||||
|
||||
@Convert(converter = ImplicitEnumMapKeyOverridedConverter.class)
|
||||
|
|
|
@ -124,7 +124,6 @@ public class UUIDTypeConverterTest {
|
|||
public static class Id {
|
||||
@Column(unique = true, length = 16, nullable = false)
|
||||
@jakarta.persistence.Id
|
||||
@Convert(converter = UuidBase64TypeConverter.class)
|
||||
private UUID id = safeRandomUUID();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue