Skip to content

Commit 5a69197

Browse files
committed
HHH-19324 - Switch tests using hbm.xml to use mapping.xml
1 parent 70c8764 commit 5a69197

File tree

14 files changed

+428
-127
lines changed

14 files changed

+428
-127
lines changed

hibernate-core/src/main/java/org/hibernate/boot/jaxb/mapping/spi/JaxbBasicMapping.java

+6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
* @author Steve Ebersole
1212
*/
1313
public interface JaxbBasicMapping {
14+
/**
15+
* The attribute's name
16+
*/
17+
String getName();
18+
void setName(String name);
19+
1420
JaxbUserTypeImpl getType();
1521

1622
void setType(JaxbUserTypeImpl value);

hibernate-core/src/main/java/org/hibernate/boot/jaxb/mapping/spi/JaxbEmbeddable.java

+5
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@
44
*/
55
package org.hibernate.boot.jaxb.mapping.spi;
66

7+
import org.checkerframework.checker.nullness.qual.Nullable;
8+
79
/**
810
* @author Steve Ebersole
911
*/
1012
public interface JaxbEmbeddable extends JaxbManagedType {
13+
@Nullable
14+
String getName();
15+
void setName(@Nullable String name);
1116
}

hibernate-core/src/main/java/org/hibernate/boot/model/internal/IdGeneratorResolverSecondPass.java

+16
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.hibernate.boot.model.IdentifierGeneratorDefinition;
1313
import org.hibernate.boot.models.HibernateAnnotations;
1414
import org.hibernate.boot.models.JpaAnnotations;
15+
import org.hibernate.boot.models.annotations.internal.GenericGeneratorAnnotation;
1516
import org.hibernate.boot.models.spi.GenericGeneratorRegistration;
1617
import org.hibernate.boot.models.spi.GlobalRegistrations;
1718
import org.hibernate.boot.models.spi.SequenceGeneratorRegistration;
@@ -351,6 +352,21 @@ protected void handleNamedAutoGenerator() {
351352
}
352353

353354
private boolean handleAsLocalAutoGenerator() {
355+
if ( "increment".equals( generatedValue.generator() ) ) {
356+
final GenericGeneratorAnnotation incrementGenerator = new GenericGeneratorAnnotation( buildingContext.getBootstrapContext().getModelsContext() );
357+
incrementGenerator.name( "increment" );
358+
incrementGenerator.strategy( "increment" );
359+
360+
GeneratorAnnotationHelper.handleGenericGenerator(
361+
generatedValue.generator(),
362+
incrementGenerator,
363+
entityMapping,
364+
idValue,
365+
buildingContext
366+
);
367+
return true;
368+
}
369+
354370
final String generator = generatedValue.generator();
355371
assert !generator.isEmpty();
356372

hibernate-core/src/main/java/org/hibernate/boot/model/process/spi/MetadataBuildingProcess.java

+16-12
Original file line numberDiff line numberDiff line change
@@ -432,18 +432,22 @@ public static DomainModelSource processManagedResources(
432432
);
433433

434434
final HashSet<String> categorizedClassNames = new HashSet<>();
435-
allKnownClassNames.forEach( (className) -> applyKnownClass(
436-
className,
437-
categorizedClassNames,
438-
classDetailsRegistry,
439-
modelCategorizationCollector
440-
) );
441-
xmlPreProcessingResult.getMappedNames().forEach( (className) -> applyKnownClass(
442-
className,
443-
categorizedClassNames,
444-
classDetailsRegistry,
445-
modelCategorizationCollector
446-
) );
435+
// apply known classes
436+
allKnownClassNames.forEach( (className) -> {
437+
if ( categorizedClassNames.add( className ) ) {
438+
// not known yet
439+
final ClassDetails classDetails = classDetailsRegistry.resolveClassDetails( className );
440+
applyKnownClass( classDetails, categorizedClassNames, classDetailsRegistry, modelCategorizationCollector );
441+
}
442+
} );
443+
// apply known "names" - generally this handles dynamic models
444+
xmlPreProcessingResult.getMappedNames().forEach( (mappedName) -> {
445+
if ( categorizedClassNames.add( mappedName ) ) {
446+
// not known yet
447+
final ClassDetails classDetails = classDetailsRegistry.resolveClassDetails( mappedName );
448+
applyKnownClass( classDetails, categorizedClassNames, classDetailsRegistry, modelCategorizationCollector );
449+
}
450+
} );
447451

448452
xmlProcessingResult.apply();
449453

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
* Copyright Red Hat Inc. and Hibernate Authors
4+
*/
5+
package org.hibernate.boot.models.xml;
6+
7+
import org.hibernate.HibernateException;
8+
9+
/**
10+
* Indicates a problem resolving an attribute's type details - typically with dynamic models.
11+
*
12+
* @author Steve Ebersole
13+
*/
14+
public class UnknownAttributeTypeException extends HibernateException {
15+
public UnknownAttributeTypeException(String message) {
16+
super( message );
17+
}
18+
}

0 commit comments

Comments
 (0)