HHH-17377 - Migrate to JPA 3.2
https://hibernate.atlassian.net/browse/HHH-17377 Test compilation success!! 95 test failures next
This commit is contained in:
parent
3495461a9c
commit
86584dfffd
|
@ -163,8 +163,11 @@ public interface QueryProducer {
|
|||
* @return The {@link NativeQuery} instance for manipulation and execution
|
||||
*
|
||||
* @see jakarta.persistence.EntityManager#createNativeQuery(String,Class)
|
||||
*
|
||||
* @apiNote Changes in JPA 3.2 required de-typing this to be compilable with their changes
|
||||
*/
|
||||
NativeQuery<?> createNativeQuery(String sqlString, Class<?> resultClass);
|
||||
@SuppressWarnings("rawtypes")
|
||||
NativeQuery createNativeQuery(String sqlString, Class<?> resultClass);
|
||||
|
||||
/**
|
||||
* Create a {@link NativeQuery} instance for the given native SQL query
|
||||
|
|
|
@ -287,6 +287,21 @@ public abstract class CriteriaDefinition<R>
|
|||
return query.getRestriction();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JpaCriteriaQuery<R> where(List<Predicate> restrictions) {
|
||||
return query.where( restrictions );
|
||||
}
|
||||
|
||||
@Override
|
||||
public JpaCriteriaQuery<R> having(List<Predicate> restrictions) {
|
||||
return query.having( restrictions );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <U> JpaSubQuery<U> subquery(EntityType<U> type) {
|
||||
return query.subquery( type );
|
||||
}
|
||||
|
||||
@Override
|
||||
public JpaExpression<Number> getOffset() {
|
||||
return query.getOffset();
|
||||
|
|
|
@ -42,6 +42,7 @@ import jakarta.persistence.criteria.Root;
|
|||
import jakarta.persistence.criteria.Selection;
|
||||
import jakarta.persistence.criteria.SetJoin;
|
||||
import jakarta.persistence.criteria.Subquery;
|
||||
import jakarta.persistence.criteria.TemporalField;
|
||||
|
||||
/**
|
||||
* A JPA {@link CriteriaBuilder} is a source of objects which may be composed
|
||||
|
@ -179,12 +180,26 @@ public interface HibernateCriteriaBuilder extends CriteriaBuilder {
|
|||
return union( true, query1, queries );
|
||||
}
|
||||
|
||||
@Override
|
||||
<T> JpaCriteriaQuery<T> union(CriteriaQuery<? extends T> left, CriteriaQuery<? extends T> right);
|
||||
|
||||
@Override
|
||||
default <T> JpaCriteriaQuery<T> unionAll(CriteriaQuery<? extends T> left, CriteriaQuery<? extends T> right) {
|
||||
return null;
|
||||
}
|
||||
|
||||
default <T> JpaSubQuery<T> union(Subquery<? extends T> query1, Subquery<?>... queries) {
|
||||
return union( false, query1, queries );
|
||||
}
|
||||
|
||||
<T> JpaSubQuery<T> union(boolean all, Subquery<? extends T> query1, Subquery<?>... queries);
|
||||
|
||||
@Override
|
||||
<T> JpaCriteriaQuery<T> intersect(CriteriaQuery<? super T> left, CriteriaQuery<? super T> right);
|
||||
|
||||
@Override
|
||||
<T> JpaCriteriaQuery<T> intersectAll(CriteriaQuery<? super T> left, CriteriaQuery<? super T> right);
|
||||
|
||||
default <T> JpaSubQuery<T> intersectAll(Subquery<? extends T> query1, Subquery<?>... queries) {
|
||||
return intersect( true, query1, queries );
|
||||
}
|
||||
|
@ -195,6 +210,12 @@ public interface HibernateCriteriaBuilder extends CriteriaBuilder {
|
|||
|
||||
<T> JpaSubQuery<T> intersect(boolean all, Subquery<? extends T> query1, Subquery<?>... queries);
|
||||
|
||||
@Override
|
||||
<T> JpaCriteriaQuery<T> except(CriteriaQuery<T> left, CriteriaQuery<?> right);
|
||||
|
||||
@Override
|
||||
<T> JpaCriteriaQuery<T> exceptAll(CriteriaQuery<T> left, CriteriaQuery<?> right);
|
||||
|
||||
default <T> JpaSubQuery<T> exceptAll(Subquery<? extends T> query1, Subquery<?>... queries) {
|
||||
return except( true, query1, queries );
|
||||
}
|
||||
|
@ -3611,4 +3632,17 @@ public interface HibernateCriteriaBuilder extends CriteriaBuilder {
|
|||
*/
|
||||
@Incubating
|
||||
<E> JpaPredicate collectionIntersectsNullable(Collection<E> collection1, Expression<? extends Collection<? extends E>> collectionExpression2);
|
||||
|
||||
|
||||
@Override
|
||||
JpaPredicate and(List<Predicate> restrictions);
|
||||
|
||||
@Override
|
||||
JpaPredicate or(List<Predicate> restrictions);
|
||||
|
||||
@Override
|
||||
JpaExpression<String> concat(List<Expression<String>> expressions);
|
||||
|
||||
@Override
|
||||
<N, T extends Temporal> JpaExpression<N> extract(TemporalField<N, T> field, Expression<T> temporal);
|
||||
}
|
||||
|
|
|
@ -8,6 +8,9 @@ package org.hibernate.query.criteria;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hibernate.query.sqm.FetchClauseType;
|
||||
|
||||
import jakarta.persistence.criteria.CriteriaQuery;
|
||||
import jakarta.persistence.criteria.Expression;
|
||||
import jakarta.persistence.criteria.Order;
|
||||
|
@ -17,8 +20,6 @@ import jakarta.persistence.criteria.Root;
|
|||
import jakarta.persistence.criteria.Selection;
|
||||
import jakarta.persistence.metamodel.EntityType;
|
||||
|
||||
import org.hibernate.query.sqm.FetchClauseType;
|
||||
|
||||
/**
|
||||
* Extension of the JPA {@link CriteriaQuery}
|
||||
*
|
||||
|
@ -107,6 +108,9 @@ public interface JpaCriteriaQuery<T> extends CriteriaQuery<T>, JpaQueryableCrite
|
|||
@Override
|
||||
JpaCriteriaQuery<T> where(Predicate... restrictions);
|
||||
|
||||
@Override
|
||||
JpaCriteriaQuery<T> where(List<Predicate> restrictions);
|
||||
|
||||
@Override
|
||||
JpaCriteriaQuery<T> groupBy(Expression<?>... grouping);
|
||||
|
||||
|
@ -119,9 +123,15 @@ public interface JpaCriteriaQuery<T> extends CriteriaQuery<T>, JpaQueryableCrite
|
|||
@Override
|
||||
JpaCriteriaQuery<T> having(Predicate... restrictions);
|
||||
|
||||
@Override
|
||||
JpaCriteriaQuery<T> having(List<Predicate> restrictions);
|
||||
|
||||
@Override
|
||||
JpaCriteriaQuery<T> orderBy(Order... o);
|
||||
|
||||
@Override
|
||||
JpaCriteriaQuery<T> orderBy(List<Order> o);
|
||||
|
||||
@Override
|
||||
<U> JpaSubQuery<U> subquery(EntityType<U> type);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,11 @@ public interface JpaFrom<O,T> extends JpaPath<T>, JpaFetchParent<O,T>, From<O,T>
|
|||
<Y> JpaEntityJoin<T, Y> join(Class<Y> entityClass);
|
||||
|
||||
@Override
|
||||
<Y> JpaJoin<T, Y> join(Class<Y> entityClass, JoinType joinType);
|
||||
<Y> JpaEntityJoin<T, Y> join(Class<Y> entityClass, JoinType joinType);
|
||||
|
||||
default <X> JpaEntityJoin<T, X> join(Class<X> entityJavaType, SqmJoinType joinType) {
|
||||
return join( entityJavaType, joinType.getCorrespondingJpaJoinType() );
|
||||
}
|
||||
|
||||
@Override
|
||||
<Y> JpaJoin<T, Y> join(EntityType<Y> entity);
|
||||
|
@ -41,15 +45,9 @@ public interface JpaFrom<O,T> extends JpaPath<T>, JpaFetchParent<O,T>, From<O,T>
|
|||
@Override
|
||||
<Y> JpaJoin<T, Y> join(EntityType<Y> entity, JoinType joinType);
|
||||
|
||||
//
|
||||
// @Override
|
||||
// <Y> JpaEntityJoin<Y> join(Class<Y> entityClass);
|
||||
//
|
||||
// <X> JpaEntityJoin<X> join(EntityDomainType<X> entity);
|
||||
//
|
||||
// <X> JpaEntityJoin<X> join(Class<X> entityJavaType, SqmJoinType joinType);
|
||||
//
|
||||
// <X> JpaEntityJoin<X> join(EntityDomainType<X> entity, SqmJoinType joinType);
|
||||
<X> JpaEntityJoin<T,X> join(EntityDomainType<X> entity);
|
||||
|
||||
<X> JpaEntityJoin<T,X> join(EntityDomainType<X> entity, SqmJoinType joinType);
|
||||
|
||||
@Incubating
|
||||
<X> JpaDerivedJoin<X> join(Subquery<X> subquery);
|
||||
|
|
|
@ -256,6 +256,8 @@ public class HibernateCriteriaBuilderDelegate implements HibernateCriteriaBuilde
|
|||
return criteriaBuilder.except( all, query1, queries );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public JpaExpression<Integer> sign(Expression<? extends Number> x) {
|
||||
return criteriaBuilder.sign( x );
|
||||
|
@ -317,7 +319,7 @@ public class HibernateCriteriaBuilderDelegate implements HibernateCriteriaBuilde
|
|||
}
|
||||
|
||||
@Override
|
||||
public <N, T extends Temporal> Expression<N> extract(TemporalField<N, T> field, Expression<T> temporal) {
|
||||
public <N, T extends Temporal> JpaExpression<N> extract(TemporalField<N, T> field, Expression<T> temporal) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -337,32 +339,32 @@ public class HibernateCriteriaBuilderDelegate implements HibernateCriteriaBuilde
|
|||
}
|
||||
|
||||
@Override
|
||||
public <T> CriteriaQuery<T> union(CriteriaQuery<? extends T> left, CriteriaQuery<? extends T> right) {
|
||||
public <T> JpaCriteriaQuery<T> union(CriteriaQuery<? extends T> left, CriteriaQuery<? extends T> right) {
|
||||
return criteriaBuilder.union( left, right );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> CriteriaQuery<T> unionAll(CriteriaQuery<? extends T> left, CriteriaQuery<? extends T> right) {
|
||||
public <T> JpaCriteriaQuery<T> unionAll(CriteriaQuery<? extends T> left, CriteriaQuery<? extends T> right) {
|
||||
return criteriaBuilder.unionAll( left, right );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> CriteriaQuery<T> intersect(CriteriaQuery<? super T> left, CriteriaQuery<? super T> right) {
|
||||
public <T> JpaCriteriaQuery<T> intersect(CriteriaQuery<? super T> left, CriteriaQuery<? super T> right) {
|
||||
return criteriaBuilder.intersect( left, right );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> CriteriaQuery<T> intersectAll(CriteriaQuery<? super T> left, CriteriaQuery<? super T> right) {
|
||||
public <T> JpaCriteriaQuery<T> intersectAll(CriteriaQuery<? super T> left, CriteriaQuery<? super T> right) {
|
||||
return criteriaBuilder.intersectAll( left, right );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> CriteriaQuery<T> except(CriteriaQuery<T> left, CriteriaQuery<?> right) {
|
||||
public <T> JpaCriteriaQuery<T> except(CriteriaQuery<T> left, CriteriaQuery<?> right) {
|
||||
return criteriaBuilder.except( left, right );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> CriteriaQuery<T> exceptAll(CriteriaQuery<T> left, CriteriaQuery<?> right) {
|
||||
public <T> JpaCriteriaQuery<T> exceptAll(CriteriaQuery<T> left, CriteriaQuery<?> right) {
|
||||
return criteriaBuilder.exceptAll( left, right );
|
||||
}
|
||||
|
||||
|
@ -862,7 +864,7 @@ public class HibernateCriteriaBuilderDelegate implements HibernateCriteriaBuilde
|
|||
}
|
||||
|
||||
@Override
|
||||
public Predicate and(List<Predicate> restrictions) {
|
||||
public JpaPredicate and(List<Predicate> restrictions) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -877,7 +879,7 @@ public class HibernateCriteriaBuilderDelegate implements HibernateCriteriaBuilde
|
|||
}
|
||||
|
||||
@Override
|
||||
public Predicate or(List<Predicate> restrictions) {
|
||||
public JpaPredicate or(List<Predicate> restrictions) {
|
||||
return criteriaBuilder.or( restrictions );
|
||||
}
|
||||
|
||||
|
@ -1178,7 +1180,7 @@ public class HibernateCriteriaBuilderDelegate implements HibernateCriteriaBuilde
|
|||
}
|
||||
|
||||
@Override
|
||||
public Expression<String> concat(List<Expression<String>> expressions) {
|
||||
public JpaExpression<String> concat(List<Expression<String>> expressions) {
|
||||
return criteriaBuilder.concat( expressions );
|
||||
}
|
||||
|
||||
|
|
|
@ -47,8 +47,9 @@ public interface QueryProducerImplementor extends QueryProducer {
|
|||
@Override @Deprecated @SuppressWarnings("rawtypes")
|
||||
NativeQueryImplementor createNativeQuery(String sqlString);
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
NativeQueryImplementor<?> createNativeQuery(String sqlString, Class<?> resultClass);
|
||||
NativeQueryImplementor createNativeQuery(String sqlString, Class<?> resultClass);
|
||||
|
||||
@Override
|
||||
<R> NativeQueryImplementor<R> createNativeQuery(String sqlString, Class<R> resultClass, String tableAlias);
|
||||
|
|
|
@ -548,37 +548,37 @@ public class SqmCriteriaNodeBuilder implements NodeBuilder, SqmCreationContext,
|
|||
}
|
||||
|
||||
@Override
|
||||
public <T> CriteriaQuery<T> union(CriteriaQuery<? extends T> left, CriteriaQuery<? extends T> right) {
|
||||
public <T> JpaCriteriaQuery<T> union(CriteriaQuery<? extends T> left, CriteriaQuery<? extends T> right) {
|
||||
// todo (jpa 3.2) : implement
|
||||
throw new UnsupportedOperationException( "Not yet implemented" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> CriteriaQuery<T> unionAll(CriteriaQuery<? extends T> left, CriteriaQuery<? extends T> right) {
|
||||
public <T> JpaCriteriaQuery<T> unionAll(CriteriaQuery<? extends T> left, CriteriaQuery<? extends T> right) {
|
||||
// todo (jpa 3.2) : implement
|
||||
throw new UnsupportedOperationException( "Not yet implemented" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> CriteriaQuery<T> intersect(CriteriaQuery<? super T> left, CriteriaQuery<? super T> right) {
|
||||
public <T> JpaCriteriaQuery<T> intersect(CriteriaQuery<? super T> left, CriteriaQuery<? super T> right) {
|
||||
// todo (jpa 3.2) : implement
|
||||
throw new UnsupportedOperationException( "Not yet implemented" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> CriteriaQuery<T> intersectAll(CriteriaQuery<? super T> left, CriteriaQuery<? super T> right) {
|
||||
public <T> JpaCriteriaQuery<T> intersectAll(CriteriaQuery<? super T> left, CriteriaQuery<? super T> right) {
|
||||
// todo (jpa 3.2) : implement
|
||||
throw new UnsupportedOperationException( "Not yet implemented" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> CriteriaQuery<T> except(CriteriaQuery<T> left, CriteriaQuery<?> right) {
|
||||
public <T> JpaCriteriaQuery<T> except(CriteriaQuery<T> left, CriteriaQuery<?> right) {
|
||||
// todo (jpa 3.2) : implement
|
||||
throw new UnsupportedOperationException( "Not yet implemented" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> CriteriaQuery<T> exceptAll(CriteriaQuery<T> left, CriteriaQuery<?> right) {
|
||||
public <T> JpaCriteriaQuery<T> exceptAll(CriteriaQuery<T> left, CriteriaQuery<?> right) {
|
||||
// todo (jpa 3.2) : implement
|
||||
throw new UnsupportedOperationException( "Not yet implemented" );
|
||||
}
|
||||
|
@ -1800,7 +1800,7 @@ public class SqmCriteriaNodeBuilder implements NodeBuilder, SqmCreationContext,
|
|||
}
|
||||
|
||||
@Override
|
||||
public <N, T extends Temporal> Expression<N> extract(TemporalField<N, T> field, Expression<T> temporal) {
|
||||
public <N, T extends Temporal> SqmExpression<N> extract(TemporalField<N, T> field, Expression<T> temporal) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -2124,7 +2124,7 @@ public class SqmCriteriaNodeBuilder implements NodeBuilder, SqmCreationContext,
|
|||
}
|
||||
|
||||
@Override
|
||||
public Predicate and(List<Predicate> restrictions) {
|
||||
public SqmPredicate and(List<Predicate> restrictions) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -2152,7 +2152,7 @@ public class SqmCriteriaNodeBuilder implements NodeBuilder, SqmCreationContext,
|
|||
}
|
||||
|
||||
@Override
|
||||
public Predicate or(List<Predicate> restrictions) {
|
||||
public SqmPredicate or(List<Predicate> restrictions) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -2679,7 +2679,7 @@ public class SqmCriteriaNodeBuilder implements NodeBuilder, SqmCreationContext,
|
|||
}
|
||||
|
||||
@Override
|
||||
public Expression<String> concat(List<Expression<String>> expressions) {
|
||||
public SqmExpression<String> concat(List<Expression<String>> expressions) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -200,43 +200,6 @@ public abstract class AbstractSqmFrom<O,T> extends AbstractSqmPath<T> implements
|
|||
return sqmPath;
|
||||
}
|
||||
|
||||
// private ModelPartContainer findModelPartContainer(SqmAttributeJoin<?, ?> attributeJoin, SqmCreationState creationState) {
|
||||
// final SqmFrom<?, ?> lhs = attributeJoin.getLhs();
|
||||
// if ( lhs instanceof SqmAttributeJoin<?, ?> ) {
|
||||
// final SqmAttributeJoin<?, ?> lhsAttributeJoin = (SqmAttributeJoin<?, ?>) lhs;
|
||||
// if ( lhsAttributeJoin.getReferencedPathSource() instanceof EntityDomainType<?> ) {
|
||||
// final String entityName = ( (EntityDomainType<?>) lhsAttributeJoin.getReferencedPathSource() ).getHibernateEntityName();
|
||||
// return (ModelPartContainer) creationState.getCreationContext()
|
||||
// .getJpaMetamodel()
|
||||
// .getMappingMetamodel()
|
||||
// .getEntityDescriptor( entityName )
|
||||
// .findSubPart( attributeJoin.getAttribute().getName(), null );
|
||||
// }
|
||||
// else {
|
||||
// return (ModelPartContainer) findModelPartContainer( lhsAttributeJoin, creationState )
|
||||
// .findSubPart( attributeJoin.getAttribute().getName(), null );
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// final String entityName;
|
||||
// if ( lhs instanceof SqmRoot<?> ) {
|
||||
// entityName = ( (SqmRoot<?>) lhs ).getEntityName();
|
||||
// }
|
||||
// else if ( lhs instanceof SqmEntityJoin<?,?> ) {
|
||||
// entityName = ( (SqmEntityJoin<?,?>) lhs ).getEntityName();
|
||||
// }
|
||||
// else {
|
||||
// assert lhs instanceof SqmCrossJoin<?>;
|
||||
// entityName = ( (SqmCrossJoin<?>) lhs ).getEntityName();
|
||||
// }
|
||||
// return (ModelPartContainer) creationState.getCreationContext()
|
||||
// .getJpaMetamodel()
|
||||
// .getMappingMetamodel()
|
||||
// .getEntityDescriptor( entityName )
|
||||
// .findSubPart( attributeJoin.getAttribute().getName(), null );
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public boolean hasJoins() {
|
||||
return joins != null && !joins.isEmpty();
|
||||
|
@ -354,6 +317,30 @@ public abstract class AbstractSqmFrom<O,T> extends AbstractSqmPath<T> implements
|
|||
return join;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <X> SqmEntityJoin<T, X> join(Class<X> targetEntityClass, SqmJoinType joinType) {
|
||||
return join( nodeBuilder().getJpaMetamodel().entity( targetEntityClass ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <X> SqmEntityJoin<T, X> join(EntityDomainType<X> targetEntityDescriptor) {
|
||||
return join( targetEntityDescriptor, SqmJoinType.INNER );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <X> SqmEntityJoin<T, X> join(EntityDomainType<X> targetEntityDescriptor, SqmJoinType joinType) {
|
||||
//noinspection unchecked
|
||||
final SqmRoot<T> root = (SqmRoot<T>) findRoot();
|
||||
final SqmEntityJoin<T, X> sqmEntityJoin = new SqmEntityJoin<>(
|
||||
targetEntityDescriptor,
|
||||
null,
|
||||
joinType,
|
||||
root
|
||||
);
|
||||
root.addSqmJoin( sqmEntityJoin );
|
||||
return sqmEntityJoin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <A> SqmBagJoin<T, A> join(CollectionAttribute<? super T, A> attribute) {
|
||||
return join( attribute, JoinType.INNER );
|
||||
|
|
|
@ -279,14 +279,14 @@ public class SqmSelectStatement<T> extends AbstractSqmSelectQuery<T> implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public CriteriaQuery<T> where(List<Predicate> restrictions) {
|
||||
public SqmSelectStatement<T> where(List<Predicate> restrictions) {
|
||||
//noinspection rawtypes,unchecked
|
||||
getQuerySpec().getWhereClause().applyPredicates( (List) restrictions );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CriteriaQuery<T> having(List<Predicate> restrictions) {
|
||||
public SqmSelectStatement<T> having(List<Predicate> restrictions) {
|
||||
//noinspection unchecked,rawtypes
|
||||
final SqmPredicate combined = combinePredicates( getQuerySpec().getHavingClausePredicate(), (List) restrictions );
|
||||
getQuerySpec().setHavingClausePredicate( combined );
|
||||
|
|
|
@ -91,7 +91,7 @@ public class AnyTest extends BaseCoreFunctionalTestCase {
|
|||
final PropertyHolder2 propertyHolder = session.get( PropertyHolder2.class, 2L );
|
||||
assertEquals( "name2", propertyHolder.getProperty().getName() );
|
||||
assertEquals( "Mario Rossi", propertyHolder.getProperty().getValue() );
|
||||
final String propertyType = session.createNativeQuery(
|
||||
final String propertyType = (String) session.createNativeQuery(
|
||||
"select property_type from property_holder2",
|
||||
String.class
|
||||
).getSingleResult();
|
||||
|
|
|
@ -109,7 +109,7 @@ public class CompositeUserTypeTest {
|
|||
session.persist( f );
|
||||
session.flush();
|
||||
// Test value conversion during insert
|
||||
BigDecimal amountViaSql = session.createNativeQuery(
|
||||
BigDecimal amountViaSql = (BigDecimal) session.createNativeQuery(
|
||||
"select amount_millions from MutualFund", BigDecimal.class )
|
||||
.uniqueResult();
|
||||
assertEquals( AMOUNT_MILLIONS.doubleValue(), amountViaSql.doubleValue(), 0.01d );
|
||||
|
|
|
@ -206,7 +206,7 @@ public class EntityGraphParserTest extends AbstractEntityGraphTest {
|
|||
|
||||
assertEquals( subGraph.getGraphedType().getJavaType(), GraphParsingTestSubEntity.class );
|
||||
|
||||
final AttributeNodeImplementor<Object> subTypeAttrNode = subGraph.addAttributeNode( "sub" );
|
||||
final AttributeNodeImplementor<Object> subTypeAttrNode = subGraph.findOrCreateAttributeNode( "sub" );
|
||||
assert subTypeAttrNode != null;
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ public class JoinedSubclassNativeQueryTest {
|
|||
// PostgreSQLDialect#getSelectClauseNullString produces e.g. `null::text` which we interpret as parameter,
|
||||
// so workaround this problem by configuring to ignore JDBC parameters
|
||||
session.setProperty( AvailableSettings.NATIVE_IGNORE_JDBC_PARAMETERS, true );
|
||||
Person p = session.createNativeQuery( "select p.*, " + nullColumnString + " as company_name, 0 as clazz_ from Person p", Person.class ).getSingleResult();
|
||||
Person p = (Person) session.createNativeQuery( "select p.*, " + nullColumnString + " as company_name, 0 as clazz_ from Person p", Person.class ).getSingleResult();
|
||||
Assertions.assertNotNull( p );
|
||||
Assertions.assertEquals( p.getFirstName(), "Jan" );
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ public class CriteriaQualifiedJoinTest {
|
|||
final HibernateCriteriaBuilder cb = entityManager.unwrap( Session.class ).getCriteriaBuilder();
|
||||
final JpaCriteriaQuery<Tuple> query = cb.createTupleQuery();
|
||||
final JpaRoot<Primary> root = query.from( Primary.class );
|
||||
final JpaEntityJoin<Secondary> entityJoin = root.join( Secondary.class, SqmJoinType.INNER );
|
||||
final JpaEntityJoin<Primary,Secondary> entityJoin = root.join( Secondary.class, SqmJoinType.INNER );
|
||||
final JpaPath<Integer> id = root.get( "id" );
|
||||
entityJoin.on( cb.equal( id, entityJoin.get( "id" ) ) );
|
||||
final JpaPath<String> name = entityJoin.get( "name" );
|
||||
|
|
|
@ -46,7 +46,7 @@ public class EntityHidingTests {
|
|||
final SessionFactoryImplementor sessionFactory = scope.getSessionFactory();
|
||||
final RuntimeMetamodels runtimeMetamodels = sessionFactory.getRuntimeMetamodels();
|
||||
|
||||
final EntityDomainType<Object> jpaModelDescriptor = runtimeMetamodels.getJpaMetamodel().entity( "DynamicEntity" );
|
||||
final EntityDomainType<?> jpaModelDescriptor = runtimeMetamodels.getJpaMetamodel().entity( "DynamicEntity" );
|
||||
assertThat( jpaModelDescriptor, nullValue() );
|
||||
|
||||
final EntityPersister mappingModelDescriptor = runtimeMetamodels.getMappingMetamodel()
|
||||
|
|
|
@ -282,7 +282,7 @@ public class HANAStoredProcedureTest {
|
|||
@JiraKey( "HHH-12138")
|
||||
public void testStoredProcedureReturnValue(SessionFactoryScope scope) {
|
||||
scope.inTransaction( (session) -> {
|
||||
Integer phoneCount = session
|
||||
Integer phoneCount = (Integer) session
|
||||
.createNativeQuery( "SELECT fn_count_phones(:personId) FROM SYS.DUMMY", Integer.class )
|
||||
.setParameter( "personId", 1 )
|
||||
.getSingleResult();
|
||||
|
|
|
@ -528,7 +528,7 @@ public class CteTests {
|
|||
selfType -> {
|
||||
final JpaCriteriaQuery<Tuple> recursiveQuery = cb.createTupleQuery();
|
||||
final JpaRoot<Tuple> recursiveRoot = recursiveQuery.from( selfType );
|
||||
final JpaEntityJoin<Contact> contact = recursiveRoot.join( Contact.class );
|
||||
final JpaEntityJoin<Tuple,Contact> contact = recursiveRoot.join( Contact.class );
|
||||
contact.on( cb.equal( recursiveRoot.get( "altId" ), contact.get( "id" ) ) );
|
||||
recursiveQuery.multiselect(
|
||||
contact.get( "id" ).alias( "id" ),
|
||||
|
@ -545,7 +545,7 @@ public class CteTests {
|
|||
);
|
||||
|
||||
final JpaRoot<Tuple> root = cq.from( alternativeContacts );
|
||||
final JpaEntityJoin<Contact> alt = root.join( Contact.class );
|
||||
final JpaEntityJoin<Tuple,Contact> alt = root.join( Contact.class );
|
||||
alt.on( cb.equal( root.get( "id" ), alt.get( "id" ) ) );
|
||||
cq.multiselect( alt );
|
||||
cq.orderBy( cb.asc( root.get( "orderAttr" ) ) );
|
||||
|
|
|
@ -19,7 +19,7 @@ import static org.junit.jupiter.api.Assertions.assertInstanceOf;
|
|||
public class OracleNumericTypesTest {
|
||||
@Test void test(SessionFactoryScope scope) {
|
||||
String sql = "SELECT 012345678901234567890123456789, cast(1234567890123.456 as number(30,5)), cast(1234567890123.456 as double precision), cast(1234567890123.456 as float(32)), cast(1234567890123.456 as float(24)) from dual";
|
||||
Object[] values = scope.fromSession( s -> s.createNativeQuery(sql, Object[].class).getSingleResult());
|
||||
Object[] values = (Object[]) scope.fromSession( s -> s.createNativeQuery( sql, Object[].class).getSingleResult());
|
||||
assertInstanceOf(BigDecimal.class, values[0]);
|
||||
assertInstanceOf(BigDecimal.class, values[1]);
|
||||
assertInstanceOf(BigDecimal.class, values[2]);
|
||||
|
|
|
@ -55,7 +55,7 @@ public class ImplicitInstantiationTest {
|
|||
scope.inTransaction(
|
||||
session -> {
|
||||
session.persist(new Thing(1L, "thing"));
|
||||
Record result = session.createNativeQuery("select id, upper(name) as name from thingy_table", Record.class)
|
||||
Record result = (Record) session.createNativeQuery( "select id, upper(name) as name from thingy_table", Record.class)
|
||||
.addSynchronizedEntityClass(Thing.class)
|
||||
.getSingleResult();
|
||||
assertEquals( result.id(), 1L );
|
||||
|
@ -148,7 +148,7 @@ public class ImplicitInstantiationTest {
|
|||
scope.inTransaction(
|
||||
session -> {
|
||||
session.persist(new Thing(1L, "thing"));
|
||||
Tuple result = session.createNativeQuery("select id as id, upper(name) as name from thingy_table", Tuple.class)
|
||||
Tuple result = (Tuple) session.createNativeQuery( "select id as id, upper(name) as name from thingy_table", Tuple.class)
|
||||
.addSynchronizedEntityClass(Thing.class)
|
||||
.getSingleResult();
|
||||
assertEquals( result.get("id"), 1L );
|
||||
|
@ -163,7 +163,7 @@ public class ImplicitInstantiationTest {
|
|||
scope.inTransaction(
|
||||
session -> {
|
||||
session.persist(new Thing(1L, "thing"));
|
||||
Map result = session.createNativeQuery("select id as id, upper(name) as name from thingy_table", Map.class)
|
||||
Map result = (Map) session.createNativeQuery( "select id as id, upper(name) as name from thingy_table", Map.class)
|
||||
.addSynchronizedEntityClass(Thing.class)
|
||||
.getSingleResult();
|
||||
assertEquals( result.get("id"), 1L );
|
||||
|
@ -178,7 +178,7 @@ public class ImplicitInstantiationTest {
|
|||
scope.inTransaction(
|
||||
session -> {
|
||||
session.persist(new Thing(1L, "thing"));
|
||||
List result = session.createNativeQuery("select id, upper(name) as name from thingy_table", List.class)
|
||||
List result = (List) session.createNativeQuery( "select id, upper(name) as name from thingy_table", List.class)
|
||||
.addSynchronizedEntityClass(Thing.class)
|
||||
.getSingleResult();
|
||||
assertEquals( result.get(0), 1L );
|
||||
|
|
|
@ -81,7 +81,7 @@ public class NativeQueryEagerAssociationTest {
|
|||
@Test
|
||||
@Jira( "https://hibernate.atlassian.net/browse/HHH-16191" )
|
||||
public void testNativeQuery(SessionFactoryScope scope) {
|
||||
final Classroom result = scope.fromTransaction(
|
||||
final Classroom result = (Classroom) scope.fromTransaction(
|
||||
session -> session.createNativeQuery( "select * from Classroom where id = 1", Classroom.class )
|
||||
.getSingleResult()
|
||||
);
|
||||
|
|
|
@ -82,7 +82,7 @@ public class SecondaryRowTest {
|
|||
|
||||
private static void verifySecondaryRows(String table, int expectedCount, SessionImplementor session) {
|
||||
final String sql = "select count(1) from " + table;
|
||||
final int count = session.createNativeQuery( sql, Integer.class ).getSingleResult();
|
||||
final int count = (int) session.createNativeQuery( sql, Integer.class ).getSingleResult();
|
||||
assertThat( count ).isEqualTo( expectedCount );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import java.util.UUID;
|
|||
|
||||
import org.hibernate.annotations.JdbcTypeCode;
|
||||
import org.hibernate.dialect.H2Dialect;
|
||||
import org.hibernate.query.sql.spi.NativeQueryImplementor;
|
||||
import org.hibernate.type.SqlTypes;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
|
@ -74,7 +75,7 @@ public class H2JsonListTest {
|
|||
.executeUpdate();
|
||||
} );
|
||||
scope.inTransaction( session -> {
|
||||
final Path path = session.createNativeQuery(
|
||||
final Path path = (Path) session.createNativeQuery(
|
||||
"select * from paths_clob where id = 99",
|
||||
Path.class
|
||||
).getSingleResult();
|
||||
|
@ -104,10 +105,11 @@ public class H2JsonListTest {
|
|||
.executeUpdate();
|
||||
} );
|
||||
scope.inTransaction( session -> {
|
||||
final PathClob path = session.createNativeQuery(
|
||||
final NativeQueryImplementor<PathClob> nativeQuery = session.createNativeQuery(
|
||||
"select * from paths_clob where id = 99",
|
||||
PathClob.class
|
||||
).getSingleResult();
|
||||
);
|
||||
final PathClob path = nativeQuery.getSingleResult();
|
||||
assertThat( path ).isNotNull();
|
||||
assertThat( path.getRelativePaths() ).hasSize( 2 );
|
||||
} );
|
||||
|
|
|
@ -47,7 +47,7 @@ public class OptionalTableUpdateTests {
|
|||
private static void verifySecondaryRows(String table, int expectedCount, SessionFactoryScope sfScope) {
|
||||
final String sql = "select count(1) from " + table;
|
||||
sfScope.inTransaction( (session) -> {
|
||||
final int count = session.createNativeQuery( sql, Integer.class ).getSingleResult();
|
||||
final int count = (int) session.createNativeQuery( sql, Integer.class ).getSingleResult();
|
||||
assertThat( count ).isEqualTo( expectedCount );
|
||||
} );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue