remove deprecated methods made obsolete by Map.of()

This commit is contained in:
Gavin King 2024-11-14 00:27:45 +01:00
parent dd858e3dbf
commit e2f3adc96f
4 changed files with 2 additions and 66 deletions

View File

@ -138,25 +138,6 @@ public interface NaturalIdLoadAccess<T> {
*/
NaturalIdLoadAccess<T> using(Map<String,?> mappings);
/**
* Set multiple {@link org.hibernate.annotations.NaturalId @NaturalId}
* attribute values at once. An even number of arguments is expected,
* with each attribute name followed by its value, for example:
* <pre>
* Book book =
* session.byNaturalId(Book.class)
* .using(Book_.ISBN, isbn, Book_.PRINTING, printing)
* .load();
* </pre>
*
* @return {@code this}, for method chaining
*
* @deprecated use {@link #using(Map)} with {@link Map#of}, which is
* slightly more typesafe
*/
@Deprecated(since = "6.3", forRemoval = true)
NaturalIdLoadAccess<T> using(Object... mappings);
/**
* Determines if cached natural id cross-references are synchronized
* before query execution with unflushed modifications made in memory

View File

@ -4,13 +4,10 @@
*/
package org.hibernate;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.hibernate.graph.GraphSemantic;
import org.hibernate.graph.RootGraph;
import org.hibernate.internal.util.collections.CollectionHelper;
import java.util.List;
/**
* Loads multiple instances of a given entity type at once, by
@ -174,27 +171,4 @@ public interface NaturalIdMultiLoadAccess<T> {
* @return The managed entities.
*/
List<T> multiLoad(List<?> ids);
/**
* Helper for creating a {@link Map} that represents the value of a
* composite natural id. An even number of arguments is expected,
* with each attribute name followed by its value.
*
* @see NaturalIdLoadAccess#using(Object...)
*
* @deprecated use {@link Map#of} instead
*/
@Deprecated(since = "6.3", forRemoval = true)
static Map<String,?> compoundValue(Object... elements) {
assert elements != null;
assert elements.length % 2 == 0;
final HashMap<String, Object> map = new HashMap<>();
CollectionHelper.collectMapEntries( map::put, elements );
for ( int i = 0; i < elements.length; i += 2 ) {
map.put( (String) elements[ i ], (Object) elements[ i+1 ] );
}
return map;
}
}

View File

@ -16,7 +16,6 @@ import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.BiConsumer;
import java.util.function.Function;
import static java.util.Arrays.asList;
@ -377,17 +376,6 @@ public final class CollectionHelper {
}
}
@Deprecated(forRemoval = true)
@SuppressWarnings( "unchecked" )
public static <K,V> void collectMapEntries(BiConsumer<K, V> mapEntryConsumer, Object[] mappings) {
// even numbered
assert mappings.length % 2 == 0;
for ( int i = 0; i < mappings.length; i += 2 ) {
mapEntryConsumer.accept( (K) mappings[i], (V) mappings[i+1] );
}
}
public static <O> List<O> combine(List<O> list1, List<O> list2) {
final ArrayList<O> combined = arrayList( list1.size() + list2.size() );
combined.addAll( list1 );

View File

@ -13,7 +13,6 @@ import org.hibernate.LockOptions;
import org.hibernate.NaturalIdLoadAccess;
import org.hibernate.graph.GraphSemantic;
import org.hibernate.graph.RootGraph;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.metamodel.mapping.EntityMappingType;
/**
@ -49,12 +48,6 @@ public class NaturalIdLoadAccessImpl<T> extends BaseNaturalIdLoadAccessImpl<T> i
return this;
}
@Override @Deprecated(forRemoval = true)
public NaturalIdLoadAccess<T> using(Object... mappings) {
CollectionHelper.collectMapEntries( naturalIdParameters::put, mappings );
return this;
}
@Override
public NaturalIdLoadAccessImpl<T> setSynchronizationEnabled(boolean synchronizationEnabled) {
super.synchronizationEnabled( synchronizationEnabled );