From 98a83a082c30a025e3eb1faf458b83bfc6a45baa Mon Sep 17 00:00:00 2001 From: Gavin Date: Thu, 6 Jul 2023 09:24:58 +0200 Subject: [PATCH] add lots @Override annotations and some generic type args in Jpa types removed an unused and unimplemented interface --- .../hibernate/query/criteria/JpaDmlCriteria.java | 13 ------------- .../hibernate/query/criteria/JpaInPredicate.java | 2 ++ .../org/hibernate/query/criteria/JpaMapJoin.java | 1 + .../org/hibernate/query/criteria/JpaPluralJoin.java | 6 ++++++ .../org/hibernate/query/criteria/JpaQueryGroup.java | 4 ++++ .../org/hibernate/query/criteria/JpaQueryPart.java | 4 ++-- .../hibernate/query/criteria/JpaQueryStructure.java | 12 ++++++++---- .../org/hibernate/query/criteria/JpaSelection.java | 4 ++-- .../org/hibernate/query/criteria/JpaSetJoin.java | 6 +++++- .../hibernate/query/sqm/tree/SqmDmlStatement.java | 2 ++ .../query/sqm/tree/select/SqmQueryPart.java | 4 +--- .../query/sqm/tree/select/SqmQuerySpec.java | 12 ------------ 12 files changed, 33 insertions(+), 37 deletions(-) delete mode 100644 hibernate-core/src/main/java/org/hibernate/query/criteria/JpaDmlCriteria.java diff --git a/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaDmlCriteria.java b/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaDmlCriteria.java deleted file mode 100644 index f74eb911e9..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaDmlCriteria.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * 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; - -/** - * @author Steve Ebersole - */ -public interface JpaDmlCriteria { -} diff --git a/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaInPredicate.java b/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaInPredicate.java index fd208f7041..1d1de68c5f 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaInPredicate.java +++ b/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaInPredicate.java @@ -17,6 +17,7 @@ public interface JpaInPredicate extends JpaPredicate, CriteriaBuilder.In * list of values. * @return expression */ + @Override JpaExpression getExpression(); /** @@ -24,6 +25,7 @@ public interface JpaInPredicate extends JpaPredicate, CriteriaBuilder.In * @param value value * @return in predicate */ + @Override JpaInPredicate value(T value); /** diff --git a/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaMapJoin.java b/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaMapJoin.java index 709acf8f1f..7130488239 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaMapJoin.java +++ b/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaMapJoin.java @@ -33,6 +33,7 @@ public interface JpaMapJoin extends JpaPluralJoin, V>, MapJo @Override JpaMapJoin on(Predicate... restrictions); + @Override JpaMapJoin treatAs(Class treatAsType); @Override diff --git a/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaPluralJoin.java b/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaPluralJoin.java index 25256a1490..9966a922a8 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaPluralJoin.java +++ b/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaPluralJoin.java @@ -22,15 +22,21 @@ public interface JpaPluralJoin extends JpaJoin, PluralJoin getAttribute(); + @Override JpaPluralJoin on(JpaExpression restriction); + @Override JpaPluralJoin on(Expression restriction); + @Override JpaPluralJoin on(JpaPredicate... restrictions); + @Override JpaPluralJoin on(Predicate... restrictions); + @Override JpaPluralJoin treatAs(Class treatAsType); + @Override JpaPluralJoin treatAs(EntityDomainType treatAsType); } diff --git a/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaQueryGroup.java b/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaQueryGroup.java index 06ef6835f5..9b69713291 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaQueryGroup.java +++ b/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaQueryGroup.java @@ -27,12 +27,16 @@ public interface JpaQueryGroup extends JpaQueryPart { // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Covariant overrides + @Override JpaQueryGroup setSortSpecifications(List sortSpecifications); + @Override JpaQueryGroup setOffset(JpaExpression offset); + @Override JpaQueryGroup setFetch(JpaExpression fetch); + @Override JpaQueryGroup setFetch(JpaExpression fetch, FetchClauseType fetchClauseType); } diff --git a/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaQueryPart.java b/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaQueryPart.java index 12b6f00eca..b18eb348a2 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaQueryPart.java +++ b/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaQueryPart.java @@ -31,11 +31,11 @@ public interface JpaQueryPart extends JpaCriteriaNode { // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Limit/Offset/Fetch clause - JpaExpression getOffset(); + JpaExpression getOffset(); JpaQueryPart setOffset(JpaExpression offset); - JpaExpression getFetch(); + JpaExpression getFetch(); JpaQueryPart setFetch(JpaExpression fetch); diff --git a/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaQueryStructure.java b/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaQueryStructure.java index 5dc2cd1554..8e44b78966 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaQueryStructure.java +++ b/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaQueryStructure.java @@ -34,11 +34,11 @@ public interface JpaQueryStructure extends JpaQueryPart { boolean isDistinct(); - JpaQueryStructure setDistinct(boolean distinct); + JpaQueryStructure setDistinct(boolean distinct); JpaSelection getSelection(); - JpaQueryStructure setSelection(JpaSelection selection); + JpaQueryStructure setSelection(JpaSelection selection); // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -48,7 +48,7 @@ public interface JpaQueryStructure extends JpaQueryPart { List> getRootList(); - JpaQueryStructure addRoot(JpaRoot root); + JpaQueryStructure addRoot(JpaRoot root); // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -66,7 +66,7 @@ public interface JpaQueryStructure extends JpaQueryPart { // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Grouping (group-by / having) clause - List getGroupingExpressions(); + List> getGroupingExpressions(); JpaQueryStructure setGroupingExpressions(List> grouping); @@ -83,11 +83,15 @@ public interface JpaQueryStructure extends JpaQueryPart { // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Covariant overrides + @Override JpaQueryStructure setSortSpecifications(List sortSpecifications); + @Override JpaQueryStructure setOffset(JpaExpression offset); + @Override JpaQueryStructure setFetch(JpaExpression fetch); + @Override JpaQueryStructure setFetch(JpaExpression fetch, FetchClauseType fetchClauseType); } diff --git a/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaSelection.java b/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaSelection.java index fbaf95deb9..8499413829 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaSelection.java +++ b/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaSelection.java @@ -6,6 +6,7 @@ */ package org.hibernate.query.criteria; +import java.util.Collections; import java.util.List; import jakarta.persistence.criteria.Selection; @@ -18,9 +19,8 @@ public interface JpaSelection extends JpaTupleElement, Selection { List> getSelectionItems(); @Override - @SuppressWarnings("unchecked") default List> getCompoundSelectionItems() { - return (List) getSelectionItems(); + return Collections.unmodifiableList( getSelectionItems() ); } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaSetJoin.java b/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaSetJoin.java index 89fd5a99af..89defa3b74 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaSetJoin.java +++ b/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaSetJoin.java @@ -9,7 +9,6 @@ package org.hibernate.query.criteria; import java.util.Set; import org.hibernate.metamodel.model.domain.EntityDomainType; -import org.hibernate.metamodel.model.domain.PluralPersistentAttribute; import jakarta.persistence.criteria.Expression; import jakarta.persistence.criteria.Predicate; @@ -22,15 +21,20 @@ import jakarta.persistence.criteria.SetJoin; */ public interface JpaSetJoin extends JpaPluralJoin, T>, SetJoin { + @Override JpaSetJoin on(JpaExpression restriction); JpaSetJoin on(Expression restriction); + @Override JpaSetJoin on(JpaPredicate... restrictions); + @Override JpaSetJoin on(Predicate... restrictions); + @Override JpaSetJoin treatAs(Class treatAsType); + @Override JpaSetJoin treatAs(EntityDomainType treatAsType); } diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/SqmDmlStatement.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/SqmDmlStatement.java index 02a0c95160..21efa33d2b 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/SqmDmlStatement.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/SqmDmlStatement.java @@ -24,10 +24,12 @@ public interface SqmDmlStatement extends SqmStatement, SqmCteContainer, Jp /** * Get the root path that is the target of the DML statement. */ + @Override SqmRoot getTarget(); /** * Set the root path */ + @Override void setTarget(JpaRoot root); } diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/select/SqmQueryPart.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/select/SqmQueryPart.java index 5fcdcb70fd..b64e1e5647 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/select/SqmQueryPart.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/select/SqmQueryPart.java @@ -143,12 +143,11 @@ public abstract class SqmQueryPart implements SqmVisitableNode, JpaQueryPart< } //noinspection unchecked - getOrderByClause().setSortSpecifications( (List) sortSpecifications ); + getOrderByClause().setSortSpecifications( (List) sortSpecifications ); return this; } - @SuppressWarnings("unchecked") @Override public SqmExpression getOffset() { return getOffsetExpression(); @@ -160,7 +159,6 @@ public abstract class SqmQueryPart implements SqmVisitableNode, JpaQueryPart< return this; } - @SuppressWarnings("unchecked") @Override public SqmExpression getFetch() { return getFetchExpression(); diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/select/SqmQuerySpec.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/select/SqmQuerySpec.java index 01a7e1231e..eeffe78301 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/select/SqmQuerySpec.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/select/SqmQuerySpec.java @@ -444,24 +444,12 @@ public class SqmQuerySpec extends SqmQueryPart return this; } - @Override - @SuppressWarnings("unchecked") - public SqmExpression getOffset() { - return getOffsetExpression(); - } - @Override public SqmQuerySpec setOffset(JpaExpression offset) { setOffsetExpression( (SqmExpression) offset ); return this; } - @Override - @SuppressWarnings("unchecked") - public SqmExpression getFetch() { - return getFetchExpression(); - } - @Override public SqmQuerySpec setFetch(JpaExpression fetch) { setFetchExpression( (SqmExpression) fetch );