|
29 | 29 | import org.hibernate.AnnotationException; |
30 | 30 | import org.hibernate.AssertionFailure; |
31 | 31 | import org.hibernate.MappingException; |
32 | | -import org.hibernate.annotations.*; |
| 32 | +import org.hibernate.annotations.Cache; |
| 33 | +import org.hibernate.annotations.CacheConcurrencyStrategy; |
| 34 | +import org.hibernate.annotations.CacheLayout; |
| 35 | +import org.hibernate.annotations.Check; |
| 36 | +import org.hibernate.annotations.Checks; |
| 37 | +import org.hibernate.annotations.ConcreteProxy; |
| 38 | +import org.hibernate.annotations.DiscriminatorFormula; |
| 39 | +import org.hibernate.annotations.DynamicInsert; |
| 40 | +import org.hibernate.annotations.DynamicUpdate; |
| 41 | +import org.hibernate.annotations.Filter; |
| 42 | +import org.hibernate.annotations.Filters; |
| 43 | +import org.hibernate.annotations.HQLSelect; |
| 44 | +import org.hibernate.annotations.Immutable; |
| 45 | +import org.hibernate.annotations.Mutability; |
| 46 | +import org.hibernate.annotations.NaturalIdCache; |
| 47 | +import org.hibernate.annotations.NaturalIdClass; |
| 48 | +import org.hibernate.annotations.OnDelete; |
| 49 | +import org.hibernate.annotations.OptimisticLockType; |
| 50 | +import org.hibernate.annotations.OptimisticLocking; |
| 51 | +import org.hibernate.annotations.QueryCacheLayout; |
| 52 | +import org.hibernate.annotations.RowId; |
| 53 | +import org.hibernate.annotations.SQLDelete; |
| 54 | +import org.hibernate.annotations.SQLDeleteAll; |
| 55 | +import org.hibernate.annotations.SQLInsert; |
| 56 | +import org.hibernate.annotations.SQLRestriction; |
| 57 | +import org.hibernate.annotations.SQLSelect; |
| 58 | +import org.hibernate.annotations.SQLUpdate; |
| 59 | +import org.hibernate.annotations.SecondaryRow; |
| 60 | +import org.hibernate.annotations.SecondaryRows; |
| 61 | +import org.hibernate.annotations.SoftDelete; |
| 62 | +import org.hibernate.annotations.Subselect; |
| 63 | +import org.hibernate.annotations.Synchronize; |
| 64 | +import org.hibernate.annotations.TypeBinderType; |
| 65 | +import org.hibernate.annotations.View; |
33 | 66 | import org.hibernate.binder.TypeBinder; |
34 | 67 | import org.hibernate.boot.model.NamedEntityGraphDefinition; |
35 | 68 | import org.hibernate.boot.model.internal.InheritanceState.ElementsToProcess; |
|
86 | 119 |
|
87 | 120 | import static jakarta.persistence.InheritanceType.SINGLE_TABLE; |
88 | 121 | import static java.util.Collections.addAll; |
| 122 | +import static org.hibernate.boot.BootLogging.BOOT_LOGGER; |
89 | 123 | import static org.hibernate.boot.model.internal.AnnotatedClassType.MAPPED_SUPERCLASS; |
90 | 124 | import static org.hibernate.boot.model.internal.AnnotatedDiscriminatorColumn.DEFAULT_DISCRIMINATOR_COLUMN_NAME; |
91 | 125 | import static org.hibernate.boot.model.internal.AnnotatedDiscriminatorColumn.buildDiscriminatorColumn; |
|
112 | 146 | import static org.hibernate.boot.spi.AccessType.getAccessStrategy; |
113 | 147 | import static org.hibernate.engine.OptimisticLockStyle.fromLockType; |
114 | 148 | import static org.hibernate.engine.spi.ExecuteUpdateResultCheckStyle.fromResultCheckStyle; |
115 | | -import static org.hibernate.boot.BootLogging.BOOT_LOGGER; |
116 | 149 | import static org.hibernate.internal.util.ReflectHelper.getDefaultSupplier; |
117 | 150 | import static org.hibernate.internal.util.StringHelper.isBlank; |
118 | 151 | import static org.hibernate.internal.util.StringHelper.isNotBlank; |
@@ -159,7 +192,7 @@ public class EntityBinder { |
159 | 192 | private String cacheRegion; |
160 | 193 | private boolean cacheLazyProperty; |
161 | 194 | private String naturalIdCacheRegion; |
162 | | - private Class<?> naturalIdClass; |
| 195 | + private ClassDetails naturalIdClass; |
163 | 196 | private CacheLayout queryCacheLayout; |
164 | 197 |
|
165 | 198 | private ModelsContext modelsContext() { |
@@ -1340,7 +1373,7 @@ private void bindRootEntity() { |
1340 | 1373 | rootClass.setLazyPropertiesCacheable( cacheLazyProperty ); |
1341 | 1374 | } |
1342 | 1375 | rootClass.setNaturalIdCacheRegionName( naturalIdCacheRegion ); |
1343 | | - rootClass.setNaturalIdClass( naturalIdClass ); |
| 1376 | + rootClass.setNaturalIdClass( naturalIdClass ); |
1344 | 1377 | } |
1345 | 1378 |
|
1346 | 1379 | private void bindCustomSql() { |
@@ -1618,7 +1651,16 @@ private SQLRestriction extractSQLRestriction(ClassDetails classDetails) { |
1618 | 1651 |
|
1619 | 1652 | private void bindNaturalIdClass() { |
1620 | 1653 | final var ann = annotatedClass.getAnnotationUsage( NaturalIdClass.class, modelsContext() ); |
1621 | | - naturalIdClass = ann != null ? ann.value() : null; |
| 1654 | + if ( ann != null ) { |
| 1655 | + if ( ann.value() == void.class ) { |
| 1656 | + throw new IllegalStateException( "NaturalIdClass#value must not be void.class" ); |
| 1657 | + } |
| 1658 | + naturalIdClass = context |
| 1659 | + .getBootstrapContext() |
| 1660 | + .getModelsContext() |
| 1661 | + .getClassDetailsRegistry() |
| 1662 | + .resolveClassDetails( ann.value().getName() ); |
| 1663 | + } |
1622 | 1664 | } |
1623 | 1665 |
|
1624 | 1666 | private void bindNaturalIdCache() { |
|
0 commit comments