HHH-17068 introduce JoinType to replace use of SqmJoinType in criteria API

fix the layer-breakage

Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
Gavin King 2024-09-07 21:36:29 +02:00
parent d5bf8016a8
commit 63c4f313ca
20 changed files with 211 additions and 111 deletions

View File

@ -36,10 +36,20 @@ public interface JpaFrom<O,T> extends JpaPath<T>, JpaFetchParent<O,T>, From<O,T>
@Override
<Y> JpaEntityJoin<T, Y> join(Class<Y> entityClass, JoinType joinType);
/**
* @deprecated This method is a layer-breaker, leaking the SQM type
* {@link SqmJoinType} onto an API. It will be removed.
* Use {@link #join(Class, org.hibernate.query.common.JoinType)}
*/
@Deprecated(since="7", forRemoval = true)
default <X> JpaEntityJoin<T, X> join(Class<X> entityJavaType, SqmJoinType joinType) {
return join( entityJavaType, joinType.getCorrespondingJpaJoinType() );
}
default <X> JpaEntityJoin<T, X> join(Class<X> entityJavaType, org.hibernate.query.common.JoinType joinType) {
return join( entityJavaType, SqmJoinType.from(joinType) );
}
@Override
<Y> JpaJoin<T, Y> join(EntityType<Y> entity);
@ -48,23 +58,60 @@ public interface JpaFrom<O,T> extends JpaPath<T>, JpaFetchParent<O,T>, From<O,T>
<X> JpaEntityJoin<T,X> join(EntityDomainType<X> entity);
/**
* @deprecated This method is a layer-breaker, leaking the SQM type
* {@link SqmJoinType} onto an API. It will be removed.
* Use {@link #join(EntityDomainType, org.hibernate.query.common.JoinType)}
*/
@Deprecated(since = "7", forRemoval = true)
<X> JpaEntityJoin<T,X> join(EntityDomainType<X> entity, SqmJoinType joinType);
default <X> JpaEntityJoin<T,X> join(EntityDomainType<X> entity, org.hibernate.query.common.JoinType joinType) {
return join( entity, SqmJoinType.from(joinType) );
}
@Incubating
<X> JpaDerivedJoin<X> join(Subquery<X> subquery);
@Incubating
/**
* @deprecated This method is a layer-breaker, leaking the SQM type
* {@link SqmJoinType} onto an API. It will be removed.
* Use {@link #join(Subquery, org.hibernate.query.common.JoinType)}
*/
@Incubating @Deprecated(since = "7", forRemoval = true)
<X> JpaDerivedJoin<X> join(Subquery<X> subquery, SqmJoinType joinType);
default <X> JpaDerivedJoin<X> join(Subquery<X> subquery, org.hibernate.query.common.JoinType joinType) {
return join( subquery, SqmJoinType.from(joinType) );
}
@Incubating
<X> JpaDerivedJoin<X> joinLateral(Subquery<X> subquery);
@Incubating
/**
* @deprecated This method is a layer-breaker, leaking the SQM type
* {@link SqmJoinType} onto an API. It will be removed.
* Use {@link #joinLateral(Subquery, org.hibernate.query.common.JoinType)}
*/
@Incubating @Deprecated(since = "7", forRemoval = true)
<X> JpaDerivedJoin<X> joinLateral(Subquery<X> subquery, SqmJoinType joinType);
@Incubating
default <X> JpaDerivedJoin<X> joinLateral(Subquery<X> subquery, org.hibernate.query.common.JoinType joinType) {
return joinLateral( subquery, SqmJoinType.from(joinType) );
}
/**
* @deprecated This method is a layer-breaker, leaking the SQM type
* {@link SqmJoinType} onto an API. It will be removed.
* Use {@link #join(Subquery, org.hibernate.query.common.JoinType, boolean)}
*/
@Incubating @Deprecated(since = "7", forRemoval = true)
<X> JpaDerivedJoin<X> join(Subquery<X> subquery, SqmJoinType joinType, boolean lateral);
default <X> JpaDerivedJoin<X> join(Subquery<X> subquery, org.hibernate.query.common.JoinType joinType, boolean lateral) {
return join( subquery, SqmJoinType.from(joinType), lateral );
}
/**
* Like calling the overload {@link #join(JpaSetReturningFunction, SqmJoinType)} with {@link SqmJoinType#INNER}.
*
@ -192,9 +239,18 @@ public interface JpaFrom<O,T> extends JpaPath<T>, JpaFetchParent<O,T>, From<O,T>
@Incubating
<X> JpaJoin<?, X> join(JpaCteCriteria<X> cte);
@Incubating
/**
* @deprecated This method is a layer-breaker, leaking the SQM type
* {@link SqmJoinType} onto an API. It will be removed.
* Use {@link #join(JpaCteCriteria, org.hibernate.query.common.JoinType)}
*/
@Incubating @Deprecated(since = "7", forRemoval = true)
<X> JpaJoin<?, X> join(JpaCteCriteria<X> cte, SqmJoinType joinType);
default <X> JpaJoin<?, X> join(JpaCteCriteria<X> cte, org.hibernate.query.common.JoinType joinType) {
return join( cte, SqmJoinType.from(joinType) );
}
@Incubating
<X> JpaCrossJoin<X> crossJoin(Class<X> entityJavaType);

View File

@ -0,0 +1,35 @@
/*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Copyright Red Hat Inc. and Hibernate Authors
*/
package org.hibernate.query.common;
/**
* Enumerates the possible kinds of join in HQL and ANSI SQL.
*
* @apiNote This enumeration competes with
* {@link jakarta.persistence.criteria.JoinType},
* adding {@link #FULL} and {@link #CROSS} joins.
*
* @author Gavin King
*
* @since 7
*
* @see jakarta.persistence.criteria.JoinType
*/
public enum JoinType {
/**
* @see jakarta.persistence.criteria.JoinType#INNER
*/
INNER,
/**
* @see jakarta.persistence.criteria.JoinType#LEFT
*/
LEFT,
/**
* @see jakarta.persistence.criteria.JoinType#RIGHT
*/
RIGHT,
FULL,
CROSS
}

View File

@ -4,92 +4,102 @@
*/
package org.hibernate.query.sqm.tree;
import org.hibernate.query.common.JoinType;
import org.hibernate.sql.ast.SqlAstJoinType;
/**
* Represents a canonical join type.
* <p>
* Note that currently HQL really only supports inner and left outer joins
* (though cross joins can also be achieved). This is because joins in HQL
* are always defined in relation to a mapped association. However, when we
* start allowing users to specify ad-hoc joins this may need to change to
* allow the full spectrum of join types. Thus the others are provided here
* currently just for completeness and for future expansion.
*
* @author Steve Ebersole
*
* @see JoinType
* @see SqlAstJoinType
*/
public enum SqmJoinType {
/**
* Represents an inner join.
*/
INNER( "inner", SqlAstJoinType.INNER, jakarta.persistence.criteria.JoinType.INNER ),
INNER,
/**
* Represents a left outer join.
*/
LEFT( "left outer", SqlAstJoinType.LEFT, jakarta.persistence.criteria.JoinType.LEFT ),
LEFT,
/**
* Represents a right outer join.
*/
RIGHT( "right outer", SqlAstJoinType.RIGHT, jakarta.persistence.criteria.JoinType.RIGHT ),
RIGHT,
/**
* Represents a cross join (aka a cartesian product).
*/
CROSS( "cross", SqlAstJoinType.CROSS, null ),
CROSS,
/**
* Represents a full join.
*/
FULL( "full", SqlAstJoinType.FULL, null );
private final String text;
private final SqlAstJoinType correspondingSqlAstJoinType;
private final jakarta.persistence.criteria.JoinType correspondingJpaJoinType;
SqmJoinType(
String text,
SqlAstJoinType correspondingSqlAstJoinType,
jakarta.persistence.criteria.JoinType correspondingJpaJoinType) {
this.text = text;
this.correspondingSqlAstJoinType = correspondingSqlAstJoinType;
this.correspondingJpaJoinType = correspondingJpaJoinType;
}
FULL;
@Override
public String toString() {
return text;
return getText();
}
public String getText() {
return text;
return switch (this) {
case RIGHT -> "right outer";
case LEFT -> "left outer";
case INNER -> "inner";
case FULL -> "full";
case CROSS -> "cross";
};
}
public SqlAstJoinType getCorrespondingSqlJoinType() {
return correspondingSqlAstJoinType;
return switch (this) {
case RIGHT -> SqlAstJoinType.RIGHT;
case LEFT -> SqlAstJoinType.LEFT;
case INNER -> SqlAstJoinType.INNER;
case FULL -> SqlAstJoinType.FULL;
case CROSS -> SqlAstJoinType.CROSS;
};
}
public jakarta.persistence.criteria.JoinType getCorrespondingJpaJoinType() {
return correspondingJpaJoinType;
return switch (this) {
case RIGHT -> jakarta.persistence.criteria.JoinType.RIGHT;
case LEFT -> jakarta.persistence.criteria.JoinType.LEFT;
case INNER -> jakarta.persistence.criteria.JoinType.INNER;
default -> null;
};
}
public JoinType getCorrespondingJoinType() {
return switch (this) {
case RIGHT -> JoinType.RIGHT;
case LEFT -> JoinType.LEFT;
case INNER -> JoinType.INNER;
case FULL -> JoinType.FULL;
case CROSS -> JoinType.CROSS;
};
}
public static SqmJoinType from(JoinType joinType) {
return switch ( joinType ) {
case INNER -> INNER;
case LEFT -> LEFT;
case RIGHT -> RIGHT;
case CROSS -> CROSS;
case FULL -> FULL;
};
}
@SuppressWarnings("DuplicateBranchesInSwitch")
public static SqmJoinType from(jakarta.persistence.criteria.JoinType jpaJoinType) {
switch ( jpaJoinType ) {
case INNER: {
return INNER;
}
case LEFT: {
return LEFT;
}
case RIGHT: {
return RIGHT;
}
default: {
// generally speaking, the default for JPA JoinType is INNER
return INNER;
}
}
return switch ( jpaJoinType ) {
case INNER -> INNER;
case LEFT -> LEFT;
case RIGHT -> RIGHT;
};
}
}

View File

@ -9,6 +9,7 @@ import java.util.ArrayList;
import java.util.List;
import org.hibernate.Session;
import org.hibernate.query.common.JoinType;
import org.hibernate.query.criteria.HibernateCriteriaBuilder;
import org.hibernate.query.criteria.JpaCriteriaQuery;
import org.hibernate.query.criteria.JpaCrossJoin;
@ -18,7 +19,6 @@ import org.hibernate.query.criteria.JpaJoin;
import org.hibernate.query.criteria.JpaPath;
import org.hibernate.query.criteria.JpaRoot;
import org.hibernate.query.criteria.JpaSubQuery;
import org.hibernate.query.sqm.tree.SqmJoinType;
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
@ -94,7 +94,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<Primary,Secondary> entityJoin = root.join( Secondary.class, SqmJoinType.INNER );
final JpaEntityJoin<Primary,Secondary> entityJoin = root.join( Secondary.class, JoinType.INNER );
final JpaPath<Integer> id = root.get( "id" );
entityJoin.on( cb.equal( id, entityJoin.get( "id" ) ) );
final JpaPath<String> name = entityJoin.get( "name" );

View File

@ -6,13 +6,13 @@ package org.hibernate.orm.test.query;
import java.util.function.Consumer;
import org.hibernate.query.common.JoinType;
import org.hibernate.query.criteria.HibernateCriteriaBuilder;
import org.hibernate.query.criteria.JpaCriteriaQuery;
import org.hibernate.query.criteria.JpaDerivedJoin;
import org.hibernate.query.criteria.JpaRoot;
import org.hibernate.query.criteria.JpaSubQuery;
import org.hibernate.query.spi.QueryImplementor;
import org.hibernate.query.sqm.tree.SqmJoinType;
import org.hibernate.testing.orm.junit.JiraKey;
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
@ -64,7 +64,7 @@ public class SubQueryInFromEmbeddedIdTests {
subquery.orderBy( cb.asc( alternativeContact.get( "name" ).get( "first" ) ) );
subquery.fetch( 1 );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, SqmJoinType.LEFT );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, JoinType.LEFT );
cq.multiselect( root.get( "name" ), a.get( "contact" ).get( "id" ) );
cq.orderBy( cb.asc( root.get( "id" ) ) );
@ -114,7 +114,7 @@ public class SubQueryInFromEmbeddedIdTests {
subquery.orderBy( cb.desc( alternativeContact.get( "name" ).get( "first" ) ) );
subquery.fetch( 1 );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, SqmJoinType.LEFT );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, JoinType.LEFT );
final Join<Object, Object> alt = a.join( "contact" );
cq.multiselect( root.get( "name" ), alt.get( "name" ) );
@ -162,7 +162,7 @@ public class SubQueryInFromEmbeddedIdTests {
subquery.orderBy( cb.desc( alternativeContact.get( "name" ).get( "first" ) ) );
subquery.fetch( 1 );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, SqmJoinType.LEFT );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, JoinType.LEFT );
cq.multiselect( root.get( "name" ), a.get( "contact" ).get( "name" ) );
cq.orderBy( cb.asc( root.get( "id" ) ) );

View File

@ -6,13 +6,13 @@ package org.hibernate.orm.test.query;
import java.util.function.Consumer;
import org.hibernate.query.common.JoinType;
import org.hibernate.query.criteria.HibernateCriteriaBuilder;
import org.hibernate.query.criteria.JpaCriteriaQuery;
import org.hibernate.query.criteria.JpaDerivedJoin;
import org.hibernate.query.criteria.JpaRoot;
import org.hibernate.query.criteria.JpaSubQuery;
import org.hibernate.query.spi.QueryImplementor;
import org.hibernate.query.sqm.tree.SqmJoinType;
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
import org.hibernate.testing.orm.junit.DomainModel;
@ -62,7 +62,7 @@ public class SubQueryInFromIdClassTests {
subquery.orderBy( cb.asc( alternativeContact.get( "name" ).get( "first" ) ) );
subquery.fetch( 1 );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, SqmJoinType.LEFT );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, JoinType.LEFT );
cq.multiselect( root.get( "name" ), a.get( "contact" ).get( "id1" ), a.get( "contact" ).get( "id2" ) );
cq.orderBy( cb.asc( root.get( "id1" ) ) );
@ -113,7 +113,7 @@ public class SubQueryInFromIdClassTests {
subquery.orderBy( cb.desc( alternativeContact.get( "name" ).get( "first" ) ) );
subquery.fetch( 1 );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, SqmJoinType.LEFT );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, JoinType.LEFT );
final Join<Object, Object> alt = a.join( "contact" );
cq.multiselect( root.get( "name" ), alt.get( "name" ) );
@ -161,7 +161,7 @@ public class SubQueryInFromIdClassTests {
subquery.orderBy( cb.desc( alternativeContact.get( "name" ).get( "first" ) ) );
subquery.fetch( 1 );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, SqmJoinType.LEFT );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, JoinType.LEFT );
cq.multiselect( root.get( "name" ), a.get( "contact" ).get( "name" ) );
cq.orderBy( cb.asc( root.get( "id1" ) ) );

View File

@ -6,13 +6,13 @@ package org.hibernate.orm.test.query;
import java.util.function.Consumer;
import org.hibernate.query.common.JoinType;
import org.hibernate.query.criteria.HibernateCriteriaBuilder;
import org.hibernate.query.criteria.JpaCriteriaQuery;
import org.hibernate.query.criteria.JpaDerivedJoin;
import org.hibernate.query.criteria.JpaRoot;
import org.hibernate.query.criteria.JpaSubQuery;
import org.hibernate.query.spi.QueryImplementor;
import org.hibernate.query.sqm.tree.SqmJoinType;
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
import org.hibernate.testing.orm.junit.DomainModel;
@ -62,7 +62,7 @@ public class SubQueryInFromInverseOneEmbeddedIdTests {
subquery.orderBy( cb.asc( alternativeContact.get( "name" ).get( "first" ) ) );
subquery.fetch( 1 );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, SqmJoinType.LEFT );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, JoinType.LEFT );
cq.multiselect( root.get( "name" ), a.get( "contact" ).get( "id" ) );
cq.orderBy( cb.asc( root.get( "id" ) ) );
@ -112,7 +112,7 @@ public class SubQueryInFromInverseOneEmbeddedIdTests {
subquery.orderBy( cb.desc( alternativeContact.get( "name" ).get( "first" ) ) );
subquery.fetch( 1 );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, SqmJoinType.LEFT );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, JoinType.LEFT );
final Join<Object, Object> alt = a.join( "contact" );
cq.multiselect( root.get( "name" ), alt.get( "name" ) );
@ -160,7 +160,7 @@ public class SubQueryInFromInverseOneEmbeddedIdTests {
subquery.orderBy( cb.desc( alternativeContact.get( "name" ).get( "first" ) ) );
subquery.fetch( 1 );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, SqmJoinType.LEFT );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, JoinType.LEFT );
cq.multiselect( root.get( "name" ), a.get( "contact" ).get( "name" ) );
cq.orderBy( cb.asc( root.get( "id" ) ) );

View File

@ -6,13 +6,13 @@ package org.hibernate.orm.test.query;
import java.util.function.Consumer;
import org.hibernate.query.common.JoinType;
import org.hibernate.query.criteria.HibernateCriteriaBuilder;
import org.hibernate.query.criteria.JpaCriteriaQuery;
import org.hibernate.query.criteria.JpaDerivedJoin;
import org.hibernate.query.criteria.JpaRoot;
import org.hibernate.query.criteria.JpaSubQuery;
import org.hibernate.query.spi.QueryImplementor;
import org.hibernate.query.sqm.tree.SqmJoinType;
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
import org.hibernate.testing.orm.junit.DomainModel;
@ -62,7 +62,7 @@ public class SubQueryInFromInverseOneIdClassTests {
subquery.orderBy( cb.asc( alternativeContact.get( "name" ).get( "first" ) ) );
subquery.fetch( 1 );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, SqmJoinType.LEFT );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, JoinType.LEFT );
cq.multiselect( root.get( "name" ), a.get( "contact" ).get( "id1" ), a.get( "contact" ).get( "id2" ) );
cq.orderBy( cb.asc( root.get( "id1" ) ) );
@ -113,7 +113,7 @@ public class SubQueryInFromInverseOneIdClassTests {
subquery.orderBy( cb.desc( alternativeContact.get( "name" ).get( "first" ) ) );
subquery.fetch( 1 );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, SqmJoinType.LEFT );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, JoinType.LEFT );
final Join<Object, Object> alt = a.join( "contact" );
cq.multiselect( root.get( "name" ), alt.get( "name" ) );
@ -161,7 +161,7 @@ public class SubQueryInFromInverseOneIdClassTests {
subquery.orderBy( cb.desc( alternativeContact.get( "name" ).get( "first" ) ) );
subquery.fetch( 1 );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, SqmJoinType.LEFT );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, JoinType.LEFT );
cq.multiselect( root.get( "name" ), a.get( "contact" ).get( "name" ) );
cq.orderBy( cb.asc( root.get( "id1" ) ) );

View File

@ -6,13 +6,13 @@ package org.hibernate.orm.test.query;
import java.util.function.Consumer;
import org.hibernate.query.common.JoinType;
import org.hibernate.query.criteria.HibernateCriteriaBuilder;
import org.hibernate.query.criteria.JpaCriteriaQuery;
import org.hibernate.query.criteria.JpaDerivedJoin;
import org.hibernate.query.criteria.JpaRoot;
import org.hibernate.query.criteria.JpaSubQuery;
import org.hibernate.query.spi.QueryImplementor;
import org.hibernate.query.sqm.tree.SqmJoinType;
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
import org.hibernate.testing.orm.junit.DomainModel;
@ -62,7 +62,7 @@ public class SubQueryInFromInverseOneTests {
subquery.orderBy( cb.asc( alternativeContact.get( "name" ).get( "first" ) ) );
subquery.fetch( 1 );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, SqmJoinType.LEFT );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, JoinType.LEFT );
cq.multiselect( root.get( "name" ), a.get( "contact" ).get( "id" ) );
cq.orderBy( cb.asc( root.get( "id" ) ) );
@ -110,7 +110,7 @@ public class SubQueryInFromInverseOneTests {
subquery.orderBy( cb.desc( alternativeContact.get( "name" ).get( "first" ) ) );
subquery.fetch( 1 );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, SqmJoinType.LEFT );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, JoinType.LEFT );
final Join<Object, Object> alt = a.join( "contact" );
cq.multiselect( root.get( "name" ), alt.get( "name" ) );
@ -158,7 +158,7 @@ public class SubQueryInFromInverseOneTests {
subquery.orderBy( cb.desc( alternativeContact.get( "name" ).get( "first" ) ) );
subquery.fetch( 1 );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, SqmJoinType.LEFT );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, JoinType.LEFT );
cq.multiselect( root.get( "name" ), a.get( "contact" ).get( "name" ) );
cq.orderBy( cb.asc( root.get( "id" ) ) );

View File

@ -7,13 +7,13 @@ package org.hibernate.orm.test.query;
import java.util.Set;
import java.util.function.Consumer;
import org.hibernate.query.common.JoinType;
import org.hibernate.query.criteria.HibernateCriteriaBuilder;
import org.hibernate.query.criteria.JpaCriteriaQuery;
import org.hibernate.query.criteria.JpaDerivedJoin;
import org.hibernate.query.criteria.JpaRoot;
import org.hibernate.query.criteria.JpaSubQuery;
import org.hibernate.query.spi.QueryImplementor;
import org.hibernate.query.sqm.tree.SqmJoinType;
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
import org.hibernate.testing.orm.junit.DomainModel;
@ -62,7 +62,7 @@ public class SubQueryInFromManyToManyEmbeddedIdTests {
subquery.orderBy( cb.asc( alternativeContacts.get( "name" ).get( "first" ) ) );
subquery.fetch( 1 );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, SqmJoinType.LEFT );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, JoinType.LEFT );
cq.multiselect( root.get( "name" ), a.get( "contact" ).get( "id" ) );
cq.orderBy( cb.asc( root.get( "id" ) ) );
@ -112,7 +112,7 @@ public class SubQueryInFromManyToManyEmbeddedIdTests {
subquery.orderBy( cb.desc( alternativeContacts.get( "name" ).get( "first" ) ) );
subquery.fetch( 1 );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, SqmJoinType.LEFT );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, JoinType.LEFT );
final Join<Object, Object> alt = a.join( "contact" );
cq.multiselect( root.get( "name" ), alt.get( "name" ) );
@ -160,7 +160,7 @@ public class SubQueryInFromManyToManyEmbeddedIdTests {
subquery.orderBy( cb.desc( alternativeContacts.get( "name" ).get( "first" ) ) );
subquery.fetch( 1 );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, SqmJoinType.LEFT );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, JoinType.LEFT );
cq.multiselect( root.get( "name" ), a.get( "contact" ).get( "name" ) );
cq.orderBy( cb.asc( root.get( "id" ) ) );

View File

@ -7,13 +7,13 @@ package org.hibernate.orm.test.query;
import java.util.Set;
import java.util.function.Consumer;
import org.hibernate.query.common.JoinType;
import org.hibernate.query.criteria.HibernateCriteriaBuilder;
import org.hibernate.query.criteria.JpaCriteriaQuery;
import org.hibernate.query.criteria.JpaDerivedJoin;
import org.hibernate.query.criteria.JpaRoot;
import org.hibernate.query.criteria.JpaSubQuery;
import org.hibernate.query.spi.QueryImplementor;
import org.hibernate.query.sqm.tree.SqmJoinType;
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
import org.hibernate.testing.orm.junit.DomainModel;
@ -62,7 +62,7 @@ public class SubQueryInFromManyToManyIdClassTests {
subquery.orderBy( cb.asc( alternativeContacts.get( "name" ).get( "first" ) ) );
subquery.fetch( 1 );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, SqmJoinType.LEFT );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, JoinType.LEFT );
cq.multiselect( root.get( "name" ), a.get( "contact" ).get( "id1" ), a.get( "contact" ).get( "id2" ) );
cq.orderBy( cb.asc( root.get( "id1" ) ) );
@ -113,7 +113,7 @@ public class SubQueryInFromManyToManyIdClassTests {
subquery.orderBy( cb.desc( alternativeContacts.get( "name" ).get( "first" ) ) );
subquery.fetch( 1 );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, SqmJoinType.LEFT );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, JoinType.LEFT );
final Join<Object, Object> alt = a.join( "contact" );
cq.multiselect( root.get( "name" ), alt.get( "name" ) );
@ -161,7 +161,7 @@ public class SubQueryInFromManyToManyIdClassTests {
subquery.orderBy( cb.desc( alternativeContacts.get( "name" ).get( "first" ) ) );
subquery.fetch( 1 );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, SqmJoinType.LEFT );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, JoinType.LEFT );
cq.multiselect( root.get( "name" ), a.get( "contact" ).get( "name" ) );
cq.orderBy( cb.asc( root.get( "id1" ) ) );

View File

@ -7,13 +7,13 @@ package org.hibernate.orm.test.query;
import java.util.Set;
import java.util.function.Consumer;
import org.hibernate.query.common.JoinType;
import org.hibernate.query.criteria.HibernateCriteriaBuilder;
import org.hibernate.query.criteria.JpaCriteriaQuery;
import org.hibernate.query.criteria.JpaDerivedJoin;
import org.hibernate.query.criteria.JpaRoot;
import org.hibernate.query.criteria.JpaSubQuery;
import org.hibernate.query.spi.QueryImplementor;
import org.hibernate.query.sqm.tree.SqmJoinType;
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
import org.hibernate.testing.orm.junit.DomainModel;
@ -62,7 +62,7 @@ public class SubQueryInFromManyToManyTests {
subquery.orderBy( cb.asc( alternativeContacts.get( "name" ).get( "first" ) ) );
subquery.fetch( 1 );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, SqmJoinType.LEFT );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, JoinType.LEFT );
cq.multiselect( root.get( "name" ), a.get( "contact" ).get( "id" ) );
cq.orderBy( cb.asc( root.get( "id" ) ) );
@ -110,7 +110,7 @@ public class SubQueryInFromManyToManyTests {
subquery.orderBy( cb.desc( alternativeContacts.get( "name" ).get( "first" ) ) );
subquery.fetch( 1 );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, SqmJoinType.LEFT );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, JoinType.LEFT );
final Join<Object, Object> alt = a.join( "contact" );
cq.multiselect( root.get( "name" ), alt.get( "name" ) );
@ -158,7 +158,7 @@ public class SubQueryInFromManyToManyTests {
subquery.orderBy( cb.desc( alternativeContacts.get( "name" ).get( "first" ) ) );
subquery.fetch( 1 );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, SqmJoinType.LEFT );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, JoinType.LEFT );
cq.multiselect( root.get( "name" ), a.get( "contact" ).get( "name" ) );
cq.orderBy( cb.asc( root.get( "id" ) ) );

View File

@ -7,13 +7,13 @@ package org.hibernate.orm.test.query;
import java.util.Set;
import java.util.function.Consumer;
import org.hibernate.query.common.JoinType;
import org.hibernate.query.criteria.HibernateCriteriaBuilder;
import org.hibernate.query.criteria.JpaCriteriaQuery;
import org.hibernate.query.criteria.JpaDerivedJoin;
import org.hibernate.query.criteria.JpaRoot;
import org.hibernate.query.criteria.JpaSubQuery;
import org.hibernate.query.spi.QueryImplementor;
import org.hibernate.query.sqm.tree.SqmJoinType;
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
import org.hibernate.testing.orm.junit.DomainModel;
@ -64,7 +64,7 @@ public class SubQueryInFromOneToManyEmbeddedIdTests {
subquery.orderBy( cb.asc( alternativeContacts.get( "name" ).get( "first" ) ) );
subquery.fetch( 1 );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, SqmJoinType.LEFT );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, JoinType.LEFT );
cq.multiselect( root.get( "name" ), a.get( "contact" ).get( "id" ) );
cq.orderBy( cb.asc( root.get( "id" ) ) );
@ -114,7 +114,7 @@ public class SubQueryInFromOneToManyEmbeddedIdTests {
subquery.orderBy( cb.desc( alternativeContacts.get( "name" ).get( "first" ) ) );
subquery.fetch( 1 );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, SqmJoinType.LEFT );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, JoinType.LEFT );
final Join<Object, Object> alt = a.join( "contact" );
cq.multiselect( root.get( "name" ), alt.get( "name" ) );
@ -162,7 +162,7 @@ public class SubQueryInFromOneToManyEmbeddedIdTests {
subquery.orderBy( cb.desc( alternativeContacts.get( "name" ).get( "first" ) ) );
subquery.fetch( 1 );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, SqmJoinType.LEFT );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, JoinType.LEFT );
cq.multiselect( root.get( "name" ), a.get( "contact" ).get( "name" ) );
cq.orderBy( cb.asc( root.get( "id" ) ) );

View File

@ -7,13 +7,13 @@ package org.hibernate.orm.test.query;
import java.util.Set;
import java.util.function.Consumer;
import org.hibernate.query.common.JoinType;
import org.hibernate.query.criteria.HibernateCriteriaBuilder;
import org.hibernate.query.criteria.JpaCriteriaQuery;
import org.hibernate.query.criteria.JpaDerivedJoin;
import org.hibernate.query.criteria.JpaRoot;
import org.hibernate.query.criteria.JpaSubQuery;
import org.hibernate.query.spi.QueryImplementor;
import org.hibernate.query.sqm.tree.SqmJoinType;
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
import org.hibernate.testing.orm.junit.DomainModel;
@ -64,7 +64,7 @@ public class SubQueryInFromOneToManyIdClassTests {
subquery.orderBy( cb.asc( alternativeContacts.get( "name" ).get( "first" ) ) );
subquery.fetch( 1 );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, SqmJoinType.LEFT );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, JoinType.LEFT );
cq.multiselect( root.get( "name" ), a.get( "contact" ).get( "id1" ), a.get( "contact" ).get( "id2" ) );
cq.orderBy( cb.asc( root.get( "id1" ) ) );
@ -115,7 +115,7 @@ public class SubQueryInFromOneToManyIdClassTests {
subquery.orderBy( cb.desc( alternativeContacts.get( "name" ).get( "first" ) ) );
subquery.fetch( 1 );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, SqmJoinType.LEFT );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, JoinType.LEFT );
final Join<Object, Object> alt = a.join( "contact" );
cq.multiselect( root.get( "name" ), alt.get( "name" ) );
@ -163,7 +163,7 @@ public class SubQueryInFromOneToManyIdClassTests {
subquery.orderBy( cb.desc( alternativeContacts.get( "name" ).get( "first" ) ) );
subquery.fetch( 1 );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, SqmJoinType.LEFT );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, JoinType.LEFT );
cq.multiselect( root.get( "name" ), a.get( "contact" ).get( "name" ) );
cq.orderBy( cb.asc( root.get( "id1" ) ) );

View File

@ -7,13 +7,13 @@ package org.hibernate.orm.test.query;
import java.util.Set;
import java.util.function.Consumer;
import org.hibernate.query.common.JoinType;
import org.hibernate.query.criteria.HibernateCriteriaBuilder;
import org.hibernate.query.criteria.JpaCriteriaQuery;
import org.hibernate.query.criteria.JpaDerivedJoin;
import org.hibernate.query.criteria.JpaRoot;
import org.hibernate.query.criteria.JpaSubQuery;
import org.hibernate.query.spi.QueryImplementor;
import org.hibernate.query.sqm.tree.SqmJoinType;
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
import org.hibernate.testing.orm.junit.DomainModel;
@ -64,7 +64,7 @@ public class SubQueryInFromOneToManyTests {
subquery.orderBy( cb.asc( alternativeContacts.get( "name" ).get( "first" ) ) );
subquery.fetch( 1 );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, SqmJoinType.LEFT );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, JoinType.LEFT );
cq.multiselect( root.get( "name" ), a.get( "contact" ).get( "id" ) );
cq.orderBy( cb.asc( root.get( "id" ) ) );
@ -112,7 +112,7 @@ public class SubQueryInFromOneToManyTests {
subquery.orderBy( cb.desc( alternativeContacts.get( "name" ).get( "first" ) ) );
subquery.fetch( 1 );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, SqmJoinType.LEFT );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, JoinType.LEFT );
final Join<Object, Object> alt = a.join( "contact" );
cq.multiselect( root.get( "name" ), alt.get( "name" ) );
@ -160,7 +160,7 @@ public class SubQueryInFromOneToManyTests {
subquery.orderBy( cb.desc( alternativeContacts.get( "name" ).get( "first" ) ) );
subquery.fetch( 1 );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, SqmJoinType.LEFT );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, JoinType.LEFT );
cq.multiselect( root.get( "name" ), a.get( "contact" ).get( "name" ) );
cq.orderBy( cb.asc( root.get( "id" ) ) );

View File

@ -8,6 +8,7 @@ import java.time.LocalDate;
import java.util.List;
import java.util.function.Consumer;
import org.hibernate.query.common.JoinType;
import org.hibernate.query.criteria.HibernateCriteriaBuilder;
import org.hibernate.query.criteria.JpaCriteriaQuery;
import org.hibernate.query.criteria.JpaDerivedJoin;
@ -16,7 +17,6 @@ import org.hibernate.query.criteria.JpaRoot;
import org.hibernate.query.criteria.JpaSubQuery;
import org.hibernate.query.spi.QueryImplementor;
import org.hibernate.query.sqm.InterpretationException;
import org.hibernate.query.sqm.tree.SqmJoinType;
import org.hibernate.testing.orm.junit.Jira;
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
@ -143,7 +143,7 @@ public class SubQueryInFromTests {
subquery.orderBy( cb.asc( address.get( "line1" ) ) );
subquery.fetch( 1 );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, SqmJoinType.INNER );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, JoinType.INNER );
cq.multiselect( root.get( "name" ), a.get( "address" ) );
@ -230,7 +230,7 @@ public class SubQueryInFromTests {
subquery.orderBy( cb.asc( address.get( "line1" ) ) );
subquery.fetch( 1 );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, SqmJoinType.INNER );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, JoinType.INNER );
cq.multiselect( root.get( "name" ), a.get( "zip" ) );
@ -313,7 +313,7 @@ public class SubQueryInFromTests {
subquery.orderBy( cb.asc( alternativeContact.get( "name" ).get( "first" ) ) );
subquery.fetch( 1 );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, SqmJoinType.LEFT );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, JoinType.LEFT );
cq.multiselect( root.get( "name" ), a.get( "contact" ).get( "id" ) );
cq.where( cb.equal( root.get( "id" ), 1 ) );
@ -359,7 +359,7 @@ public class SubQueryInFromTests {
subquery.orderBy( cb.desc( alternativeContact.get( "name" ).get( "first" ) ) );
subquery.fetch( 1 );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, SqmJoinType.LEFT );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, JoinType.LEFT );
final Join<Object, Object> alt = a.join( "contact" );
cq.multiselect( root.get( "name" ), alt.get( "name" ) );
@ -407,7 +407,7 @@ public class SubQueryInFromTests {
subquery.orderBy( cb.desc( alternativeContact.get( "name" ).get( "first" ) ) );
subquery.fetch( 1 );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, SqmJoinType.LEFT );
final JpaDerivedJoin<Tuple> a = root.joinLateral( subquery, JoinType.LEFT );
cq.multiselect( root.get( "name" ), a.get( "contact" ).get( "name" ) );
cq.where( cb.equal( root.get( "id" ), 1 ) );

View File

@ -10,10 +10,10 @@ import jakarta.persistence.criteria.Root;
import org.hibernate.community.dialect.DerbyDialect;
import org.hibernate.dialect.H2Dialect;
import org.hibernate.query.common.JoinType;
import org.hibernate.query.criteria.HibernateCriteriaBuilder;
import org.hibernate.query.criteria.JpaCriteriaQuery;
import org.hibernate.query.criteria.JpaRoot;
import org.hibernate.query.sqm.tree.SqmJoinType;
import org.hibernate.testing.SkipForDialect;
import org.hibernate.testing.orm.domain.gambit.BasicEntity;
@ -157,7 +157,7 @@ public class BasicCriteriaExecutionTests {
final JpaCriteriaQuery<Object> criteria = criteriaBuilder.createQuery();
final JpaRoot<BasicEntity> root = criteria.from( BasicEntity.class );
root.join( BasicEntity.class, SqmJoinType.CROSS );
root.join( BasicEntity.class, JoinType.CROSS );
criteria.select( root );
session.createQuery( criteria ).list();

View File

@ -9,7 +9,6 @@ import java.util.Set;
import org.hibernate.query.criteria.HibernateCriteriaBuilder;
import org.hibernate.query.criteria.JpaCriteriaQuery;
import org.hibernate.query.criteria.JpaRoot;
import org.hibernate.query.sqm.tree.SqmJoinType;
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.JiraKey;
@ -42,10 +41,10 @@ public class CriteriaGetJoinsTest {
scope.inTransaction(
session -> {
HibernateCriteriaBuilder cb = session.getCriteriaBuilder();
JpaCriteriaQuery cq = cb.createQuery();
JpaCriteriaQuery<?> cq = cb.createQuery();
JpaRoot<MyEntity> root = cq.from( MyEntity.class );
root.join( "secondEntity", JoinType.LEFT );
root.join( MyEntity.class, SqmJoinType.LEFT );
root.join( MyEntity.class, org.hibernate.query.common.JoinType.LEFT );
Set<Join<MyEntity, ?>> joins = root.getJoins();
/*
SqmEntityJoin does not implement jakarta.persistence.criteria.Join, iterating through the
@ -53,7 +52,7 @@ public class CriteriaGetJoinsTest {
*/
assertThat( joins.size() ).isEqualTo( 1 );
joins.forEach( join -> join.getJoinType() );
joins.forEach( Join::getJoinType );
}
);
}

View File

@ -6,11 +6,11 @@ package org.hibernate.orm.test.query.hql;
import java.time.LocalDate;
import org.hibernate.query.common.JoinType;
import org.hibernate.query.criteria.HibernateCriteriaBuilder;
import org.hibernate.query.criteria.JpaCriteriaDelete;
import org.hibernate.query.criteria.JpaEntityJoin;
import org.hibernate.query.criteria.JpaRoot;
import org.hibernate.query.sqm.tree.SqmJoinType;
import org.hibernate.testing.orm.domain.StandardDomainModel;
import org.hibernate.testing.orm.domain.contacts.Contact;
@ -80,7 +80,7 @@ public class DeleteJoinTests {
final HibernateCriteriaBuilder cb = session.getCriteriaBuilder();
final JpaCriteriaDelete<BasicEntity> criteriaDelete = cb.createCriteriaDelete( BasicEntity.class );
final JpaRoot<BasicEntity> b = criteriaDelete.from( BasicEntity.class );
final JpaEntityJoin<BasicEntity, Contact> c = b.join( Contact.class, SqmJoinType.LEFT );
final JpaEntityJoin<BasicEntity, Contact> c = b.join( Contact.class, JoinType.LEFT );
c.on( b.get( "id" ).equalTo( c.get( "id" ) ) );
criteriaDelete.where( c.get( "id" ).isNotNull() );
int updated = session.createMutationQuery( criteriaDelete ).executeUpdate();

View File

@ -6,11 +6,11 @@ package org.hibernate.orm.test.query.hql;
import java.time.LocalDate;
import org.hibernate.query.common.JoinType;
import org.hibernate.query.criteria.HibernateCriteriaBuilder;
import org.hibernate.query.criteria.JpaCriteriaUpdate;
import org.hibernate.query.criteria.JpaEntityJoin;
import org.hibernate.query.criteria.JpaRoot;
import org.hibernate.query.sqm.tree.SqmJoinType;
import org.hibernate.testing.orm.domain.StandardDomainModel;
import org.hibernate.testing.orm.domain.contacts.Contact;
@ -81,7 +81,7 @@ public class UpdateJoinTests {
final HibernateCriteriaBuilder cb = session.getCriteriaBuilder();
final JpaCriteriaUpdate<BasicEntity> criteriaUpdate = cb.createCriteriaUpdate( BasicEntity.class );
final JpaRoot<BasicEntity> b = criteriaUpdate.from( BasicEntity.class );
final JpaEntityJoin<BasicEntity,Contact> c = b.join( Contact.class, SqmJoinType.LEFT );
final JpaEntityJoin<BasicEntity,Contact> c = b.join( Contact.class, JoinType.LEFT );
c.on( b.get( "id" ).equalTo( c.get( "id" ) ) );
criteriaUpdate.set( b.<String>get( "data" ), c.get( "name" ).get( "first" ) );
criteriaUpdate.where( c.get( "id" ).isNotNull() );