Skip to content

Commit dfd852c

Browse files
committed
HHH-19449 prepare
1 parent 8544c57 commit dfd852c

27 files changed

+166
-179
lines changed

hibernate-core/src/main/java/org/hibernate/metamodel/internal/AttributeFactory.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -237,13 +237,9 @@ public static <Y> DomainType<Y> determineSimpleType(ValueContext typeContext, Me
237237

238238
private static <Y> EmbeddableDomainType<Y> embeddableDomainType(ValueContext typeContext, MetadataContext context) {
239239
final Component component = (Component) typeContext.getHibernateValue();
240-
if ( component.isDynamic() ) {
241-
return dynamicEmbeddableType( context, component );
242-
}
243-
else {
244-
// we should have a non-dynamic embeddable
245-
return classEmbeddableType( context, component );
246-
}
240+
return component.isDynamic()
241+
? dynamicEmbeddableType( context, component )
242+
: classEmbeddableType( context, component ); // we should have a non-dynamic embeddable
247243
}
248244

249245
private static <Y> EmbeddableDomainType<Y> classEmbeddableType(MetadataContext context, Component component) {

hibernate-core/src/main/java/org/hibernate/metamodel/internal/SingularAttributeMetadataImpl.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,11 @@ public Class<Y> getJpaBindableType() {
3838

3939
@Override
4040
public ValueClassification getValueClassification() {
41-
switch ( attributeClassification ) {
42-
case EMBEDDED: {
43-
return ValueClassification.EMBEDDABLE;
44-
}
45-
case BASIC: {
46-
return ValueClassification.BASIC;
47-
}
48-
default: {
49-
return ValueClassification.ENTITY;
50-
}
51-
}
41+
return switch ( attributeClassification ) {
42+
case EMBEDDED -> ValueClassification.EMBEDDABLE;
43+
case BASIC -> ValueClassification.BASIC;
44+
default -> ValueClassification.ENTITY;
45+
};
5246
}
5347

5448
@Override

hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/AnyDiscriminatorSqmPath.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,6 @@ public <X> X accept(SemanticQueryWalker<X> walker) {
4444
@Override
4545
public AnyDiscriminatorSqmPathSource<T> getExpressible() {
4646
return (AnyDiscriminatorSqmPathSource<T>) getNodeType();
47+
// return (AnyDiscriminatorSqmPathSource<T>) super.getExpressible();
4748
}
4849
}

hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/BasicTypeImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,17 @@ public J extract(
7676
}
7777

7878
@Override
79-
public JavaType getJavaTypeDescriptor() {
79+
public JavaType<?> getJavaTypeDescriptor() {
8080
throw new UnsupportedOperationException();
8181
}
8282

8383
@Override
84-
public ValueExtractor<?> getJdbcValueExtractor() {
84+
public ValueExtractor<J> getJdbcValueExtractor() {
8585
return jdbcType.getExtractor( javaType );
8686
}
8787

8888
@Override
89-
public ValueBinder getJdbcValueBinder() {
89+
public ValueBinder<J> getJdbcValueBinder() {
9090
return jdbcType.getBinder( javaType );
9191
}
9292
}

hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/EmbeddedDiscriminatorSqmPath.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,11 @@
2222
public class EmbeddedDiscriminatorSqmPath<T> extends AbstractSqmPath<T> implements DiscriminatorSqmPath<T> {
2323
private final EmbeddableDomainType<T> embeddableDomainType;
2424

25-
@SuppressWarnings( { "rawtypes", "unchecked" } )
2625
protected EmbeddedDiscriminatorSqmPath(
2726
NavigablePath navigablePath,
28-
SqmPathSource referencedPathSource,
27+
SqmPathSource<T> referencedPathSource,
2928
SqmPath<?> lhs,
30-
EmbeddableDomainType embeddableDomainType,
29+
EmbeddableDomainType<T> embeddableDomainType,
3130
NodeBuilder nodeBuilder) {
3231
super( navigablePath, referencedPathSource, lhs, nodeBuilder );
3332
this.embeddableDomainType = embeddableDomainType;
@@ -40,6 +39,7 @@ public EmbeddableDomainType<T> getEmbeddableDomainType() {
4039
@Override
4140
public EmbeddedDiscriminatorSqmPathSource<T> getExpressible() {
4241
return (EmbeddedDiscriminatorSqmPathSource<T>) getNodeType();
42+
// return (EmbeddedDiscriminatorSqmPathSource<T>) super.getExpressible();
4343
}
4444

4545
@Override

hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/EmbeddedDiscriminatorSqmPathSource.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ public EmbeddedDiscriminatorSqmPathSource(DomainType<D> discriminatorType, Embed
2424

2525
@Override
2626
public SqmPath<D> createSqmPath(SqmPath<?> lhs, SqmPathSource<?> intermediatePathSource) {
27+
//noinspection unchecked
2728
return new EmbeddedDiscriminatorSqmPath<>(
2829
PathHelper.append( lhs, this, intermediatePathSource ),
2930
pathModel,
3031
lhs,
31-
embeddableDomainType,
32+
(EmbeddableDomainType<D>) embeddableDomainType,
3233
lhs.nodeBuilder()
3334
);
3435
}

hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/EntityDiscriminatorSqmPath.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public EntityMappingType getEntityDescriptor() {
5050
@Override
5151
public EntityDiscriminatorSqmPathSource getExpressible() {
5252
return (EntityDiscriminatorSqmPathSource) getNodeType();
53+
// return (EntityDiscriminatorSqmPathSource) super.getExpressible();
5354
}
5455

5556
@Override
@@ -58,18 +59,19 @@ public EntityDiscriminatorSqmPath copy(SqmCopyContext context) {
5859
if ( existing != null ) {
5960
return existing;
6061
}
61-
return context.registerCopy(
62-
this,
63-
(EntityDiscriminatorSqmPath) getLhs().copy( context ).type()
64-
);
62+
else {
63+
return context.registerCopy(
64+
this,
65+
(EntityDiscriminatorSqmPath) getLhs().copy( context ).type()
66+
);
67+
}
6568
}
6669

6770
@Override
6871
public <X> X accept(SemanticQueryWalker<X> walker) {
69-
if ( ! entityDescriptor.hasSubclasses() ) {
70-
return walker.visitEntityTypeLiteralExpression( new SqmLiteralEntityType( entityDomainType, nodeBuilder() ) );
71-
}
72+
return entityDescriptor.hasSubclasses()
73+
? walker.visitDiscriminatorPath( this )
74+
: walker.visitEntityTypeLiteralExpression( new SqmLiteralEntityType( entityDomainType, nodeBuilder() ) );
7275

73-
return walker.visitDiscriminatorPath( this );
7476
}
7577
}

hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2550,10 +2550,11 @@ else if ( r instanceof AnyDiscriminatorSqmPath<?> anyDiscriminatorPath && l inst
25502550
private <T> SqmExpression<T> createDiscriminatorValue(
25512551
AnyDiscriminatorSqmPath<T> anyDiscriminatorTypeSqmPath,
25522552
HqlParser.ExpressionContext valueExpressionContext) {
2553+
final var expressible = anyDiscriminatorTypeSqmPath.getExpressible();
25532554
return new SqmAnyDiscriminatorValue<>(
2554-
anyDiscriminatorTypeSqmPath.getNodeType().getPathName(),
2555-
creationContext.getJpaMetamodel().resolveHqlEntityReference( valueExpressionContext.getText() ),
2556-
anyDiscriminatorTypeSqmPath.getExpressible().getPathType(),
2555+
expressible.getPathName(),
2556+
getJpaMetamodel().resolveHqlEntityReference( valueExpressionContext.getText() ),
2557+
expressible.getPathType(),
25572558
creationContext.getNodeBuilder()
25582559
);
25592560
}

hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SqmCriteriaNodeBuilder.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2154,6 +2154,7 @@ private static SqmExpressible<?> getNodeType(SqmExpression<?> expression) {
21542154
return sqmPath.getResolvedModel() instanceof SqmSingularPersistentAttribute<?,?> attribute
21552155
? attribute.getSqmPathSource()
21562156
: sqmPath.getResolvedModel();
2157+
// : sqmPath.getExpressible();
21572158
}
21582159
else {
21592160
return expression.getNodeType();
@@ -2169,13 +2170,10 @@ private <T> ValueBindJpaCriteriaParameter<T> valueParameter(T value, SqmExpressi
21692170
final T coercedValue =
21702171
resolveExpressible( bindableType ).getExpressibleJavaType()
21712172
.coerce(value, this::getTypeConfiguration );
2172-
if ( isInstance( bindableType, coercedValue ) ) {
2173-
return new ValueBindJpaCriteriaParameter<>( bindableType, coercedValue, this );
2174-
}
2175-
else {
2176-
// ignore typeInferenceSource and fall back the value type
2177-
return new ValueBindJpaCriteriaParameter<>( getParameterBindType( value ), value, this );
2178-
}
2173+
return isInstance( bindableType, coercedValue )
2174+
? new ValueBindJpaCriteriaParameter<>( bindableType, coercedValue, this )
2175+
// ignore typeInferenceSource and fall back the value type
2176+
: new ValueBindJpaCriteriaParameter<>( getParameterBindType( value ), value, this );
21792177
}
21802178

21812179
private <E> ValueBindJpaCriteriaParameter<? extends Collection<E>> collectionValueParameter(Collection<E> value, SqmExpression<E> elementTypeInferenceSource) {

hibernate-core/src/main/java/org/hibernate/query/sqm/internal/TypecheckUtil.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import org.hibernate.query.SemanticException;
1919
import org.hibernate.query.sqm.BinaryArithmeticOperator;
2020
import org.hibernate.query.sqm.SqmExpressible;
21-
import org.hibernate.query.sqm.SqmPathSource;
2221
import org.hibernate.query.sqm.UnaryArithmeticOperator;
2322
import org.hibernate.query.sqm.tree.SqmTypedNode;
2423
import org.hibernate.query.sqm.tree.domain.SqmPath;
@@ -101,7 +100,7 @@ public class TypecheckUtil {
101100
* @param lhsType the type of the expression on the LHS of the comparison operator
102101
* @param rhsType the type of the expression on the RHS of the comparison operator
103102
*
104-
* @see #isTypeAssignable(SqmPathSource, SqmExpressible, BindingContext)
103+
* @see #isTypeAssignable(SqmExpressible, SqmExpressible, BindingContext)
105104
*/
106105
public static boolean areTypesComparable(
107106
SqmExpressible<?> lhsType,
@@ -315,7 +314,7 @@ else if ( rhsType instanceof SqmExpressible<?> rhsExpressible ) {
315314
* @see #areTypesComparable(SqmExpressible, SqmExpressible, BindingContext)
316315
*/
317316
private static boolean isTypeAssignable(
318-
SqmPathSource<?> targetType, SqmExpressible<?> expressionType,
317+
SqmExpressible<?> targetType, SqmExpressible<?> expressionType,
319318
BindingContext bindingContext) {
320319

321320
if ( targetType == null || expressionType == null || targetType == expressionType ) {
@@ -466,7 +465,7 @@ public static void assertAssignable(
466465
// TODO: check that the target path is nullable
467466
}
468467
else {
469-
final SqmPathSource<?> targetType = targetPath.getNodeType();
468+
final SqmExpressible<?> targetType = targetPath.getNodeType();
470469
final SqmExpressible<?> expressionType = expression.getNodeType();
471470
if ( targetType != null && expressionType != null && targetPath.isEnum() ) {
472471
// this is needed by Hibernate Processor due to the weird

0 commit comments

Comments
 (0)