HHH-16866 remove usages of Sqm types from Jpa APIs
There were quite a few layer-breakers here. The org.hibernate.criteria package is supposed to be an abstraction over the SQM tree. It should not leak types from the org.hibernate.sqm package.
This commit is contained in:
parent
f933b064e9
commit
41fe405aa7
|
@ -38,7 +38,6 @@ import org.hibernate.query.SortDirection;
|
|||
import org.hibernate.query.sqm.FrameKind;
|
||||
import org.hibernate.query.NullPrecedence;
|
||||
import org.hibernate.query.sqm.TemporalUnit;
|
||||
import org.hibernate.query.sqm.tree.expression.SqmExpression;
|
||||
|
||||
/**
|
||||
* A JPA {@link CriteriaBuilder} is a source of objects which may be composed
|
||||
|
@ -459,7 +458,6 @@ public interface HibernateCriteriaBuilder extends CriteriaBuilder {
|
|||
|
||||
@Override
|
||||
<T> JpaExpression<T> literal(T value);
|
||||
<T> SqmExpression<T> literal(T value, SqmExpression<? extends T> typeInferenceSource);
|
||||
|
||||
<T> List<? extends JpaExpression<T>> literals(T... values);
|
||||
|
||||
|
@ -570,9 +568,7 @@ public interface HibernateCriteriaBuilder extends CriteriaBuilder {
|
|||
|
||||
<K, L extends List<?>> JpaExpression<Set<K>> indexes(L list);
|
||||
|
||||
<T> SqmExpression<T> value(T value);
|
||||
|
||||
<T> SqmExpression<T> value(T value, SqmExpression<? extends T> typeInferenceSource);
|
||||
<T> JpaExpression<T> value(T value);
|
||||
|
||||
<V, C extends Collection<V>> JpaExpression<Collection<V>> values(C collection);
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
package org.hibernate.query.criteria;
|
||||
|
||||
import org.hibernate.Incubating;
|
||||
import org.hibernate.query.sqm.tree.from.SqmQualifiedJoin;
|
||||
|
||||
import jakarta.persistence.criteria.Expression;
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
*/
|
||||
package org.hibernate.query.criteria;
|
||||
|
||||
import org.hibernate.query.sqm.tree.from.SqmRoot;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
|
@ -20,5 +18,5 @@ public interface JpaManipulationCriteria<E> extends JpaQueryableCriteria<E> {
|
|||
/**
|
||||
* Set the root path
|
||||
*/
|
||||
void setTarget(SqmRoot<E> root);
|
||||
void setTarget(JpaRoot<E> root);
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ import jakarta.persistence.metamodel.PluralAttribute;
|
|||
import jakarta.persistence.metamodel.SingularAttribute;
|
||||
|
||||
import org.hibernate.metamodel.model.domain.EntityDomainType;
|
||||
import org.hibernate.query.sqm.SqmPathSource;
|
||||
import org.hibernate.spi.NavigablePath;
|
||||
|
||||
/**
|
||||
|
@ -44,11 +43,6 @@ public interface JpaPath<T> extends JpaExpression<T>, Path<T> {
|
|||
*/
|
||||
<S extends T> JpaPath<S> treatAs(EntityDomainType<S> treatJavaType);
|
||||
|
||||
/**
|
||||
* Get this path's actual resolved model, i.e. the concrete type for generic attributes.
|
||||
*/
|
||||
SqmPathSource<?> getResolvedModel();
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Covariant overrides
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
package org.hibernate.query.criteria;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import jakarta.persistence.criteria.CollectionJoin;
|
||||
import jakarta.persistence.criteria.Expression;
|
||||
|
@ -22,9 +21,6 @@ import jakarta.persistence.criteria.SetJoin;
|
|||
import jakarta.persistence.criteria.Subquery;
|
||||
|
||||
import org.hibernate.query.sqm.FetchClauseType;
|
||||
import org.hibernate.query.sqm.tree.from.SqmCrossJoin;
|
||||
import org.hibernate.query.sqm.tree.from.SqmEntityJoin;
|
||||
import org.hibernate.query.sqm.tree.from.SqmJoin;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
|
@ -35,11 +31,9 @@ public interface JpaSubQuery<T> extends Subquery<T>, JpaSelectCriteria<T>, JpaEx
|
|||
|
||||
JpaSubQuery<T> multiselect(List<Selection<?>> selectionList);
|
||||
|
||||
<X> SqmCrossJoin<X> correlate(SqmCrossJoin<X> parentCrossJoin);
|
||||
<X> JpaCrossJoin<X> correlate(JpaCrossJoin<X> parentCrossJoin);
|
||||
|
||||
<X> SqmEntityJoin<X> correlate(SqmEntityJoin<X> parentEntityJoin);
|
||||
|
||||
Set<SqmJoin<?, ?>> getCorrelatedSqmJoins();
|
||||
<X> JpaEntityJoin<X> correlate(JpaEntityJoin<X> parentEntityJoin);
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Limit/Offset/Fetch clause
|
||||
|
|
|
@ -54,7 +54,6 @@ import org.hibernate.query.criteria.JpaWindow;
|
|||
import org.hibernate.query.criteria.JpaWindowFrame;
|
||||
import org.hibernate.query.NullPrecedence;
|
||||
import org.hibernate.query.sqm.TemporalUnit;
|
||||
import org.hibernate.query.sqm.tree.expression.SqmExpression;
|
||||
|
||||
import jakarta.persistence.Tuple;
|
||||
import jakarta.persistence.criteria.CollectionJoin;
|
||||
|
@ -554,11 +553,6 @@ public class HibernateCriteriaBuilderDelegate implements HibernateCriteriaBuilde
|
|||
return criteriaBuilder.literal( value );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> SqmExpression<T> literal(T value, SqmExpression<? extends T> typeInferenceSource) {
|
||||
return criteriaBuilder.literal( value, typeInferenceSource );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> List<? extends JpaExpression<T>> literals(T[] values) {
|
||||
return criteriaBuilder.literals( values );
|
||||
|
@ -740,15 +734,10 @@ public class HibernateCriteriaBuilderDelegate implements HibernateCriteriaBuilde
|
|||
}
|
||||
|
||||
@Override
|
||||
public <T> SqmExpression<T> value(T value) {
|
||||
public <T> JpaExpression<T> value(T value) {
|
||||
return criteriaBuilder.value( value );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> SqmExpression<T> value(T value, SqmExpression<? extends T> typeInferenceSource) {
|
||||
return criteriaBuilder.value( value, typeInferenceSource );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <V, C extends Collection<V>> JpaExpression<Collection<V>> values(C collection) {
|
||||
return criteriaBuilder.values( collection );
|
||||
|
|
|
@ -72,7 +72,6 @@ import org.hibernate.query.sqm.ComparisonOperator;
|
|||
import org.hibernate.query.sqm.FrameKind;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
import org.hibernate.query.sqm.SetOperator;
|
||||
import org.hibernate.query.SortDirection;
|
||||
import org.hibernate.query.sqm.SqmExpressible;
|
||||
import org.hibernate.query.sqm.SqmQuerySource;
|
||||
import org.hibernate.query.sqm.TemporalUnit;
|
||||
|
@ -462,7 +461,7 @@ public class SqmCriteriaNodeBuilder implements NodeBuilder, SqmCreationContext,
|
|||
return new SqmJunctionPredicate( Predicate.BooleanOperator.AND, predicates, this );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override @SuppressWarnings("unchecked")
|
||||
public <T extends HibernateCriteriaBuilder> T unwrap(Class<T> clazz) {
|
||||
return (T) extensions.get( clazz );
|
||||
}
|
||||
|
@ -509,7 +508,7 @@ public class SqmCriteriaNodeBuilder implements NodeBuilder, SqmCreationContext,
|
|||
|
||||
@Override
|
||||
public <X, K, T, V extends T> SqmMapJoin<X, K, V> treat(MapJoin<X, K, T> join, Class<V> type) {
|
||||
return ( (SqmMapJoin<X, K, V>) join ).treatAs( type );
|
||||
return ( (SqmMapJoin<X, K, T>) join ).treatAs( type );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1131,7 +1130,6 @@ public class SqmCriteriaNodeBuilder implements NodeBuilder, SqmCreationContext,
|
|||
return ( (SqmExpression<?>) character ).asString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> SqmLiteral<T> literal(T value, SqmExpression<? extends T> typeInferenceSource) {
|
||||
if ( value == null ) {
|
||||
return new SqmLiteralNull<>( this );
|
||||
|
@ -1663,7 +1661,6 @@ public class SqmCriteriaNodeBuilder implements NodeBuilder, SqmCreationContext,
|
|||
/**
|
||||
* Creates an expression for the value with the given "type inference" information
|
||||
*/
|
||||
@Override
|
||||
public <T> SqmExpression<T> value(T value, SqmExpression<? extends T> typeInferenceSource) {
|
||||
if ( value instanceof SqmExpression ) {
|
||||
return (SqmExpression<T>) value;
|
||||
|
|
|
@ -13,17 +13,16 @@ import java.util.Set;
|
|||
import java.util.function.Function;
|
||||
|
||||
import org.hibernate.query.criteria.JpaCteCriteria;
|
||||
import org.hibernate.query.criteria.JpaRoot;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
import org.hibernate.query.sqm.SqmQuerySource;
|
||||
import org.hibernate.query.sqm.tree.cte.SqmCteStatement;
|
||||
import org.hibernate.query.sqm.tree.expression.SqmParameter;
|
||||
import org.hibernate.query.sqm.tree.from.SqmRoot;
|
||||
import org.hibernate.query.sqm.tree.select.SqmSelectQuery;
|
||||
import org.hibernate.query.sqm.tree.select.SqmSelectStatement;
|
||||
import org.hibernate.query.sqm.tree.select.SqmSubQuery;
|
||||
|
||||
import jakarta.persistence.criteria.AbstractQuery;
|
||||
import jakarta.persistence.criteria.CriteriaQuery;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
|
@ -176,8 +175,8 @@ public abstract class AbstractSqmDmlStatement<E>
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setTarget(SqmRoot<E> root) {
|
||||
this.target = root;
|
||||
public void setTarget(JpaRoot<E> root) {
|
||||
this.target = (SqmRoot<E>) root;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
package org.hibernate.query.sqm.tree;
|
||||
|
||||
import org.hibernate.query.criteria.JpaManipulationCriteria;
|
||||
import org.hibernate.query.criteria.JpaRoot;
|
||||
import org.hibernate.query.sqm.tree.cte.SqmCteContainer;
|
||||
import org.hibernate.query.sqm.tree.delete.SqmDeleteStatement;
|
||||
import org.hibernate.query.sqm.tree.from.SqmRoot;
|
||||
|
@ -28,5 +29,5 @@ public interface SqmDmlStatement<E> extends SqmStatement<E>, SqmCteContainer, Jp
|
|||
/**
|
||||
* Set the root path
|
||||
*/
|
||||
void setTarget(SqmRoot<E> root);
|
||||
void setTarget(JpaRoot<E> root);
|
||||
}
|
||||
|
|
|
@ -140,6 +140,12 @@ public interface SqmPath<T> extends SqmExpression<T>, SemanticPathPart, JpaPath<
|
|||
SqmCreationState creationState) {
|
||||
throw new SemanticException( "Index operator applied to non-plural path '" + getNavigablePath() + "'" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get this path's actual resolved model, i.e. the concrete type for generic attributes.
|
||||
*/
|
||||
SqmPathSource<?> getResolvedModel();
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Covariant overrides
|
||||
|
||||
|
|
|
@ -15,8 +15,10 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
|
||||
import org.hibernate.metamodel.model.domain.EntityDomainType;
|
||||
import org.hibernate.query.criteria.JpaCrossJoin;
|
||||
import org.hibernate.query.criteria.JpaCteContainer;
|
||||
import org.hibernate.query.criteria.JpaCteCriteria;
|
||||
import org.hibernate.query.criteria.JpaEntityJoin;
|
||||
import org.hibernate.query.criteria.JpaExpression;
|
||||
import org.hibernate.query.criteria.JpaOrder;
|
||||
import org.hibernate.query.criteria.JpaSelection;
|
||||
|
@ -498,15 +500,17 @@ public class SqmSubQuery<T> extends AbstractSqmSelectQuery<T> implements SqmSele
|
|||
}
|
||||
|
||||
@Override
|
||||
public <X> SqmCrossJoin<X> correlate(SqmCrossJoin<X> parentCrossJoin) {
|
||||
final SqmCorrelatedCrossJoin<X> correlated = parentCrossJoin.createCorrelation();
|
||||
public <X> SqmCrossJoin<X> correlate(JpaCrossJoin<X> parentCrossJoin) {
|
||||
final SqmCorrelatedCrossJoin<X> correlated =
|
||||
((SqmCrossJoin<X>) parentCrossJoin).createCorrelation();
|
||||
getQuerySpec().addRoot( correlated.getCorrelatedRoot() );
|
||||
return correlated;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <X> SqmEntityJoin<X> correlate(SqmEntityJoin<X> parentEntityJoin) {
|
||||
final SqmCorrelatedEntityJoin<X> correlated = parentEntityJoin.createCorrelation();
|
||||
public <X> SqmEntityJoin<X> correlate(JpaEntityJoin<X> parentEntityJoin) {
|
||||
final SqmCorrelatedEntityJoin<X> correlated =
|
||||
((SqmEntityJoin<X>) parentEntityJoin).createCorrelation();
|
||||
getQuerySpec().addRoot( correlated.getCorrelatedRoot() );
|
||||
return correlated;
|
||||
}
|
||||
|
@ -531,20 +535,20 @@ public class SqmSubQuery<T> extends AbstractSqmSelectQuery<T> implements SqmSele
|
|||
return correlatedJoins;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<SqmJoin<?, ?>> getCorrelatedSqmJoins() {
|
||||
final Set<SqmJoin<?, ?>> correlatedJoins = new HashSet<>();
|
||||
for ( SqmRoot<?> root : getQuerySpec().getFromClause().getRoots() ) {
|
||||
if ( root instanceof SqmCorrelation<?, ?> ) {
|
||||
for ( SqmJoin<?, ?> sqmJoin : root.getSqmJoins() ) {
|
||||
if ( sqmJoin instanceof SqmCorrelation<?, ?> ) {
|
||||
correlatedJoins.add( sqmJoin );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return correlatedJoins;
|
||||
}
|
||||
// @Override
|
||||
// public Set<SqmJoin<?, ?>> getCorrelatedSqmJoins() {
|
||||
// final Set<SqmJoin<?, ?>> correlatedJoins = new HashSet<>();
|
||||
// for ( SqmRoot<?> root : getQuerySpec().getFromClause().getRoots() ) {
|
||||
// if ( root instanceof SqmCorrelation<?, ?> ) {
|
||||
// for ( SqmJoin<?, ?> sqmJoin : root.getSqmJoins() ) {
|
||||
// if ( sqmJoin instanceof SqmCorrelation<?, ?> ) {
|
||||
// correlatedJoins.add( sqmJoin );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return correlatedJoins;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public SqmPredicate isNull() {
|
||||
|
|
|
@ -102,26 +102,24 @@ public class SqmUpdateStatement<T>
|
|||
|
||||
@Override
|
||||
public <Y, X extends Y> SqmUpdateStatement<T> set(SingularAttribute<? super T, Y> attribute, X value) {
|
||||
applyAssignment( getTarget().get( attribute ), nodeBuilder().value( value ) );
|
||||
applyAssignment( getTarget().get( attribute ), (SqmExpression<? extends Y>) nodeBuilder().value( value ) );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <Y> SqmUpdateStatement<T> set(SingularAttribute<? super T, Y> attribute, Expression<? extends Y> value) {
|
||||
//noinspection unchecked
|
||||
applyAssignment( getTarget().get( attribute ), (SqmExpression<? extends Y>) value );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <Y, X extends Y> SqmUpdateStatement<T> set(Path<Y> attribute, X value) {
|
||||
applyAssignment( (SqmPath<Y>) attribute, nodeBuilder().value( value ) );
|
||||
applyAssignment( (SqmPath<Y>) attribute, (SqmExpression<? extends Y>) nodeBuilder().value( value ) );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <Y> SqmUpdateStatement<T> set(Path<Y> attribute, Expression<? extends Y> value) {
|
||||
//noinspection unchecked
|
||||
applyAssignment( (SqmPath<Y>) attribute, (SqmExpression<? extends Y>) value );
|
||||
return this;
|
||||
}
|
||||
|
@ -130,7 +128,7 @@ public class SqmUpdateStatement<T>
|
|||
public SqmUpdateStatement<T> set(String attributeName, Object value) {
|
||||
//noinspection unchecked
|
||||
final SqmPath<Object> sqmPath = (SqmPath<Object>) getTarget().get( attributeName );
|
||||
applyAssignment( sqmPath, nodeBuilder().value( value ) );
|
||||
applyAssignment( sqmPath, (SqmExpression<?>) nodeBuilder().value( value ) );
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,9 +8,9 @@ package org.hibernate.orm.test.annotations.embeddables.generics;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.hibernate.query.criteria.JpaPath;
|
||||
import org.hibernate.query.sqm.SqmPathSource;
|
||||
|
||||
import org.hibernate.query.sqm.tree.domain.SqmPath;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.Jira;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
|
@ -112,7 +112,7 @@ public class GenericEmbeddedIdentifierMappedSuperclassTest {
|
|||
assertThat( modelPathSource.findSubPathSource( "serial" )
|
||||
.getBindableJavaType() ).isEqualTo( Integer.class );
|
||||
// assert that types of the concrete attributes inside the component's resolved model are reported correctly
|
||||
final SqmPathSource<?> resolvedPathSource = ( (JpaPath<Object>) id ).getResolvedModel();
|
||||
final SqmPathSource<?> resolvedPathSource = ( (SqmPath<Object>) id ).getResolvedModel();
|
||||
assertThat( resolvedPathSource.findSubPathSource( "entity" )
|
||||
.getBindableJavaType() ).isEqualTo( User.class );
|
||||
assertThat( resolvedPathSource.findSubPathSource( "embedded" )
|
||||
|
@ -163,7 +163,7 @@ public class GenericEmbeddedIdentifierMappedSuperclassTest {
|
|||
assertThat( modelPathSource.findSubPathSource( "serial" )
|
||||
.getBindableJavaType() ).isEqualTo( Integer.class );
|
||||
// assert that types of the concrete attributes inside the component's resolved model are reported correctly
|
||||
final SqmPathSource<?> resolvedPathSource = ( (JpaPath<Object>) id ).getResolvedModel();
|
||||
final SqmPathSource<?> resolvedPathSource = ( (SqmPath<Object>) id ).getResolvedModel();
|
||||
assertThat( resolvedPathSource.findSubPathSource( "entity" )
|
||||
.getBindableJavaType() ).isEqualTo( Group.class );
|
||||
assertThat( resolvedPathSource.findSubPathSource( "embedded" )
|
||||
|
|
|
@ -8,9 +8,9 @@ package org.hibernate.orm.test.annotations.embeddables.generics;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.hibernate.query.criteria.JpaPath;
|
||||
import org.hibernate.query.sqm.SqmPathSource;
|
||||
|
||||
import org.hibernate.query.sqm.tree.domain.SqmPath;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.Jira;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
|
@ -110,7 +110,7 @@ public class GenericEmbeddedIdentifierTest {
|
|||
assertThat( modelPathSource.findSubPathSource( "serial" )
|
||||
.getBindableJavaType() ).isEqualTo( Integer.class );
|
||||
// assert that types of the concrete attributes inside the component's resolved model are reported correctly
|
||||
final SqmPathSource<?> resolvedPathSource = ( (JpaPath<Object>) id ).getResolvedModel();
|
||||
final SqmPathSource<?> resolvedPathSource = ( (SqmPath<Object>) id ).getResolvedModel();
|
||||
assertThat( resolvedPathSource.findSubPathSource( "entity" )
|
||||
.getBindableJavaType() ).isEqualTo( User.class );
|
||||
assertThat( resolvedPathSource.findSubPathSource( "embedded" )
|
||||
|
@ -161,7 +161,7 @@ public class GenericEmbeddedIdentifierTest {
|
|||
assertThat( modelPathSource.findSubPathSource( "serial" )
|
||||
.getBindableJavaType() ).isEqualTo( Integer.class );
|
||||
// assert that types of the concrete attributes inside the component's resolved model are reported correctly
|
||||
final SqmPathSource<?> resolvedPathSource = ( (JpaPath<Object>) id ).getResolvedModel();
|
||||
final SqmPathSource<?> resolvedPathSource = ( (SqmPath<Object>) id ).getResolvedModel();
|
||||
assertThat( resolvedPathSource.findSubPathSource( "entity" )
|
||||
.getBindableJavaType() ).isEqualTo( Group.class );
|
||||
assertThat( resolvedPathSource.findSubPathSource( "embedded" )
|
||||
|
|
|
@ -8,9 +8,9 @@ package org.hibernate.orm.test.annotations.embeddables.generics;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.hibernate.query.criteria.JpaPath;
|
||||
import org.hibernate.query.sqm.SqmPathSource;
|
||||
|
||||
import org.hibernate.query.sqm.tree.domain.SqmPath;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.Jira;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
|
@ -110,7 +110,7 @@ public class GenericEmbeddedPropertyMappedSuperclassTest {
|
|||
assertThat( modelPathSource.findSubPathSource( "serial" )
|
||||
.getBindableJavaType() ).isEqualTo( Integer.class );
|
||||
// assert that types of the concrete attributes inside the component's resolved model are reported correctly
|
||||
final SqmPathSource<?> resolvedPathSource = ( (JpaPath<Object>) prop ).getResolvedModel();
|
||||
final SqmPathSource<?> resolvedPathSource = ( (SqmPath<Object>) prop ).getResolvedModel();
|
||||
assertThat( resolvedPathSource.findSubPathSource( "entity" )
|
||||
.getBindableJavaType() ).isEqualTo( User.class );
|
||||
assertThat( resolvedPathSource.findSubPathSource( "embedded" )
|
||||
|
@ -161,7 +161,7 @@ public class GenericEmbeddedPropertyMappedSuperclassTest {
|
|||
assertThat( modelPathSource.findSubPathSource( "serial" )
|
||||
.getBindableJavaType() ).isEqualTo( Integer.class );
|
||||
// assert that types of the concrete attributes inside the component's resolved model are reported correctly
|
||||
final SqmPathSource<?> resolvedPathSource = ( (JpaPath<Object>) prop ).getResolvedModel();
|
||||
final SqmPathSource<?> resolvedPathSource = ( (SqmPath<Object>) prop ).getResolvedModel();
|
||||
assertThat( resolvedPathSource.findSubPathSource( "entity" )
|
||||
.getBindableJavaType() ).isEqualTo( Group.class );
|
||||
assertThat( resolvedPathSource.findSubPathSource( "embedded" )
|
||||
|
|
|
@ -8,9 +8,9 @@ package org.hibernate.orm.test.annotations.embeddables.generics;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.hibernate.query.criteria.JpaPath;
|
||||
import org.hibernate.query.sqm.SqmPathSource;
|
||||
|
||||
import org.hibernate.query.sqm.tree.domain.SqmPath;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.Jira;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
|
@ -109,7 +109,7 @@ public class GenericEmbeddedPropertyTest {
|
|||
assertThat( modelPathSource.findSubPathSource( "serial" )
|
||||
.getBindableJavaType() ).isEqualTo( Integer.class );
|
||||
// assert that types of the concrete attributes inside the component's resolved model are reported correctly
|
||||
final SqmPathSource<?> resolvedPathSource = ( (JpaPath<Object>) prop ).getResolvedModel();
|
||||
final SqmPathSource<?> resolvedPathSource = ( (SqmPath<Object>) prop ).getResolvedModel();
|
||||
assertThat( resolvedPathSource.findSubPathSource( "entity" )
|
||||
.getBindableJavaType() ).isEqualTo( User.class );
|
||||
assertThat( resolvedPathSource.findSubPathSource( "embedded" )
|
||||
|
@ -160,7 +160,7 @@ public class GenericEmbeddedPropertyTest {
|
|||
assertThat( modelPathSource.findSubPathSource( "serial" )
|
||||
.getBindableJavaType() ).isEqualTo( Integer.class );
|
||||
// assert that types of the concrete attributes inside the component's resolved model are reported correctly
|
||||
final SqmPathSource<?> resolvedPathSource = ( (JpaPath<Object>) prop ).getResolvedModel();
|
||||
final SqmPathSource<?> resolvedPathSource = ( (SqmPath<Object>) prop ).getResolvedModel();
|
||||
assertThat( resolvedPathSource.findSubPathSource( "entity" )
|
||||
.getBindableJavaType() ).isEqualTo( Group.class );
|
||||
assertThat( resolvedPathSource.findSubPathSource( "embedded" )
|
||||
|
|
|
@ -9,8 +9,7 @@ package org.hibernate.orm.test.annotations.generics;
|
|||
import java.io.Serializable;
|
||||
import java.util.Random;
|
||||
|
||||
import org.hibernate.query.criteria.JpaPath;
|
||||
|
||||
import org.hibernate.query.sqm.tree.domain.SqmPath;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.Jira;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
|
@ -84,7 +83,7 @@ public class EmbeddedIdGenericsSuperclassTest {
|
|||
final Path<DomainEntityId> id = root.get( "id" );
|
||||
assertThat( id.getJavaType() ).isEqualTo( DomainEntityId.class );
|
||||
assertThat( id.getModel() ).isSameAs( root.getModel().getAttribute( "id" ) );
|
||||
assertThat( ( (JpaPath<?>) id ).getResolvedModel().getBindableJavaType() ).isEqualTo( CustomerId.class );
|
||||
assertThat( ( (SqmPath<?>) id ).getResolvedModel().getBindableJavaType() ).isEqualTo( CustomerId.class );
|
||||
query.select( root ).where( cb.equal( id.get( "someDomainField" ), 1 ) );
|
||||
final Customer customer = session.createQuery( query ).getSingleResult();
|
||||
assertThat( customer ).isNotNull();
|
||||
|
@ -114,7 +113,7 @@ public class EmbeddedIdGenericsSuperclassTest {
|
|||
final Path<DomainEntityId> id = root.get( "id" );
|
||||
assertThat( id.getJavaType() ).isEqualTo( DomainEntityId.class );
|
||||
assertThat( id.getModel() ).isSameAs( root.getModel().getAttribute( "id" ) );
|
||||
assertThat( ( (JpaPath<?>) id ).getResolvedModel().getBindableJavaType() ).isEqualTo( InvoiceId.class );
|
||||
assertThat( ( (SqmPath<?>) id ).getResolvedModel().getBindableJavaType() ).isEqualTo( InvoiceId.class );
|
||||
query.select( root ).where( cb.equal( id.get( "someOtherDomainField" ), 1 ) );
|
||||
final Invoice invoice = session.createQuery( query ).getSingleResult();
|
||||
assertThat( invoice ).isNotNull();
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
*/
|
||||
package org.hibernate.orm.test.annotations.generics;
|
||||
|
||||
import org.hibernate.query.criteria.JpaPath;
|
||||
|
||||
import org.hibernate.query.sqm.tree.domain.SqmPath;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.Jira;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
|
@ -57,7 +56,7 @@ public class GenericBasicValuedPathTest {
|
|||
// generic attributes are always reported as Object java type
|
||||
assertThat( idPath.getJavaType() ).isEqualTo( Object.class );
|
||||
assertThat( idPath.getModel() ).isSameAs( root.getModel().getAttribute( "id" ) );
|
||||
assertThat( ( (JpaPath<?>) idPath ).getResolvedModel().getBindableJavaType() ).isEqualTo( Integer.class );
|
||||
assertThat( ( (SqmPath<?>) idPath ).getResolvedModel().getBindableJavaType() ).isEqualTo( Integer.class );
|
||||
final Object result = session.createQuery( query.select( idPath ) ).getSingleResult();
|
||||
assertThat( result ).isEqualTo( 1 );
|
||||
} );
|
||||
|
@ -73,7 +72,7 @@ public class GenericBasicValuedPathTest {
|
|||
// generic attributes are always reported as Object java type
|
||||
assertThat( dataPath.getJavaType() ).isEqualTo( Object.class );
|
||||
assertThat( dataPath.getModel() ).isSameAs( root.getModel().getAttribute( "data" ) );
|
||||
assertThat( ( (JpaPath<?>) dataPath ).getResolvedModel().getBindableJavaType() ).isEqualTo( String.class );
|
||||
assertThat( ( (SqmPath<?>) dataPath ).getResolvedModel().getBindableJavaType() ).isEqualTo( String.class );
|
||||
final Object result = session.createQuery( query.select( dataPath ) ).getSingleResult();
|
||||
assertThat( result ).isEqualTo( "my_entity" );
|
||||
} );
|
||||
|
|
|
@ -9,8 +9,7 @@ package org.hibernate.orm.test.annotations.generics;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.query.criteria.JpaPath;
|
||||
|
||||
import org.hibernate.query.sqm.tree.domain.SqmPath;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.Jira;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
|
@ -85,7 +84,7 @@ public class GenericMapAssociationTest {
|
|||
// generic attributes are always reported as Object java type
|
||||
assertThat( join.getJavaType() ).isEqualTo( Object.class );
|
||||
assertThat( join.getModel() ).isSameAs( root.getModel().getAttribute( "map" ) );
|
||||
assertThat( ( (JpaPath<?>) join ).getResolvedModel()
|
||||
assertThat( ( (SqmPath<?>) join ).getResolvedModel()
|
||||
.getBindableJavaType() ).isEqualTo( MapValueEntity.class );
|
||||
query.select( join.get( "id" ) );
|
||||
final Long result = session.createQuery( query ).getSingleResult();
|
||||
|
|
|
@ -9,8 +9,7 @@ package org.hibernate.orm.test.annotations.generics;
|
|||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hibernate.query.criteria.JpaPath;
|
||||
|
||||
import org.hibernate.query.sqm.tree.domain.SqmPath;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.Jira;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
|
@ -86,7 +85,7 @@ public class GenericToManyAssociationTest {
|
|||
// generic attributes are always reported as Object java type
|
||||
assertThat( parent.getJavaType() ).isEqualTo( Object.class );
|
||||
assertThat( parent.getModel() ).isSameAs( root.getModel().getAttribute( "parent" ) );
|
||||
assertThat( ( (JpaPath<?>) parent ).getResolvedModel().getBindableJavaType() ).isEqualTo( Parent.class );
|
||||
assertThat( ( (SqmPath<?>) parent ).getResolvedModel().getBindableJavaType() ).isEqualTo( Parent.class );
|
||||
final Long result = session.createQuery( query.select( parent.get( "id" ) ) ).getSingleResult();
|
||||
assertThat( result ).isEqualTo( 1L );
|
||||
} );
|
||||
|
@ -110,7 +109,7 @@ public class GenericToManyAssociationTest {
|
|||
// generic attributes are always reported as Object java type
|
||||
assertThat( join.getJavaType() ).isEqualTo( Object.class );
|
||||
assertThat( join.getModel() ).isSameAs( root.getModel().getAttribute( "children" ) );
|
||||
assertThat( ( (JpaPath<?>) join ).getResolvedModel().getBindableJavaType() ).isEqualTo( Child.class );
|
||||
assertThat( ( (SqmPath<?>) join ).getResolvedModel().getBindableJavaType() ).isEqualTo( Child.class );
|
||||
final Long result = session.createQuery( query.select( join.get( "id" ) ) ).getSingleResult();
|
||||
assertThat( result ).isEqualTo( 2L );
|
||||
} );
|
||||
|
|
|
@ -8,11 +8,7 @@ package org.hibernate.orm.test.annotations.generics;
|
|||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hibernate.query.criteria.JpaPath;
|
||||
|
||||
import org.hibernate.query.sqm.tree.domain.SqmPath;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.Jira;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
|
@ -23,9 +19,7 @@ import org.junit.jupiter.api.Test;
|
|||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.MappedSuperclass;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.OneToOne;
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.CriteriaQuery;
|
||||
|
@ -87,7 +81,7 @@ public class GenericToOneAssociationTest {
|
|||
// generic attributes are always reported as Object java type
|
||||
assertThat( parent.getJavaType() ).isEqualTo( Object.class );
|
||||
assertThat( parent.getModel() ).isSameAs( root.getModel().getAttribute( "parent" ) );
|
||||
assertThat( ( (JpaPath<?>) parent ).getResolvedModel().getBindableJavaType() ).isEqualTo( Parent.class );
|
||||
assertThat( ( (SqmPath<?>) parent ).getResolvedModel().getBindableJavaType() ).isEqualTo( Parent.class );
|
||||
final Long result = session.createQuery( query.select( parent.get( "id" ) ) ).getSingleResult();
|
||||
assertThat( result ).isEqualTo( 1L );
|
||||
} );
|
||||
|
@ -111,7 +105,7 @@ public class GenericToOneAssociationTest {
|
|||
// generic attributes are always reported as Object java type
|
||||
assertThat( join.getJavaType() ).isEqualTo( Object.class );
|
||||
assertThat( join.getModel() ).isSameAs( root.getModel().getAttribute( "child" ) );
|
||||
assertThat( ( (JpaPath<?>) join ).getResolvedModel().getBindableJavaType() ).isEqualTo( Child.class );
|
||||
assertThat( ( (SqmPath<?>) join ).getResolvedModel().getBindableJavaType() ).isEqualTo( Child.class );
|
||||
final Long result = session.createQuery( query.select( join.get( "id" ) ) ).getSingleResult();
|
||||
assertThat( result ).isEqualTo( 2L );
|
||||
} );
|
||||
|
|
|
@ -10,8 +10,7 @@ import java.io.Serializable;
|
|||
import java.time.LocalDateTime;
|
||||
import java.time.temporal.TemporalAccessor;
|
||||
|
||||
import org.hibernate.query.criteria.JpaPath;
|
||||
|
||||
import org.hibernate.query.sqm.tree.domain.SqmPath;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.Jira;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
|
@ -62,7 +61,7 @@ public class MappedSuperclassTemporalAccessorTest {
|
|||
final Root<TestEntity> root = cq.from( TestEntity.class );
|
||||
final Path<Object> createTime = root.get( "createTime" );
|
||||
assertThat( createTime.getModel() ).isSameAs( root.getModel().getAttribute( "createTime" ) );
|
||||
assertThat( ( (JpaPath<?>) createTime ).getResolvedModel()
|
||||
assertThat( ( (SqmPath<?>) createTime ).getResolvedModel()
|
||||
.getBindableJavaType() ).isEqualTo( LocalDateTime.class );
|
||||
final Object result = session.createQuery( cq.select( createTime ) ).getSingleResult();
|
||||
assertThat( result ).isEqualTo( LocalDateTime.of( 2023, 6, 16, 11, 41 ) );
|
||||
|
@ -77,7 +76,7 @@ public class MappedSuperclassTemporalAccessorTest {
|
|||
final Root<TestEntity> root = cq.from( TestEntity.class );
|
||||
final Path<Object> id = root.get( "id" );
|
||||
assertThat( id.getModel() ).isSameAs( root.getModel().getAttribute( "id" ) );
|
||||
assertThat( ( (JpaPath<?>) id ).getResolvedModel()
|
||||
assertThat( ( (SqmPath<?>) id ).getResolvedModel()
|
||||
.getBindableJavaType() ).isEqualTo( Long.class );
|
||||
final Object result = session.createQuery( cq.select( id ) ).getSingleResult();
|
||||
assertThat( result ).isEqualTo( 1L );
|
||||
|
@ -92,7 +91,7 @@ public class MappedSuperclassTemporalAccessorTest {
|
|||
final Root<TestEntity> root = cq.from( TestEntity.class );
|
||||
final Path<Object> createUser = root.get( "createUser" );
|
||||
assertThat( createUser.getModel() ).isSameAs( root.getModel().getAttribute( "createUser" ) );
|
||||
assertThat( ( (JpaPath<?>) createUser ).getResolvedModel()
|
||||
assertThat( ( (SqmPath<?>) createUser ).getResolvedModel()
|
||||
.getBindableJavaType() ).isEqualTo( String.class );
|
||||
final Object result = session.createQuery( cq.select( createUser ) ).getSingleResult();
|
||||
assertThat( result ).isEqualTo( "Marco" );
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
*/
|
||||
package org.hibernate.orm.test.annotations.generics;
|
||||
|
||||
import org.hibernate.query.criteria.JpaPath;
|
||||
|
||||
import org.hibernate.query.sqm.tree.domain.SqmPath;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.Jira;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
|
@ -77,12 +76,12 @@ public class MultipleEmbeddedGenericsTest {
|
|||
final Path<CustomerEmbeddableOne> firstEmbedded = root.get( "firstEmbedded" );
|
||||
assertThat( firstEmbedded.getJavaType() ).isEqualTo( GenericEmbeddableOne.class );
|
||||
assertThat( firstEmbedded.getModel() ).isSameAs( root.getModel().getAttribute( "firstEmbedded" ) );
|
||||
assertThat( ( (JpaPath<?>) firstEmbedded ).getResolvedModel().getBindableJavaType() )
|
||||
assertThat( ( (SqmPath<?>) firstEmbedded ).getResolvedModel().getBindableJavaType() )
|
||||
.isEqualTo( CustomerEmbeddableOne.class );
|
||||
final Path<CustomerEmbeddableTwo> secondEmbedded = root.get( "secondEmbedded" );
|
||||
assertThat( secondEmbedded.getJavaType() ).isEqualTo( GenericEmbeddableTwo.class );
|
||||
assertThat( secondEmbedded.getModel() ).isSameAs( root.getModel().getAttribute( "secondEmbedded" ) );
|
||||
assertThat( ( (JpaPath<?>) secondEmbedded ).getResolvedModel().getBindableJavaType() )
|
||||
assertThat( ( (SqmPath<?>) secondEmbedded ).getResolvedModel().getBindableJavaType() )
|
||||
.isEqualTo( CustomerEmbeddableTwo.class );
|
||||
query.select( root ).where( cb.and(
|
||||
cb.equal( firstEmbedded.get( "genericPropertyA" ), "1" ),
|
||||
|
@ -113,12 +112,12 @@ public class MultipleEmbeddedGenericsTest {
|
|||
final Path<InvoiceEmbeddableOne> firstEmbedded = root.get( "firstEmbedded" );
|
||||
assertThat( firstEmbedded.getJavaType() ).isEqualTo( GenericEmbeddableOne.class );
|
||||
assertThat( firstEmbedded.getModel() ).isSameAs( root.getModel().getAttribute( "firstEmbedded" ) );
|
||||
assertThat( ( (JpaPath<?>) firstEmbedded ).getResolvedModel().getBindableJavaType() )
|
||||
assertThat( ( (SqmPath<?>) firstEmbedded ).getResolvedModel().getBindableJavaType() )
|
||||
.isEqualTo( InvoiceEmbeddableOne.class );
|
||||
final Path<InvoiceEmbeddableTwo> secondEmbedded = root.get( "secondEmbedded" );
|
||||
assertThat( secondEmbedded.getJavaType() ).isEqualTo( GenericEmbeddableTwo.class );
|
||||
assertThat( secondEmbedded.getModel() ).isSameAs( root.getModel().getAttribute( "secondEmbedded" ) );
|
||||
assertThat( ( (JpaPath<?>) secondEmbedded ).getResolvedModel().getBindableJavaType() )
|
||||
assertThat( ( (SqmPath<?>) secondEmbedded ).getResolvedModel().getBindableJavaType() )
|
||||
.isEqualTo( InvoiceEmbeddableTwo.class );
|
||||
query.select( root ).where( cb.and(
|
||||
cb.equal( firstEmbedded.get( "invoicePropertyA" ), 1 ),
|
||||
|
|
Loading…
Reference in New Issue