Skip to content

Commit ec4310a

Browse files
committed
HHH-18843 remove deprecated @orderby
1 parent f7a8144 commit ec4310a

File tree

16 files changed

+16
-339
lines changed

16 files changed

+16
-339
lines changed

documentation/src/main/asciidoc/userguide/chapters/domain/collections.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ after the collection is loaded, the collection would need to be refreshed to re-
156156
the elements. For this reason, ordered sets are not recommended - if the application
157157
needs ordering of the set elements, a sorted set should be preferred. For this reason,
158158
it is not covered in the User Guide. See the javadocs for `jakarta.persistence.OrderBy`
159-
or `org.hibernate.annotations.OrderBy` for details.
159+
or `org.hibernate.annotations.SQLOrder` for details.
160160

161161
There are 2 options for sorting a set - naturally or using an explicit comparator.
162162

hibernate-core/src/main/java/org/hibernate/annotations/DialectOverride.java

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -90,33 +90,6 @@ public interface DialectOverride {
9090
Check[] value();
9191
}
9292

93-
/**
94-
* Specializes an {@link org.hibernate.annotations.OrderBy}
95-
* in a certain dialect.
96-
*
97-
* @deprecated Use {@link SQLOrder}
98-
*/
99-
@Target({METHOD, FIELD})
100-
@Retention(RUNTIME)
101-
@Repeatable(OrderBys.class)
102-
@OverridesAnnotation(org.hibernate.annotations.OrderBy.class)
103-
@Deprecated(since = "6.3", forRemoval = true)
104-
@interface OrderBy {
105-
/**
106-
* The {@link Dialect} in which this override applies.
107-
*/
108-
Class<? extends Dialect> dialect();
109-
Version before() default @Version(major = MAX_VALUE);
110-
Version sameOrAfter() default @Version(major = MIN_VALUE);
111-
112-
org.hibernate.annotations.OrderBy override();
113-
}
114-
@Target({METHOD, FIELD})
115-
@Retention(RUNTIME)
116-
@interface OrderBys {
117-
OrderBy[] value();
118-
}
119-
12093
/**
12194
* Specializes an {@link org.hibernate.annotations.SQLOrder}
12295
* in a certain dialect.

hibernate-core/src/main/java/org/hibernate/annotations/OrderBy.java

Lines changed: 0 additions & 65 deletions
This file was deleted.

hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionBinder.java

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ public abstract class CollectionBinder {
237237
private boolean hibernateExtensionMapping;
238238

239239
private jakarta.persistence.OrderBy jpaOrderBy;
240-
private org.hibernate.annotations.OrderBy sqlOrderBy;
241240
private SQLOrder sqlOrder;
242241
private SortNatural naturalSort;
243242
private SortComparator comparatorSort;
@@ -287,7 +286,6 @@ public static void bindCollection(
287286
collectionBinder.setMapKey( property.getAnnotationUsage( MapKey.class, sourceModelContext ) );
288287
collectionBinder.setPropertyName( inferredData.getPropertyName() );
289288
collectionBinder.setJpaOrderBy( property.getAnnotationUsage( OrderBy.class, sourceModelContext ) );
290-
collectionBinder.setSqlOrderBy( getOverridableAnnotation( property, org.hibernate.annotations.OrderBy.class, context ) );
291289
collectionBinder.setSqlOrder( getOverridableAnnotation( property, SQLOrder.class, context ) );
292290
collectionBinder.setNaturalSort( property.getAnnotationUsage( SortNatural.class, sourceModelContext ) );
293291
collectionBinder.setComparatorSort( property.getAnnotationUsage( SortComparator.class, sourceModelContext ) );
@@ -841,11 +839,6 @@ public void setJpaOrderBy(jakarta.persistence.OrderBy jpaOrderBy) {
841839
this.jpaOrderBy = jpaOrderBy;
842840
}
843841

844-
@SuppressWarnings("removal")
845-
public void setSqlOrderBy(org.hibernate.annotations.OrderBy sqlOrderBy) {
846-
this.sqlOrderBy = sqlOrderBy;
847-
}
848-
849842
public void setSqlOrder(SQLOrder sqlOrder) {
850843
this.sqlOrder = sqlOrder;
851844
}
@@ -1095,7 +1088,7 @@ private static CollectionClassification determineCollectionClassification(
10951088
}
10961089

10971090
if ( property.hasDirectAnnotationUsage( jakarta.persistence.OrderBy.class )
1098-
|| property.hasDirectAnnotationUsage( org.hibernate.annotations.OrderBy.class ) ) {
1091+
|| property.hasDirectAnnotationUsage( org.hibernate.annotations.SQLOrder.class ) ) {
10991092
return CollectionClassification.BAG;
11001093
}
11011094

@@ -1443,15 +1436,12 @@ else if ( comparatorSort != null ) {
14431436
comparatorClass = null;
14441437
}
14451438

1446-
if ( jpaOrderBy != null && ( sqlOrderBy != null || sqlOrder != null ) ) {
1439+
if ( jpaOrderBy != null && sqlOrder != null ) {
14471440
throw buildIllegalOrderCombination();
14481441
}
1449-
boolean ordered = jpaOrderBy != null || sqlOrderBy != null || sqlOrder != null ;
1442+
final boolean ordered = jpaOrderBy != null || sqlOrder != null ;
14501443
if ( ordered ) {
14511444
// we can only apply the sql-based order by up front. The jpa order by has to wait for second pass
1452-
if ( sqlOrderBy != null ) {
1453-
collection.setOrderBy( sqlOrderBy.clause() );
1454-
}
14551445
if ( sqlOrder != null ) {
14561446
collection.setOrderBy( sqlOrder.value() );
14571447
}
@@ -1490,7 +1480,7 @@ private AnnotationException buildIllegalOrderCombination() {
14901480
"Collection '%s' is annotated both '@%s' and '@%s'",
14911481
safeCollectionRole(),
14921482
jakarta.persistence.OrderBy.class.getName(),
1493-
org.hibernate.annotations.OrderBy.class.getName()
1483+
org.hibernate.annotations.SQLOrder.class.getName()
14941484
)
14951485
);
14961486
}
@@ -1502,7 +1492,7 @@ private AnnotationException buildIllegalOrderAndSortCombination() {
15021492
"Collection '%s' is both sorted and ordered (only one of '@%s', '@%s', '@%s', and '@%s' may be used)",
15031493
safeCollectionRole(),
15041494
jakarta.persistence.OrderBy.class.getName(),
1505-
org.hibernate.annotations.OrderBy.class.getName(),
1495+
org.hibernate.annotations.SQLOrder.class.getName(),
15061496
SortComparator.class.getName(),
15071497
SortNatural.class.getName()
15081498
)

hibernate-core/src/main/java/org/hibernate/boot/model/internal/ListBinder.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
import java.util.Map;
88
import java.util.function.Supplier;
99

10-
import org.hibernate.AnnotationException;
1110
import org.hibernate.MappingException;
12-
import org.hibernate.annotations.OrderBy;
1311
import org.hibernate.boot.spi.MetadataBuildingContext;
1412
import org.hibernate.boot.spi.SecondPass;
1513
import org.hibernate.mapping.Collection;
@@ -47,13 +45,6 @@ protected Collection createCollection(PersistentClass owner) {
4745
return new List( getCustomTypeBeanResolver(), owner, getBuildingContext() );
4846
}
4947

50-
@Override
51-
public void setSqlOrderBy(OrderBy orderByAnn) {
52-
if ( orderByAnn != null ) {
53-
throw new AnnotationException( "A collection of type 'List' is annotated '@OrderBy'" );
54-
}
55-
}
56-
5748
@Override
5849
public SecondPass getSecondPass() {
5950
return new CollectionSecondPass( ListBinder.this.collection ) {

hibernate-core/src/main/java/org/hibernate/boot/model/internal/SetBinder.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import java.util.function.Supplier;
88

9-
import org.hibernate.annotations.OrderBy;
109
import org.hibernate.boot.spi.MetadataBuildingContext;
1110
import org.hibernate.mapping.Collection;
1211
import org.hibernate.mapping.PersistentClass;
@@ -34,10 +33,4 @@ protected Collection createCollection(PersistentClass persistentClass) {
3433
return new Set( getCustomTypeBeanResolver(), persistentClass, getBuildingContext() );
3534
}
3635

37-
@Override
38-
public void setSqlOrderBy(OrderBy orderByAnn) {
39-
if ( orderByAnn != null ) {
40-
super.setSqlOrderBy( orderByAnn );
41-
}
42-
}
4336
}

hibernate-core/src/main/java/org/hibernate/boot/models/DialectOverrideAnnotations.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
import org.hibernate.boot.models.annotations.internal.OverriddenGeneratedColumnsAnnotation;
2828
import org.hibernate.boot.models.annotations.internal.OverriddenJoinFormulaAnnotation;
2929
import org.hibernate.boot.models.annotations.internal.OverriddenJoinFormulasAnnotation;
30-
import org.hibernate.boot.models.annotations.internal.OverriddenOrderByAnnotation;
31-
import org.hibernate.boot.models.annotations.internal.OverriddenOrderBysAnnotation;
3230
import org.hibernate.boot.models.annotations.internal.OverriddenSQLDeleteAllAnnotation;
3331
import org.hibernate.boot.models.annotations.internal.OverriddenSQLDeleteAllsAnnotation;
3432
import org.hibernate.boot.models.annotations.internal.OverriddenSQLDeleteAnnotation;
@@ -61,15 +59,6 @@ public interface DialectOverrideAnnotations {
6159
OverriddenCheckAnnotation.class,
6260
DIALECT_OVERRIDE_CHECKS
6361
);
64-
OrmAnnotationDescriptor<DialectOverride.OrderBys, OverriddenOrderBysAnnotation> DIALECT_OVERRIDE_ORDER_BYS = new OrmAnnotationDescriptor<>(
65-
DialectOverride.OrderBys.class,
66-
OverriddenOrderBysAnnotation.class
67-
);
68-
OrmAnnotationDescriptor<DialectOverride.OrderBy, OverriddenOrderByAnnotation> DIALECT_OVERRIDE_ORDER_BY = new OrmAnnotationDescriptor<>(
69-
DialectOverride.OrderBy.class,
70-
OverriddenOrderByAnnotation.class,
71-
DIALECT_OVERRIDE_ORDER_BYS
72-
);
7362
OrmAnnotationDescriptor<DialectOverride.ColumnDefaults, OverriddenColumnDefaultsAnnotation> DIALECT_OVERRIDE_COLUMN_DEFAULTS = new OrmAnnotationDescriptor<>(
7463
DialectOverride.ColumnDefaults.class,
7564
OverriddenColumnDefaultsAnnotation.class

hibernate-core/src/main/java/org/hibernate/boot/models/HibernateAnnotations.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -470,10 +470,6 @@ public interface HibernateAnnotations {
470470
OptimisticLocking.class,
471471
OptimisticLockingAnnotation.class
472472
);
473-
OrmAnnotationDescriptor<OrderBy,OrderByAnnotation> ORDER_BY = new OrmAnnotationDescriptor<>(
474-
OrderBy.class,
475-
OrderByAnnotation.class
476-
);
477473
OrmAnnotationDescriptor<ParamDef,ParamDefAnnotation> PARAM_DEF = new OrmAnnotationDescriptor<>(
478474
ParamDef.class,
479475
ParamDefAnnotation.class

hibernate-core/src/main/java/org/hibernate/boot/models/annotations/internal/OrderByAnnotation.java

Lines changed: 0 additions & 54 deletions
This file was deleted.

hibernate-core/src/main/java/org/hibernate/boot/models/annotations/internal/OverriddenOrderByAnnotation.java

Lines changed: 0 additions & 76 deletions
This file was deleted.

0 commit comments

Comments
 (0)