Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public interface BootLogging extends BasicLogger {
BootLogging BOOT_LOGGER = Logger.getMessageLogger( MethodHandles.lookup(), BootLogging.class, NAME );

@LogMessage(level = WARN)
@Message(id = 160101, value = "Duplicate generator name %s")
@Message(id = 160101, value = "Duplicate generator name: '%s'")
void duplicateGeneratorName(String name);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ public java.util.Collection<Table> collectTableMappings() {
@Override
public void addIdentifierGenerator(IdentifierGeneratorDefinition generator) {
if ( generator == null || generator.getName() == null ) {
throw new IllegalArgumentException( "ID generator object or name is null." );
throw new IllegalArgumentException( "Id generator object or name is null" );
}
else if ( !generator.getName().isEmpty()
&& !defaultIdentifierGeneratorNames.contains( generator.getName() ) ) {
Expand All @@ -678,7 +678,7 @@ else if ( !generator.getName().isEmpty()
+ "' to false " );
}
else {
BOOT_LOGGER.duplicateGeneratorName( old.getName() );
BOOT_LOGGER.duplicateGeneratorName( old.getName() );
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,16 @@
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.GeneratorBinder.registerGlobalGenerators;
import static org.hibernate.boot.model.internal.GeneratorParameters.interpretSequenceGenerator;
import static org.hibernate.boot.model.internal.GeneratorParameters.interpretTableGenerator;
import static org.hibernate.boot.model.internal.InheritanceState.getInheritanceStateOfSuperEntity;
import static org.hibernate.boot.model.internal.InheritanceState.getSuperclassInheritanceState;
import static org.hibernate.boot.BootLogging.BOOT_LOGGER;
import static org.hibernate.boot.model.internal.QueryBinder.bindNamedStoredProcedureQuery;
import static org.hibernate.boot.model.internal.QueryBinder.bindNativeQuery;
import static org.hibernate.boot.model.internal.QueryBinder.bindQuery;
import static org.hibernate.boot.model.internal.QueryBinder.bindSqlResultSetMapping;
import static org.hibernate.internal.util.StringHelper.unqualify;
import static org.hibernate.mapping.MetadataSource.ANNOTATIONS;

Expand Down Expand Up @@ -98,23 +103,23 @@ public static void bindDefaults(MetadataBuildingContext context) {
// result-set-mappings

globalRegistrations.getSqlResultSetMappingRegistrations().forEach( (name, mappingRegistration) -> {
QueryBinder.bindSqlResultSetMapping( mappingRegistration.configuration(), context, true );
bindSqlResultSetMapping( mappingRegistration.configuration(), context, true );
} );


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// queries

globalRegistrations.getNamedQueryRegistrations().forEach( (name, queryRegistration) -> {
QueryBinder.bindQuery( queryRegistration.configuration(), context, true, null );
bindQuery( queryRegistration.configuration(), context, true, null );
} );

globalRegistrations.getNamedNativeQueryRegistrations().forEach( (name, queryRegistration) -> {
QueryBinder.bindNativeQuery( queryRegistration.configuration(), context, null, true );
bindNativeQuery( queryRegistration.configuration(), context, null, true );
} );

globalRegistrations.getNamedStoredProcedureQueryRegistrations().forEach( (name, queryRegistration) -> {
QueryBinder.bindNamedStoredProcedureQuery( queryRegistration.configuration(), context, true );
bindNamedStoredProcedureQuery( queryRegistration.configuration(), context, true );
} );

}
Expand All @@ -130,7 +135,7 @@ public static void bindPackage(ClassLoaderService cls, String packageName, Metad
modelsContext( context ).getClassDetailsRegistry()
.resolveClassDetails( pack.getName() + ".package-info" );

GeneratorBinder.registerGlobalGenerators( packageInfo, context );
registerGlobalGenerators( packageInfo, context );

bindTypeDescriptorRegistrations( packageInfo, context );
bindEmbeddableInstantiatorRegistrations( packageInfo, context );
Expand All @@ -153,7 +158,7 @@ private static void bindNamedEntityGraphs(ClassDetails packageInfoClassDetails,
packageInfoClassDetails.forEachRepeatedAnnotationUsages(
HibernateAnnotations.NAMED_ENTITY_GRAPH,
modelsContext( context ),
(annotation) -> collector.addNamedEntityGraph( new NamedEntityGraphDefinition(
annotation -> collector.addNamedEntityGraph( new NamedEntityGraphDefinition(
annotation.name(), null,
NamedEntityGraphDefinition.Source.PARSED,
new NamedGraphCreatorParsed( annotation )
Expand All @@ -172,13 +177,13 @@ private static void bindNamedHibernateQueries(AnnotationTarget annotationTarget,
annotationTarget.forEachRepeatedAnnotationUsages(
HibernateAnnotations.NAMED_QUERY,
sourceModelContext,
(usage) -> QueryBinder.bindQuery( usage, context, annotationTarget )
(usage) -> bindQuery( usage, context, annotationTarget )
);

annotationTarget.forEachRepeatedAnnotationUsages(
HibernateAnnotations.NAMED_NATIVE_QUERY,
sourceModelContext,
(usage) -> QueryBinder.bindNativeQuery( usage, context, annotationTarget )
(usage) -> bindNativeQuery( usage, context, annotationTarget )
);
}

Expand All @@ -188,25 +193,25 @@ private static void bindNamedJpaQueries(AnnotationTarget annotationTarget, Metad
annotationTarget.forEachRepeatedAnnotationUsages(
JpaAnnotations.SQL_RESULT_SET_MAPPING,
sourceModelContext,
(usage) -> QueryBinder.bindSqlResultSetMapping( usage, context,false )
(usage) -> bindSqlResultSetMapping( usage, context,false )
);

annotationTarget.forEachRepeatedAnnotationUsages(
JpaAnnotations.NAMED_QUERY,
sourceModelContext,
(usage) -> QueryBinder.bindQuery( usage, context, false, annotationTarget )
(usage) -> bindQuery( usage, context, false, annotationTarget )
);

annotationTarget.forEachRepeatedAnnotationUsages(
JpaAnnotations.NAMED_NATIVE_QUERY,
sourceModelContext,
(usage) -> QueryBinder.bindNativeQuery( usage, context, annotationTarget, false )
(usage) -> bindNativeQuery( usage, context, annotationTarget, false )
);

annotationTarget.forEachRepeatedAnnotationUsages(
JpaAnnotations.NAMED_STORED_PROCEDURE_QUERY,
sourceModelContext,
(usage) -> QueryBinder.bindNamedStoredProcedureQuery( usage, context, false )
(usage) -> bindNamedStoredProcedureQuery( usage, context, false )
);
}

Expand Down Expand Up @@ -292,7 +297,7 @@ private static void handleJdbcTypeRegistration(
MetadataBuildingContext context,
ManagedBeanRegistry managedBeanRegistry,
JdbcTypeRegistration annotation) {
final JdbcType jdbcType = getBean( context, managedBeanRegistry, annotation.value() );
final var jdbcType = getBean( context, managedBeanRegistry, annotation.value() );
context.getMetadataCollector()
.addJdbcTypeRegistration( jdbcTypeCode( annotation, jdbcType ), jdbcType );
}
Expand Down Expand Up @@ -417,9 +422,9 @@ private static void bindFetchProfile(FetchProfile fetchProfile, MetadataBuilding
final String name = fetchProfile.name();
if ( reuseOrCreateFetchProfile( context, name ) ) {
for ( var fetchOverride : fetchProfile.fetchOverrides() ) {
final FetchType type = fetchOverride.fetch();
final FetchMode mode = fetchOverride.mode();
if ( type == FetchType.LAZY && mode == FetchMode.JOIN ) {
final FetchType fetchType = fetchOverride.fetch();
final FetchMode fetchMode = fetchOverride.mode();
if ( fetchType == FetchType.LAZY && fetchMode == FetchMode.JOIN ) {
throw new AnnotationException(
"Fetch profile '" + name
+ "' has a '@FetchOverride' with 'fetch=LAZY' and 'mode=JOIN'"
Expand Down Expand Up @@ -461,25 +466,25 @@ public static Map<ClassDetails, InheritanceState> buildInheritanceStates(
MetadataBuildingContext buildingContext) {
final Map<ClassDetails, InheritanceState> inheritanceStatePerClass = new HashMap<>( orderedClasses.size() );
final var collector = buildingContext.getMetadataCollector();
for ( ClassDetails clazz : orderedClasses ) {
final var superclassState = getSuperclassInheritanceState( clazz, inheritanceStatePerClass );
final var state = new InheritanceState( clazz, inheritanceStatePerClass, buildingContext );
final var classType = collector.getClassType( clazz );
if ( classType == EMBEDDABLE && !clazz.hasDirectAnnotationUsage( Imported.class ) ) {
final String className = clazz.getName();
for ( var classDetails : orderedClasses ) {
final var superclassState = getSuperclassInheritanceState( classDetails, inheritanceStatePerClass );
final var state = new InheritanceState( classDetails, inheritanceStatePerClass, buildingContext );
final var classType = collector.getClassType( classDetails );
if ( classType == EMBEDDABLE && !classDetails.hasDirectAnnotationUsage( Imported.class ) ) {
final String className = classDetails.getName();
collector.addImport( unqualify( className ), className );
}
if ( superclassState != null ) {
//the classes are ordered thus preventing an NPE
superclassState.setHasSiblings( true );
final var superEntityState = getInheritanceStateOfSuperEntity( clazz, inheritanceStatePerClass );
final var superEntityState = getInheritanceStateOfSuperEntity( classDetails, inheritanceStatePerClass );
if ( superEntityState != null ) {
state.setHasParents( true );
if ( classType == EMBEDDABLE ) {
collector.registerEmbeddableSubclass( superEntityState.getClassDetails(), clazz );
collector.registerEmbeddableSubclass( superEntityState.getClassDetails(), classDetails );
}
}
logMixedInheritance( clazz, superclassState, state );
logMixedInheritance( classDetails, superclassState, state );
if ( superclassState.getType() != null ) {
state.setType( superclassState.getType() );
}
Expand All @@ -488,7 +493,7 @@ public static Map<ClassDetails, InheritanceState> buildInheritanceStates(
case ENTITY:
case MAPPED_SUPERCLASS:
case EMBEDDABLE:
inheritanceStatePerClass.put( clazz, state );
inheritanceStatePerClass.put( classDetails, state );
}
}
return inheritanceStatePerClass;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import org.hibernate.AssertionFailure;
import org.hibernate.LockMode;
import org.hibernate.metamodel.mapping.CollectionPart;
import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.mapping.PluralAttributeMapping;
import org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping;
Expand Down Expand Up @@ -110,41 +109,34 @@ private FetchBuilder resolve(
dynamicFetchBuilder.getColumnAliases().toArray( new String[0] )
);
}
else {
else if ( fetchBuilder instanceof CompleteFetchBuilderEntityValuedModelPart completeFetchBuilder ) {
resultBuilder.addIdColumnAliases(
((CompleteFetchBuilderEntityValuedModelPart) fetchBuilder).getColumnAliases()
.toArray( new String[0] )
completeFetchBuilder.getColumnAliases().toArray( new String[0] )
);
}
else {
throw new AssertionFailure( "Unexpected fetch builder type" );
}
fetchBuilderMap.put(
pluralAttributeMapping.getElementDescriptor(),
fetchBuilder
);
}
else if ( attrName.equals( "index" ) ) {
final CollectionPart indexDescriptor = pluralAttributeMapping.getIndexDescriptor();
final var indexDescriptor = pluralAttributeMapping.getIndexDescriptor();
resultBuilder.addFetchBuilder( indexDescriptor, fetchBuilder );
fetchBuilderMap.put(
indexDescriptor,
fetchBuilder
);
fetchBuilderMap.put( indexDescriptor, fetchBuilder );
}
else if ( attrName.startsWith( ELEMENT_PREFIX ) ) {
final Fetchable attributeMapping = (Fetchable) partMappingType.findByPath(
attrName.substring( ELEMENT_PREFIX_LENGTH ) );
final var attributeMapping =
(Fetchable) partMappingType.findByPath( attrName.substring( ELEMENT_PREFIX_LENGTH ) );
resultBuilder.addFetchBuilder( attributeMapping, fetchBuilder );
fetchBuilderMap.put(
attributeMapping,
fetchBuilder
);
fetchBuilderMap.put( attributeMapping, fetchBuilder );
}
else {
final Fetchable attributeMapping = (Fetchable) partMappingType.findByPath( attrName );
final var attributeMapping = (Fetchable) partMappingType.findByPath( attrName );
resultBuilder.addFetchBuilder( attributeMapping, fetchBuilder );
fetchBuilderMap.put(
attributeMapping,
fetchBuilder
);
fetchBuilderMap.put( attributeMapping, fetchBuilder );
}
}
);
Expand All @@ -170,15 +162,13 @@ private FetchBuilder resolve(
fetchMemento.resolve( this, querySpaceConsumer, context )
)
);
final DynamicResultBuilderEntityStandard resultBuilder;
resultBuilder = new DynamicResultBuilderEntityStandard(
toOneAttributeMapping.getEntityMappingType(),
tableAlias,
navigablePath
);
fetchBuilderMap.forEach( (fetchable, fetchBuilder) ->
resultBuilder.addFetchBuilder( fetchable, fetchBuilder )
);
final var resultBuilder =
new DynamicResultBuilderEntityStandard(
toOneAttributeMapping.getEntityMappingType(),
tableAlias,
navigablePath
);
fetchBuilderMap.forEach( resultBuilder::addFetchBuilder );
return new DynamicFetchBuilderLegacy(
tableAlias,
ownerTableAlias,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ public void validateNamedQueries(QueryEngine queryEngine) {

@Override
public Map<String, HibernateException> checkNamedQueries(QueryEngine queryEngine) {
Map<String,HibernateException> errors = new HashMap<>();
final Map<String,HibernateException> errors = new HashMap<>();

final var interpretationCache = queryEngine.getInterpretationCache();
final var hqlTranslator = queryEngine.getHqlTranslator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
*/
package org.hibernate.query.internal;

import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;

import org.hibernate.query.named.NamedResultSetMappingMemento;
import org.hibernate.query.named.ResultMemento;
import org.hibernate.query.results.ResultSetMapping;

import static java.util.Collections.unmodifiableList;

/**
* Standard {@link NamedResultSetMappingMemento} implementation
*
Expand All @@ -34,7 +35,7 @@ public String getName() {
}

public List<ResultMemento> getResultMementos() {
return Collections.unmodifiableList( resultMementos );
return unmodifiableList( resultMementos );
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static boolean isDefaultOrdering(
* @return The recognized NullPrecedence, or {@code null}
*/
public static Nulls parse(String name) {
for ( Nulls value : Nulls.values() ) {
for ( var value : Nulls.values() ) {
if ( value.name().equalsIgnoreCase( name ) ) {
return value;
}
Expand All @@ -64,7 +64,7 @@ public static Nulls parse(String name) {
* @return The recognized NullPrecedence, or {@code defaultValue}.
*/
public static Nulls parse(String name, Nulls defaultValue) {
final Nulls value = parse( name );
final var value = parse( name );
return value != null ? value : defaultValue;
}

Expand Down
Loading
Loading