HHH-17377 - Migrate to JPA 3.2
https://hibernate.atlassian.net/browse/HHH-17377 JPA 3.2 B02
This commit is contained in:
parent
f8865106c1
commit
ad26e73c44
|
@ -20,7 +20,7 @@ public class ConfigurationEventReader extends AbstractEventReader {
|
|||
public ConfigurationEventReader(XMLEventReader reader, XMLEventFactory xmlEventFactory) {
|
||||
super(
|
||||
ROOT_ELEMENT_NAME,
|
||||
ConfigXsdSupport.configurationXsd(),
|
||||
ConfigXsdSupport.getJPA32(),
|
||||
reader,
|
||||
xmlEventFactory
|
||||
);
|
||||
|
|
|
@ -72,6 +72,7 @@ import jakarta.persistence.LockOption;
|
|||
import jakarta.persistence.RefreshOption;
|
||||
import jakarta.persistence.criteria.CriteriaDelete;
|
||||
import jakarta.persistence.criteria.CriteriaQuery;
|
||||
import jakarta.persistence.criteria.CriteriaSelect;
|
||||
import jakarta.persistence.criteria.CriteriaUpdate;
|
||||
import jakarta.persistence.metamodel.Metamodel;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
@ -507,6 +508,11 @@ public class SessionDelegatorBaseImpl implements SessionImplementor {
|
|||
return delegate.getEntityGraph( graphName );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> QueryImplementor<T> createQuery(CriteriaSelect<T> selectQuery) {
|
||||
return delegate.createQuery( selectQuery );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> List<EntityGraph<? super T>> getEntityGraphs(Class<T> entityClass) {
|
||||
return delegate.getEntityGraphs( entityClass );
|
||||
|
|
|
@ -17,11 +17,14 @@ import org.hibernate.event.spi.PersistContext;
|
|||
import org.hibernate.event.spi.RefreshContext;
|
||||
import org.hibernate.graph.spi.RootGraphImplementor;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.query.spi.QueryImplementor;
|
||||
import org.hibernate.resource.jdbc.spi.JdbcSessionOwner;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinator;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder;
|
||||
import org.hibernate.type.descriptor.WrapperOptions;
|
||||
|
||||
import jakarta.persistence.criteria.CriteriaSelect;
|
||||
|
||||
/**
|
||||
* Defines the "internal contract" between {@link Session} and other parts of Hibernate
|
||||
* including implementors of {@link org.hibernate.type.Type}, {@link EntityPersister},
|
||||
|
@ -77,6 +80,9 @@ public interface SessionImplementor extends Session, SharedSessionContractImplem
|
|||
@Override
|
||||
RootGraphImplementor<?> getEntityGraph(String graphName);
|
||||
|
||||
@Override
|
||||
<T> QueryImplementor<T> createQuery(CriteriaSelect<T> selectQuery);
|
||||
|
||||
/**
|
||||
* Get the {@link ActionQueue} associated with this session.
|
||||
*/
|
||||
|
|
|
@ -53,8 +53,10 @@ import jakarta.persistence.FlushModeType;
|
|||
import jakarta.persistence.LockModeType;
|
||||
import jakarta.persistence.LockOption;
|
||||
import jakarta.persistence.RefreshOption;
|
||||
import jakarta.persistence.TypedQuery;
|
||||
import jakarta.persistence.criteria.CriteriaDelete;
|
||||
import jakarta.persistence.criteria.CriteriaQuery;
|
||||
import jakarta.persistence.criteria.CriteriaSelect;
|
||||
import jakarta.persistence.criteria.CriteriaUpdate;
|
||||
import jakarta.persistence.metamodel.Metamodel;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
@ -591,6 +593,11 @@ public class SessionLazyDelegator implements Session {
|
|||
return this.lazySession.get().createQuery( criteriaQuery );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> TypedQuery<T> createQuery(CriteriaSelect<T> selectQuery) {
|
||||
return this.lazySession.get().createQuery( selectQuery );
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
@Deprecated
|
||||
|
|
|
@ -11,6 +11,7 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.hibernate.graph.AttributeNode;
|
||||
import org.hibernate.graph.CannotBecomeEntityGraphException;
|
||||
|
@ -95,6 +96,42 @@ public abstract class AbstractGraph<J> extends AbstractGraphNode<J> implements G
|
|||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// AttributeNode handling
|
||||
|
||||
|
||||
@Override
|
||||
public <Y> AttributeNodeImplementor<Y> getAttributeNode(String attributeName) {
|
||||
if ( attrNodeMap == null ) {
|
||||
return null;
|
||||
}
|
||||
final PersistentAttribute<? super J, ?> attribute = managedType.findAttributeInSuperTypes( attributeName );
|
||||
//noinspection unchecked
|
||||
return (AttributeNodeImplementor<Y>) attrNodeMap.get( attribute );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <Y> AttributeNodeImplementor<Y> getAttributeNode(Attribute<? super J, Y> attribute) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitAttributeNodes(Consumer<AttributeNodeImplementor<?>> consumer) {
|
||||
if ( attrNodeMap == null ) {
|
||||
return;
|
||||
}
|
||||
attrNodeMap.forEach( (persistentAttribute, attributeNodeImplementor) -> {
|
||||
consumer.accept( attributeNodeImplementor );
|
||||
} );
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AttributeNode<?>> getAttributeNodeList() {
|
||||
if ( attrNodeMap == null ) {
|
||||
return emptyList();
|
||||
}
|
||||
final List<AttributeNode<?>> result = new ArrayList<>();
|
||||
visitAttributeNodes( result::add );
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttributeNodeImplementor<?> addAttributeNode(AttributeNodeImplementor<?> incomingAttributeNode) {
|
||||
verifyMutability();
|
||||
|
@ -151,8 +188,8 @@ public abstract class AbstractGraph<J> extends AbstractGraphNode<J> implements G
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addAttributeNode(String attributeName) throws CannotContainSubGraphException {
|
||||
findOrCreateAttributeNode( attributeName );
|
||||
public <AJ> AttributeNodeImplementor<AJ> addAttributeNode(String attributeName) throws CannotContainSubGraphException {
|
||||
return findOrCreateAttributeNode( attributeName );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -162,8 +199,9 @@ public abstract class AbstractGraph<J> extends AbstractGraphNode<J> implements G
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addAttributeNode(Attribute<? super J, ?> attribute) {
|
||||
findOrCreateAttributeNode( (PersistentAttribute<? super J, ?>) attribute );
|
||||
public <Y> AttributeNodeImplementor<Y> addAttributeNode(Attribute<? super J, Y> attribute) {
|
||||
//noinspection unchecked
|
||||
return (AttributeNodeImplementor<Y>) findOrCreateAttributeNode( (PersistentAttribute<? super J, ?>) attribute );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,6 +16,8 @@ import org.hibernate.graph.Graph;
|
|||
import org.hibernate.metamodel.model.domain.PersistentAttribute;
|
||||
import org.hibernate.query.sqm.SqmPathSource;
|
||||
|
||||
import jakarta.persistence.metamodel.Attribute;
|
||||
|
||||
/**
|
||||
* Integration version of the {@link Graph} contract
|
||||
*
|
||||
|
@ -49,6 +51,16 @@ public interface GraphImplementor<J> extends Graph<J>, GraphNodeImplementor<J> {
|
|||
getAttributeNodeImplementors().forEach( consumer );
|
||||
}
|
||||
|
||||
@Override
|
||||
default boolean hasAttributeNode(String attributeName) {
|
||||
return getAttributeNode( attributeName ) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
default boolean hasAttributeNode(Attribute<? super J, ?> attribute) {
|
||||
return getAttributeNode( attribute ) != null;
|
||||
}
|
||||
|
||||
AttributeNodeImplementor<?> addAttributeNode(AttributeNodeImplementor<?> makeCopy);
|
||||
|
||||
List<AttributeNodeImplementor<?>> getAttributeNodeImplementors();
|
||||
|
@ -66,7 +78,10 @@ public interface GraphImplementor<J> extends Graph<J>, GraphNodeImplementor<J> {
|
|||
<AJ> AttributeNodeImplementor<AJ> findAttributeNode(PersistentAttribute<? super J, AJ> attribute);
|
||||
|
||||
@Override
|
||||
void addAttributeNode(String attributeName) throws CannotContainSubGraphException;
|
||||
<AJ> AttributeNodeImplementor<AJ> addAttributeNode(String attributeName) throws CannotContainSubGraphException;
|
||||
|
||||
@Override
|
||||
<Y> AttributeNodeImplementor<Y> addAttributeNode(Attribute<? super J, Y> attribute);
|
||||
|
||||
@Override
|
||||
<AJ> AttributeNodeImplementor<AJ> addAttributeNode(PersistentAttribute<? super J, AJ> attribute)
|
||||
|
|
|
@ -856,6 +856,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
|
|||
return interpretAndCreateSelectionQuery( hqlString, expectedResultType );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public <R> SelectionQuery<R> createSelectionQuery(CriteriaQuery<R> criteria) {
|
||||
if ( criteria instanceof CriteriaDefinition ) {
|
||||
|
@ -1476,7 +1477,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
|
|||
}
|
||||
}
|
||||
|
||||
private <T> QueryImplementor<T> createCriteriaQuery(SqmStatement<T> criteria, Class<T> resultType) {
|
||||
protected <T> QueryImplementor<T> createCriteriaQuery(SqmStatement<T> criteria, Class<T> resultType) {
|
||||
final QuerySqmImpl<T> query = new QuerySqmImpl<>( criteria, resultType, this );
|
||||
applyQuerySettingsAndHints( query );
|
||||
return query;
|
||||
|
|
|
@ -124,6 +124,11 @@ import org.hibernate.proxy.LazyInitializer;
|
|||
import org.hibernate.query.Query;
|
||||
import org.hibernate.query.SelectionQuery;
|
||||
import org.hibernate.query.UnknownSqlResultSetMappingException;
|
||||
import org.hibernate.query.criteria.CriteriaDefinition;
|
||||
import org.hibernate.query.spi.QueryImplementor;
|
||||
import org.hibernate.query.sqm.tree.select.SqmQueryGroup;
|
||||
import org.hibernate.query.sqm.tree.select.SqmQuerySpec;
|
||||
import org.hibernate.query.sqm.tree.select.SqmSelectStatement;
|
||||
import org.hibernate.resource.jdbc.spi.JdbcSessionOwner;
|
||||
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
|
||||
import org.hibernate.resource.jdbc.spi.StatementInspector;
|
||||
|
@ -148,6 +153,7 @@ import jakarta.persistence.LockOption;
|
|||
import jakarta.persistence.PersistenceException;
|
||||
import jakarta.persistence.RefreshOption;
|
||||
import jakarta.persistence.TransactionRequiredException;
|
||||
import jakarta.persistence.criteria.CriteriaSelect;
|
||||
import jakarta.persistence.metamodel.Metamodel;
|
||||
|
||||
import static java.lang.Boolean.parseBoolean;
|
||||
|
@ -1719,6 +1725,35 @@ public class SessionImpl
|
|||
return getFactory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> QueryImplementor<T> createQuery(CriteriaSelect<T> selectQuery) {
|
||||
checkOpen();
|
||||
if ( selectQuery instanceof CriteriaDefinition ) {
|
||||
return (QueryImplementor<T>) ((CriteriaDefinition<T>) selectQuery).createSelectionQuery(this);
|
||||
}
|
||||
else {
|
||||
try {
|
||||
final SqmSelectStatement<T> selectStatement = (SqmSelectStatement<T>) selectQuery;
|
||||
if ( ! ( selectStatement.getQueryPart() instanceof SqmQueryGroup ) ) {
|
||||
final SqmQuerySpec<T> querySpec = selectStatement.getQuerySpec();
|
||||
if ( querySpec.getSelectClause().getSelections().isEmpty() ) {
|
||||
if ( querySpec.getFromClause().getRoots().size() == 1 ) {
|
||||
querySpec.getSelectClause().setSelection( querySpec.getFromClause().getRoots().get(0) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return createCriteriaQuery( selectStatement, selectStatement.getResultType() );
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
if ( getSessionFactory().getJpaMetamodel().getJpaCompliance().isJpaTransactionComplianceEnabled() ) {
|
||||
markForRollbackOnly();
|
||||
}
|
||||
throw getExceptionConverter().convert( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializeCollection(PersistentCollection<?> collection, boolean writing) {
|
||||
checkOpenOrWaitingForAutoClose();
|
||||
|
|
|
@ -166,8 +166,7 @@ public interface QueryProducer {
|
|||
*
|
||||
* @apiNote Changes in JPA 3.2 required de-typing this to be compilable with their changes
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
NativeQuery createNativeQuery(String sqlString, Class<?> resultClass);
|
||||
<R> NativeQuery<R> createNativeQuery(String sqlString, Class<R> resultClass);
|
||||
|
||||
/**
|
||||
* Create a {@link NativeQuery} instance for the given native SQL query
|
||||
|
|
|
@ -25,12 +25,14 @@ import org.hibernate.query.NullPrecedence;
|
|||
import org.hibernate.query.SortDirection;
|
||||
import org.hibernate.query.sqm.FrameKind;
|
||||
import org.hibernate.query.sqm.TemporalUnit;
|
||||
import org.hibernate.query.sqm.tree.select.SqmSelectStatement;
|
||||
|
||||
import jakarta.persistence.Tuple;
|
||||
import jakarta.persistence.criteria.AbstractQuery;
|
||||
import jakarta.persistence.criteria.CollectionJoin;
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.CriteriaQuery;
|
||||
import jakarta.persistence.criteria.CriteriaSelect;
|
||||
import jakarta.persistence.criteria.Expression;
|
||||
import jakarta.persistence.criteria.Join;
|
||||
import jakarta.persistence.criteria.ListJoin;
|
||||
|
@ -176,28 +178,34 @@ public interface HibernateCriteriaBuilder extends CriteriaBuilder {
|
|||
|
||||
<T> JpaCriteriaQuery<T> except(boolean all, CriteriaQuery<? extends T> query1, CriteriaQuery<?>... queries);
|
||||
|
||||
default <T> JpaSubQuery<T> unionAll(Subquery<? extends T> query1, Subquery<?>... queries) {
|
||||
return union( true, query1, queries );
|
||||
}
|
||||
|
||||
@Override
|
||||
<T> CriteriaSelect<T> union(CriteriaSelect<? extends T> left, CriteriaSelect<? extends T> right);
|
||||
|
||||
<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);
|
||||
default <T> JpaSubQuery<T> unionAll(Subquery<? extends T> query1, Subquery<?>... queries) {
|
||||
return union( true, query1, queries );
|
||||
}
|
||||
|
||||
@Override
|
||||
<T> CriteriaSelect<T> unionAll(CriteriaSelect<? extends T> left, CriteriaSelect<? extends T> right);
|
||||
|
||||
<T> JpaCriteriaQuery<T> unionAll(CriteriaQuery<? extends T> left, CriteriaQuery<? extends T> right);
|
||||
|
||||
@Override
|
||||
<T> CriteriaSelect<T> intersect(CriteriaSelect<? super T> left, CriteriaSelect<? super T> right);
|
||||
|
||||
@Override
|
||||
<T> CriteriaSelect<T> intersectAll(CriteriaSelect<? super T> left, CriteriaSelect<? super T> right);
|
||||
|
||||
<T> JpaCriteriaQuery<T> intersect(CriteriaQuery<? super T> left, CriteriaQuery<? super T> right);
|
||||
|
||||
<T> JpaCriteriaQuery<T> intersectAll(CriteriaQuery<? super T> left, CriteriaQuery<? super T> right);
|
||||
|
||||
default <T> JpaSubQuery<T> intersectAll(Subquery<? extends T> query1, Subquery<?>... queries) {
|
||||
|
@ -211,9 +219,13 @@ 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);
|
||||
<T> CriteriaSelect<T> except(CriteriaSelect<T> left, CriteriaSelect<?> right);
|
||||
|
||||
@Override
|
||||
<T> CriteriaSelect<T> exceptAll(CriteriaSelect<T> left, CriteriaSelect<?> right);
|
||||
|
||||
<T> JpaCriteriaQuery<T> except(CriteriaQuery<T> left, CriteriaQuery<?> right);
|
||||
|
||||
<T> JpaCriteriaQuery<T> exceptAll(CriteriaQuery<T> left, CriteriaQuery<?> right);
|
||||
|
||||
default <T> JpaSubQuery<T> exceptAll(Subquery<? extends T> query1, Subquery<?>... queries) {
|
||||
|
@ -368,11 +380,11 @@ public interface HibernateCriteriaBuilder extends CriteriaBuilder {
|
|||
|
||||
@Override
|
||||
JpaCompoundSelection<Tuple> tuple(Selection<?>... selections);
|
||||
JpaCompoundSelection<Tuple> tuple(List<? extends JpaSelection<?>> selections);
|
||||
JpaCompoundSelection<Tuple> tuple(List<Selection<?>> selections);
|
||||
|
||||
@Override
|
||||
JpaCompoundSelection<Object[]> array(Selection<?>... selections);
|
||||
JpaCompoundSelection<Object[]> array(List<? extends JpaSelection<?>> selections);
|
||||
JpaCompoundSelection<Object[]> array(List<Selection<?>> selections);
|
||||
|
||||
<Y> JpaCompoundSelection<Y> array(Class<Y> resultClass, Selection<?>... selections);
|
||||
<Y> JpaCompoundSelection<Y> array(Class<Y> resultClass, List<? extends JpaSelection<?>> selections);
|
||||
|
|
|
@ -25,7 +25,7 @@ import jakarta.persistence.metamodel.EntityType;
|
|||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface JpaCriteriaQuery<T> extends CriteriaQuery<T>, JpaQueryableCriteria<T>, JpaSelectCriteria<T> {
|
||||
public interface JpaCriteriaQuery<T> extends CriteriaQuery<T>, JpaQueryableCriteria<T>, JpaSelectCriteria<T>, JpaCriteriaSelect<T> {
|
||||
|
||||
/**
|
||||
* A query that returns the number of results of this query.
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.query.criteria;
|
||||
|
||||
import jakarta.persistence.criteria.CriteriaSelect;
|
||||
|
||||
/**
|
||||
* Extension of the JPA {@link CriteriaSelect}.
|
||||
*
|
||||
* @apiNote This is different from {@link JpaSelectCriteria}. JPA added
|
||||
* {@link CriteriaSelect} in version 3.2 while {@link JpaSelectCriteria} has
|
||||
* existed for many releases prior. JPA's {@link CriteriaSelect} is intended
|
||||
* for supporting its newly added set operations (union, interest, except).
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface JpaCriteriaSelect<T> extends CriteriaSelect<T> {
|
||||
|
||||
}
|
|
@ -25,7 +25,7 @@ import org.hibernate.query.sqm.FetchClauseType;
|
|||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface JpaSubQuery<T> extends Subquery<T>, JpaSelectCriteria<T>, JpaExpression<T>, JpaCteContainer {
|
||||
public interface JpaSubQuery<T> extends Subquery<T>, JpaSelectCriteria<T>, JpaCriteriaSelect<T>, JpaExpression<T>, JpaCteContainer {
|
||||
|
||||
JpaSubQuery<T> multiselect(Selection<?>... selections);
|
||||
|
||||
|
|
|
@ -62,6 +62,7 @@ import jakarta.persistence.Tuple;
|
|||
import jakarta.persistence.criteria.CollectionJoin;
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.CriteriaQuery;
|
||||
import jakarta.persistence.criteria.CriteriaSelect;
|
||||
import jakarta.persistence.criteria.Expression;
|
||||
import jakarta.persistence.criteria.Join;
|
||||
import jakarta.persistence.criteria.ListJoin;
|
||||
|
@ -211,11 +212,21 @@ public class HibernateCriteriaBuilderDelegate implements HibernateCriteriaBuilde
|
|||
return criteriaBuilder.except( all, query1, queries );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> CriteriaSelect<T> union(CriteriaSelect<? extends T> left, CriteriaSelect<? extends T> right) {
|
||||
return criteriaBuilder.union( left, right );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> JpaSubQuery<T> unionAll(Subquery<? extends T> query1, Subquery<?>... queries) {
|
||||
return criteriaBuilder.unionAll( query1, queries );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> CriteriaSelect<T> unionAll(CriteriaSelect<? extends T> left, CriteriaSelect<? extends T> right) {
|
||||
return criteriaBuilder.unionAll( left, right );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> JpaSubQuery<T> union(Subquery<? extends T> query1, Subquery<?>... queries) {
|
||||
return criteriaBuilder.union( query1, queries );
|
||||
|
@ -241,6 +252,16 @@ public class HibernateCriteriaBuilderDelegate implements HibernateCriteriaBuilde
|
|||
return criteriaBuilder.intersect( all, query1, queries );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> CriteriaSelect<T> except(CriteriaSelect<T> left, CriteriaSelect<?> right) {
|
||||
return criteriaBuilder.except( left, right );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> CriteriaSelect<T> exceptAll(CriteriaSelect<T> left, CriteriaSelect<?> right) {
|
||||
return criteriaBuilder.exceptAll( left, right );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> JpaSubQuery<T> exceptAll(Subquery<? extends T> query1, Subquery<?>... queries) {
|
||||
return criteriaBuilder.exceptAll( query1, queries );
|
||||
|
@ -348,6 +369,16 @@ public class HibernateCriteriaBuilderDelegate implements HibernateCriteriaBuilde
|
|||
return criteriaBuilder.unionAll( left, right );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> CriteriaSelect<T> intersect(CriteriaSelect<? super T> left, CriteriaSelect<? super T> right) {
|
||||
return criteriaBuilder.intersect( left, right );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> CriteriaSelect<T> intersectAll(CriteriaSelect<? super T> left, CriteriaSelect<? super T> right) {
|
||||
return criteriaBuilder.intersectAll( left, right );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> JpaCriteriaQuery<T> intersect(CriteriaQuery<? super T> left, CriteriaQuery<? super T> right) {
|
||||
return criteriaBuilder.intersect( left, right );
|
||||
|
@ -409,7 +440,7 @@ public class HibernateCriteriaBuilderDelegate implements HibernateCriteriaBuilde
|
|||
}
|
||||
|
||||
@Override
|
||||
public JpaCompoundSelection<Tuple> tuple(List<? extends JpaSelection<?>> selections) {
|
||||
public JpaCompoundSelection<Tuple> tuple(List<Selection<?>> selections) {
|
||||
return criteriaBuilder.tuple( selections );
|
||||
}
|
||||
|
||||
|
@ -419,7 +450,7 @@ public class HibernateCriteriaBuilderDelegate implements HibernateCriteriaBuilde
|
|||
}
|
||||
|
||||
@Override
|
||||
public JpaCompoundSelection<Object[]> array(List<? extends JpaSelection<?>> selections) {
|
||||
public JpaCompoundSelection<Object[]> array(List<Selection<?>> selections) {
|
||||
return criteriaBuilder.array( selections );
|
||||
}
|
||||
|
||||
|
|
|
@ -47,9 +47,8 @@ public interface QueryProducerImplementor extends QueryProducer {
|
|||
@Override @Deprecated @SuppressWarnings("rawtypes")
|
||||
NativeQueryImplementor createNativeQuery(String sqlString);
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
NativeQueryImplementor createNativeQuery(String sqlString, Class<?> resultClass);
|
||||
<R> NativeQueryImplementor<R> createNativeQuery(String sqlString, Class<R> resultClass);
|
||||
|
||||
@Override
|
||||
<R> NativeQueryImplementor<R> createNativeQuery(String sqlString, Class<R> resultClass, String tableAlias);
|
||||
|
|
|
@ -64,7 +64,6 @@ import jakarta.persistence.criteria.Expression;
|
|||
import jakarta.persistence.criteria.Join;
|
||||
import jakarta.persistence.criteria.ListJoin;
|
||||
import jakarta.persistence.criteria.MapJoin;
|
||||
import jakarta.persistence.criteria.Nulls;
|
||||
import jakarta.persistence.criteria.Path;
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
import jakarta.persistence.criteria.Root;
|
||||
|
@ -636,13 +635,13 @@ public interface NodeBuilder extends HibernateCriteriaBuilder {
|
|||
JpaCompoundSelection<Tuple> tuple(Selection<?>[] selections);
|
||||
|
||||
@Override
|
||||
JpaCompoundSelection<Tuple> tuple(List<? extends JpaSelection<?>> selections);
|
||||
JpaCompoundSelection<Tuple> tuple(List<Selection<?>> selections);
|
||||
|
||||
@Override
|
||||
JpaCompoundSelection<Object[]> array(Selection<?>[] selections);
|
||||
|
||||
@Override
|
||||
JpaCompoundSelection<Object[]> array(List<? extends JpaSelection<?>> selections);
|
||||
JpaCompoundSelection<Object[]> array(List<Selection<?>> selections);
|
||||
|
||||
@Override
|
||||
<T> SqmUpdateStatement<T> createCriteriaUpdate(Class<T> targetEntity);
|
||||
|
|
|
@ -58,6 +58,7 @@ import org.hibernate.query.criteria.HibernateCriteriaBuilder;
|
|||
import org.hibernate.query.criteria.JpaCoalesce;
|
||||
import org.hibernate.query.criteria.JpaCompoundSelection;
|
||||
import org.hibernate.query.criteria.JpaCriteriaQuery;
|
||||
import org.hibernate.query.criteria.JpaCriteriaSelect;
|
||||
import org.hibernate.query.criteria.JpaCteCriteriaAttribute;
|
||||
import org.hibernate.query.criteria.JpaExpression;
|
||||
import org.hibernate.query.criteria.JpaFunction;
|
||||
|
@ -170,6 +171,7 @@ import org.hibernate.type.spi.TypeConfiguration;
|
|||
import jakarta.persistence.Tuple;
|
||||
import jakarta.persistence.criteria.CollectionJoin;
|
||||
import jakarta.persistence.criteria.CriteriaQuery;
|
||||
import jakarta.persistence.criteria.CriteriaSelect;
|
||||
import jakarta.persistence.criteria.Expression;
|
||||
import jakarta.persistence.criteria.Join;
|
||||
import jakarta.persistence.criteria.ListJoin;
|
||||
|
@ -406,16 +408,42 @@ public class SqmCriteriaNodeBuilder implements NodeBuilder, SqmCreationContext,
|
|||
return setOperation( all ? SetOperator.EXCEPT_ALL : SetOperator.EXCEPT, query1, queries );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> JpaCriteriaSelect<T> union(CriteriaSelect<? extends T> left, CriteriaSelect<? extends T> right) {
|
||||
if ( left instanceof Subquery<?> ) {
|
||||
assert right instanceof Subquery<?>;
|
||||
//noinspection unchecked
|
||||
return setOperation( SetOperator.UNION, (Subquery<T>) left, (Subquery<T>) right );
|
||||
}
|
||||
//noinspection unchecked
|
||||
return setOperation( SetOperator.UNION, (JpaCriteriaQuery<T>) left, (JpaCriteriaQuery<T>) right );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> JpaSubQuery<T> union(boolean all, Subquery<? extends T> query1, Subquery<?>... queries) {
|
||||
return setOperation( all ? SetOperator.UNION_ALL : SetOperator.UNION, query1, queries );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> CriteriaSelect<T> unionAll(CriteriaSelect<? extends T> left, CriteriaSelect<? extends T> right) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> JpaSubQuery<T> intersect(boolean all, Subquery<? extends T> query1, Subquery<?>... queries) {
|
||||
return setOperation( all ? SetOperator.INTERSECT_ALL : SetOperator.INTERSECT, query1, queries );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> CriteriaSelect<T> except(CriteriaSelect<T> left, CriteriaSelect<?> right) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> CriteriaSelect<T> exceptAll(CriteriaSelect<T> left, CriteriaSelect<?> right) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> JpaSubQuery<T> except(boolean all, Subquery<? extends T> query1, Subquery<?>... queries) {
|
||||
return setOperation( all ? SetOperator.EXCEPT_ALL : SetOperator.EXCEPT, query1, queries );
|
||||
|
@ -557,6 +585,16 @@ public class SqmCriteriaNodeBuilder implements NodeBuilder, SqmCreationContext,
|
|||
return createUnionSet( SetOperator.UNION_ALL, left, right );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> CriteriaSelect<T> intersect(CriteriaSelect<? super T> left, CriteriaSelect<? super T> right) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> CriteriaSelect<T> intersectAll(CriteriaSelect<? super T> left, CriteriaSelect<? super T> right) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
private static <T> JpaCriteriaQuery<T> createUnionSet(
|
||||
SetOperator operator,
|
||||
|
@ -786,13 +824,18 @@ public class SqmCriteriaNodeBuilder implements NodeBuilder, SqmCreationContext,
|
|||
|
||||
@Override
|
||||
public JpaCompoundSelection<Tuple> tuple(Selection<?>[] selections) {
|
||||
//noinspection unchecked
|
||||
return tuple( (List<SqmSelectableNode<?>>) (List<?>) Arrays.asList( selections ) );
|
||||
return tuple( Arrays.asList( selections ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public JpaCompoundSelection<Tuple> tuple(List<? extends JpaSelection<?>> selections) {
|
||||
return null;
|
||||
public JpaCompoundSelection<Tuple> tuple(List<Selection<?>> selections) {
|
||||
checkMultiselect( selections );
|
||||
//noinspection unchecked,rawtypes
|
||||
return new SqmJpaCompoundSelection<>(
|
||||
(List) selections,
|
||||
getTypeConfiguration().getJavaTypeRegistry().getDescriptor( Tuple.class ),
|
||||
this
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -825,13 +868,13 @@ public class SqmCriteriaNodeBuilder implements NodeBuilder, SqmCreationContext,
|
|||
|
||||
@Override
|
||||
public JpaCompoundSelection<Object[]> array(Selection<?>[] selections) {
|
||||
//noinspection unchecked
|
||||
return array( (List<SqmSelectableNode<?>>) (List<?>) Arrays.asList( selections ) );
|
||||
return array( Arrays.asList( selections ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public JpaCompoundSelection<Object[]> array(List<? extends JpaSelection<?>> selections) {
|
||||
return array( Object[].class, selections );
|
||||
public JpaCompoundSelection<Object[]> array(List<Selection<?>> selections) {
|
||||
//noinspection unchecked,rawtypes
|
||||
return array( Object[].class, (List) selections );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -842,7 +885,8 @@ public class SqmCriteriaNodeBuilder implements NodeBuilder, SqmCreationContext,
|
|||
|
||||
@Override
|
||||
public <Y> JpaCompoundSelection<Y> array(Class<Y> resultClass, List<? extends JpaSelection<?>> selections) {
|
||||
checkMultiselect( selections );
|
||||
//noinspection rawtypes,unchecked
|
||||
checkMultiselect( (List) selections );
|
||||
final JavaType<Y> javaType = getTypeConfiguration().getJavaTypeRegistry().getDescriptor( resultClass );
|
||||
//noinspection unchecked
|
||||
return new SqmJpaCompoundSelection<>( (List<SqmSelectableNode<?>>) selections, javaType, this );
|
||||
|
@ -856,7 +900,8 @@ public class SqmCriteriaNodeBuilder implements NodeBuilder, SqmCreationContext,
|
|||
|
||||
@Override
|
||||
public <Y> JpaCompoundSelection<Y> construct(Class<Y> resultClass, List<? extends JpaSelection<?>> arguments) {
|
||||
checkMultiselect( arguments );
|
||||
//noinspection unchecked,rawtypes
|
||||
checkMultiselect( (List) arguments );
|
||||
final SqmDynamicInstantiation<Y> instantiation;
|
||||
if ( List.class.equals( resultClass ) ) {
|
||||
//noinspection unchecked
|
||||
|
@ -891,10 +936,11 @@ public class SqmCriteriaNodeBuilder implements NodeBuilder, SqmCreationContext,
|
|||
* <i>"An argument to the multiselect method must not be a tuple-
|
||||
* or array-valued compound selection item."</i>
|
||||
*/
|
||||
void checkMultiselect(List<? extends JpaSelection<?>> selections) {
|
||||
void checkMultiselect(List<Selection<?>> selections) {
|
||||
final HashSet<String> aliases = new HashSet<>( CollectionHelper.determineProperSizing( selections.size() ) );
|
||||
|
||||
for ( JpaSelection<?> selection : selections ) {
|
||||
for ( Selection<?> it : selections ) {
|
||||
final JpaSelection<?> selection = (JpaSelection<?>) it;
|
||||
if ( selection.isCompoundSelection() ) {
|
||||
if ( selection.getJavaType().isArray() ) {
|
||||
throw new IllegalArgumentException(
|
||||
|
|
|
@ -31,7 +31,6 @@ import org.hibernate.query.sqm.tree.predicate.SqmPredicate;
|
|||
import org.hibernate.query.sqm.tree.from.SqmRoot;
|
||||
|
||||
import jakarta.persistence.Tuple;
|
||||
import jakarta.persistence.criteria.CriteriaQuery;
|
||||
import jakarta.persistence.criteria.Expression;
|
||||
import jakarta.persistence.criteria.Order;
|
||||
import jakarta.persistence.criteria.ParameterExpression;
|
||||
|
@ -331,8 +330,8 @@ public class SqmSelectStatement<T> extends AbstractSqmSelectQuery<T> implements
|
|||
@SuppressWarnings("unchecked")
|
||||
private Selection<? extends T> getResultSelection(List<?> selectionList) {
|
||||
final Class<T> resultType = getResultType();
|
||||
final List<? extends JpaSelection<?>> selections =
|
||||
(List<? extends JpaSelection<?>>) selectionList;
|
||||
//noinspection rawtypes
|
||||
final List<? extends JpaSelection<?>> selections = (List) selectionList;
|
||||
if ( resultType == null || resultType == Object.class ) {
|
||||
switch ( selectionList.size() ) {
|
||||
case 0: {
|
||||
|
@ -344,12 +343,12 @@ public class SqmSelectStatement<T> extends AbstractSqmSelectQuery<T> implements
|
|||
return (Selection<? extends T>) selectionList.get( 0 );
|
||||
}
|
||||
default: {
|
||||
return (Selection<? extends T>) nodeBuilder().array( selections );
|
||||
return (Selection<? extends T>) nodeBuilder().array( selectionList );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( Tuple.class.isAssignableFrom( resultType ) ) {
|
||||
return (Selection<? extends T>) nodeBuilder().tuple( selections );
|
||||
return (Selection<? extends T>) nodeBuilder().tuple( selectionList );
|
||||
}
|
||||
else if ( resultType.isArray() ) {
|
||||
return nodeBuilder().array( resultType, selections );
|
||||
|
|
|
@ -41,7 +41,6 @@ import org.hibernate.query.sqm.tree.domain.SqmCorrelatedListJoin;
|
|||
import org.hibernate.query.sqm.tree.domain.SqmCorrelatedMapJoin;
|
||||
import org.hibernate.query.sqm.tree.domain.SqmCorrelatedRoot;
|
||||
import org.hibernate.query.sqm.tree.domain.SqmCorrelatedSetJoin;
|
||||
import org.hibernate.query.sqm.tree.domain.SqmCorrelatedSingularJoin;
|
||||
import org.hibernate.query.sqm.tree.domain.SqmCorrelatedSingularValuedJoin;
|
||||
import org.hibernate.query.sqm.tree.domain.SqmCorrelation;
|
||||
import org.hibernate.query.sqm.tree.domain.SqmListJoin;
|
||||
|
@ -49,7 +48,6 @@ import org.hibernate.query.sqm.tree.domain.SqmMapJoin;
|
|||
import org.hibernate.query.sqm.tree.domain.SqmSetJoin;
|
||||
import org.hibernate.query.sqm.tree.domain.SqmSingularValuedJoin;
|
||||
import org.hibernate.query.sqm.tree.expression.SqmExpression;
|
||||
import org.hibernate.query.sqm.tree.from.SqmAttributeJoin;
|
||||
import org.hibernate.query.sqm.tree.from.SqmCrossJoin;
|
||||
import org.hibernate.query.sqm.tree.from.SqmEntityJoin;
|
||||
import org.hibernate.query.sqm.tree.from.SqmFromClause;
|
||||
|
@ -276,12 +274,12 @@ public class SqmSubQuery<T> extends AbstractSqmSelectQuery<T> implements SqmSele
|
|||
break;
|
||||
}
|
||||
default: {
|
||||
resultSelection = ( Selection<? extends T> ) nodeBuilder().array( selections );
|
||||
resultSelection = ( Selection<? extends T> ) nodeBuilder().array( selectionList );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( Tuple.class.isAssignableFrom( resultType ) ) {
|
||||
resultSelection = ( Selection<? extends T> ) nodeBuilder().tuple( selections );
|
||||
resultSelection = ( Selection<? extends T> ) nodeBuilder().tuple( selectionList );
|
||||
}
|
||||
else if ( resultType.isArray() ) {
|
||||
resultSelection = nodeBuilder().array( resultType, selections );
|
||||
|
|
|
@ -18,7 +18,7 @@ import org.gradle.api.initialization.Settings;
|
|||
public class JpaVersion {
|
||||
public static final String EXT_KEY = "jakartaJpaVersion";
|
||||
public static final String VERSION_KEY = "jakartaJpaVersionOverride";
|
||||
public static final String DEFAULT_VERSION = "3.2.0-B01";
|
||||
public static final String DEFAULT_VERSION = "3.2.0-B02";
|
||||
|
||||
private final String name;
|
||||
private final String osgiName;
|
||||
|
|
Loading…
Reference in New Issue