remove deprecated Sort annotation
This commit is contained in:
parent
d0afd6359e
commit
bbf4619fcd
|
@ -1173,11 +1173,6 @@ The https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibern
|
|||
|
||||
See the <<chapters/domain/entity.adoc#locking-optimistic-lock-type-dirty-example, `OptimisticLockType.DIRTY` mapping>> section for more info on how `@SelectBeforeUpdate` works.
|
||||
|
||||
[[annotations-hibernate-sort]]
|
||||
==== [line-through]#`@Sort`#
|
||||
|
||||
The https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/annotations/Sort.html[[line-through]#`@Sort`#] annotation is deprecated. Use the Hibernate specific <<annotations-hibernate-sortcomparator>> or <<annotations-hibernate-sortnatural>> annotations instead.
|
||||
|
||||
[[annotations-hibernate-sortcomparator]]
|
||||
==== `@SortComparator`
|
||||
|
||||
|
|
|
@ -1,40 +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.annotations;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import static java.lang.annotation.ElementType.FIELD;
|
||||
import static java.lang.annotation.ElementType.METHOD;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
/**
|
||||
* Collection sort (in-memory sorting). Different than ordering, which is applied during the SQL select.
|
||||
*
|
||||
* @author Emmanuel Bernard
|
||||
*
|
||||
* @see OrderBy
|
||||
*
|
||||
* @deprecated Use {@link SortComparator} or {@link SortNatural} instead depending on need.
|
||||
*/
|
||||
@Target({METHOD, FIELD})
|
||||
@Retention(RUNTIME)
|
||||
@Deprecated
|
||||
public @interface Sort {
|
||||
/**
|
||||
* The type of sorting to use. The default is to not use sorting.
|
||||
*/
|
||||
SortType type() default SortType.UNSORTED;
|
||||
|
||||
/**
|
||||
* Specifies the comparator to use. Only valid when {@link #type} specifies {@link SortType#COMPARATOR}.
|
||||
*
|
||||
* TODO find a way to use {@code Class<Comparator>} -> see HHH-8164
|
||||
*/
|
||||
Class comparator() default void.class;
|
||||
}
|
|
@ -1,30 +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.annotations;
|
||||
|
||||
/**
|
||||
* Possible collection sorting strategies.
|
||||
*
|
||||
* @author Emmanuel Bernard
|
||||
*
|
||||
* @deprecated Since {@link Sort} is deprecated.
|
||||
*/
|
||||
@Deprecated
|
||||
public enum SortType {
|
||||
/**
|
||||
* The collection is unsorted.
|
||||
*/
|
||||
UNSORTED,
|
||||
/**
|
||||
* The collection is sorted using its natural sorting.
|
||||
*/
|
||||
NATURAL,
|
||||
/**
|
||||
* The collection is sorted using a supplied comparator.
|
||||
*/
|
||||
COMPARATOR
|
||||
}
|
|
@ -116,7 +116,6 @@ import org.hibernate.annotations.ParamDef;
|
|||
import org.hibernate.annotations.Parameter;
|
||||
import org.hibernate.annotations.Parent;
|
||||
import org.hibernate.annotations.Proxy;
|
||||
import org.hibernate.annotations.Sort;
|
||||
import org.hibernate.annotations.SortComparator;
|
||||
import org.hibernate.annotations.SortNatural;
|
||||
import org.hibernate.annotations.Source;
|
||||
|
@ -2043,7 +2042,6 @@ public final class AnnotationBinder {
|
|||
collectionBinder.setJpaOrderBy( property.getAnnotation( javax.persistence.OrderBy.class ) );
|
||||
collectionBinder.setSqlOrderBy( property.getAnnotation( OrderBy.class ) );
|
||||
|
||||
collectionBinder.setSort( property.getAnnotation( Sort.class ) );
|
||||
collectionBinder.setNaturalSort( property.getAnnotation( SortNatural.class ) );
|
||||
collectionBinder.setComparatorSort( property.getAnnotation( SortComparator.class ) );
|
||||
|
||||
|
|
|
@ -60,10 +60,8 @@ import org.hibernate.annotations.SQLDelete;
|
|||
import org.hibernate.annotations.SQLDeleteAll;
|
||||
import org.hibernate.annotations.SQLInsert;
|
||||
import org.hibernate.annotations.SQLUpdate;
|
||||
import org.hibernate.annotations.Sort;
|
||||
import org.hibernate.annotations.SortComparator;
|
||||
import org.hibernate.annotations.SortNatural;
|
||||
import org.hibernate.annotations.SortType;
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.hibernate.annotations.WhereJoinTable;
|
||||
import org.hibernate.annotations.common.reflection.XClass;
|
||||
|
@ -170,7 +168,6 @@ public abstract class CollectionBinder {
|
|||
private boolean isSortedCollection;
|
||||
private javax.persistence.OrderBy jpaOrderBy;
|
||||
private OrderBy sqlOrderBy;
|
||||
private Sort deprecatedSort;
|
||||
private SortNatural naturalSort;
|
||||
private SortComparator comparatorSort;
|
||||
|
||||
|
@ -247,10 +244,6 @@ public abstract class CollectionBinder {
|
|||
this.sqlOrderBy = sqlOrderBy;
|
||||
}
|
||||
|
||||
public void setSort(Sort deprecatedSort) {
|
||||
this.deprecatedSort = deprecatedSort;
|
||||
}
|
||||
|
||||
public void setNaturalSort(SortNatural naturalSort) {
|
||||
this.naturalSort = naturalSort;
|
||||
}
|
||||
|
@ -623,21 +616,7 @@ public abstract class CollectionBinder {
|
|||
Class<? extends Comparator<?>> comparatorClass = null;
|
||||
|
||||
if ( jpaOrderBy == null && sqlOrderBy == null ) {
|
||||
if ( deprecatedSort != null ) {
|
||||
LOG.debug( "Encountered deprecated @Sort annotation; use @SortNatural or @SortComparator instead." );
|
||||
if ( naturalSort != null || comparatorSort != null ) {
|
||||
throw buildIllegalSortCombination();
|
||||
}
|
||||
hadExplicitSort = deprecatedSort.type() != SortType.UNSORTED;
|
||||
if ( deprecatedSort.type() == SortType.NATURAL ) {
|
||||
isSortedCollection = true;
|
||||
}
|
||||
else if ( deprecatedSort.type() == SortType.COMPARATOR ) {
|
||||
isSortedCollection = true;
|
||||
comparatorClass = deprecatedSort.comparator();
|
||||
}
|
||||
}
|
||||
else if ( naturalSort != null ) {
|
||||
if ( naturalSort != null ) {
|
||||
if ( comparatorSort != null ) {
|
||||
throw buildIllegalSortCombination();
|
||||
}
|
||||
|
@ -692,7 +671,6 @@ public abstract class CollectionBinder {
|
|||
String.format(
|
||||
"Illegal combination of annotations on %s. Only one of @%s, @%s and @%s can be used",
|
||||
safeCollectionRole(),
|
||||
Sort.class.getName(),
|
||||
SortNatural.class.getName(),
|
||||
SortComparator.class.getName()
|
||||
)
|
||||
|
|
|
@ -11,7 +11,6 @@ import java.util.Map;
|
|||
import org.hibernate.AnnotationException;
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.annotations.OrderBy;
|
||||
import org.hibernate.annotations.Sort;
|
||||
import org.hibernate.annotations.common.reflection.XClass;
|
||||
import org.hibernate.annotations.common.reflection.XProperty;
|
||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||
|
@ -38,7 +37,7 @@ import org.jboss.logging.Logger;
|
|||
* @author Matthew Inger
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
@SuppressWarnings({"unchecked", "serial"})
|
||||
@SuppressWarnings("unchecked")
|
||||
public class ListBinder extends CollectionBinder {
|
||||
private static final CoreMessageLogger LOG = Logger.getMessageLogger( CoreMessageLogger.class, ListBinder.class.getName() );
|
||||
|
||||
|
@ -58,13 +57,6 @@ public class ListBinder extends CollectionBinder {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSort(Sort sortAnn) {
|
||||
if ( sortAnn != null ) {
|
||||
LOG.sortAnnotationIndexedCollection();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SecondPass getSecondPass(
|
||||
final Ejb3JoinColumn[] fkJoinColumns,
|
||||
|
|
|
@ -18,8 +18,7 @@ import javax.persistence.Id;
|
|||
import javax.persistence.MapKeyColumn;
|
||||
|
||||
import org.hibernate.annotations.MapKeyType;
|
||||
import org.hibernate.annotations.Sort;
|
||||
import org.hibernate.annotations.SortType;
|
||||
import org.hibernate.annotations.SortNatural;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
/**
|
||||
|
@ -34,7 +33,7 @@ public class Matrix {
|
|||
|
||||
@MapKeyType( @Type(type="integer") )
|
||||
@ElementCollection
|
||||
@Sort(type = SortType.NATURAL)
|
||||
@SortNatural
|
||||
@Type(type = "float")
|
||||
@MapKeyColumn(nullable = false)
|
||||
private SortedMap<Integer, Float> mvalues = new TreeMap<Integer, Float>();
|
||||
|
|
|
@ -30,7 +30,6 @@ import static org.hamcrest.MatcherAssert.assertThat;
|
|||
* <ul>
|
||||
* <li>{@link org.hibernate.annotations.SortNatural @SortNatural}</li>
|
||||
* <li>{@link org.hibernate.annotations.SortComparator @SortComparator}</li>
|
||||
* <li>{@link org.hibernate.annotations.Sort @Sort}</li>
|
||||
* <li>{@link org.hibernate.annotations.OrderBy @OrderBy(from hibernate)}</li>
|
||||
* <li>{@link javax.persistence.OrderBy @OrderBy(from JPA)}</li>
|
||||
* </ul>
|
||||
|
|
|
@ -20,8 +20,7 @@ import javax.persistence.OneToMany;
|
|||
import javax.persistence.OneToOne;
|
||||
|
||||
import org.hibernate.annotations.Cascade;
|
||||
import org.hibernate.annotations.Sort;
|
||||
import org.hibernate.annotations.SortType;
|
||||
import org.hibernate.annotations.SortComparator;
|
||||
|
||||
import static org.hibernate.annotations.CascadeType.ALL;
|
||||
|
||||
|
@ -62,7 +61,7 @@ public class Customer implements Serializable {
|
|||
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "CUST_ID")
|
||||
@Sort(type = SortType.COMPARATOR, comparator = TicketComparator.class)
|
||||
@SortComparator(TicketComparator.class)
|
||||
public SortedSet<Ticket> getTickets() {
|
||||
return tickets;
|
||||
}
|
||||
|
|
|
@ -15,8 +15,7 @@ import javax.persistence.Id;
|
|||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.MapKey;
|
||||
|
||||
import org.hibernate.annotations.Sort;
|
||||
import org.hibernate.annotations.SortType;
|
||||
import org.hibernate.annotations.SortNatural;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
|
@ -24,7 +23,7 @@ import org.hibernate.annotations.SortType;
|
|||
@Entity
|
||||
public class Training {
|
||||
@Id @GeneratedValue private Long id;
|
||||
@Sort(type= SortType.NATURAL)
|
||||
@SortNatural
|
||||
@MapKey(name="name") @ManyToMany SortedMap<String, Trainee> trainees = new TreeMap<String, Trainee>();
|
||||
|
||||
public Long getId() {
|
||||
|
|
|
@ -16,8 +16,7 @@ import javax.persistence.Id;
|
|||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.MapKeyJoinColumn;
|
||||
|
||||
import org.hibernate.annotations.Sort;
|
||||
import org.hibernate.annotations.SortType;
|
||||
import org.hibernate.annotations.SortComparator;
|
||||
import org.hibernate.envers.Audited;
|
||||
import org.hibernate.envers.test.entities.StrTestEntity;
|
||||
import org.hibernate.envers.test.entities.StrTestEntityComparator;
|
||||
|
@ -37,12 +36,12 @@ public class SortedSetEntity {
|
|||
|
||||
@Audited
|
||||
@ManyToMany
|
||||
@Sort(type = SortType.COMPARATOR, comparator = StrTestEntityComparator.class)
|
||||
@SortComparator(StrTestEntityComparator.class)
|
||||
private SortedSet<StrTestEntity> sortedSet = new TreeSet<StrTestEntity>( StrTestEntityComparator.INSTANCE );
|
||||
@Audited
|
||||
@ElementCollection
|
||||
@MapKeyJoinColumn
|
||||
@Sort(type = SortType.COMPARATOR, comparator = StrTestEntityComparator.class)
|
||||
@SortComparator(StrTestEntityComparator.class)
|
||||
private SortedMap<StrTestEntity, String> sortedMap = new TreeMap<StrTestEntity, String>( StrTestEntityComparator.INSTANCE );
|
||||
|
||||
public SortedSetEntity() {
|
||||
|
|
|
@ -13,7 +13,7 @@ import javax.persistence.GeneratedValue;
|
|||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToMany;
|
||||
|
||||
import org.hibernate.annotations.Sort;
|
||||
import org.hibernate.annotations.SortNatural;
|
||||
|
||||
/**
|
||||
* @author Hardy Ferentschik
|
||||
|
@ -25,11 +25,11 @@ public class Printer {
|
|||
private long id;
|
||||
|
||||
@OneToMany
|
||||
@Sort
|
||||
@SortNatural
|
||||
private SortedSet<PrintJob> printQueue;
|
||||
|
||||
@OneToMany
|
||||
@Sort
|
||||
@SortNatural
|
||||
private SortedMap<String, PrintJob> printedJobs;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue