HHH-12730 Add deprecated constructors taking a SessionImplementor

This commit is contained in:
Guillaume Smet 2018-07-25 18:08:24 +02:00
parent dfa2bc0685
commit a4dd9a96d9
7 changed files with 152 additions and 0 deletions

View File

@ -86,6 +86,14 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
this.session = session; this.session = session;
} }
/**
* * @deprecated {@link #AbstractPersistentCollection(SharedSessionContractImplementor)} should be used instead.
*/
@Deprecated
protected AbstractPersistentCollection(SessionImplementor session) {
this( (SharedSessionContractImplementor) session );
}
@Override @Override
public final String getRole() { public final String getRole() {
return role; return role;

View File

@ -18,6 +18,7 @@ import java.util.ListIterator;
import java.util.Map; import java.util.Map;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.loader.CollectionAliases; import org.hibernate.loader.CollectionAliases;
import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.persister.collection.CollectionPersister;
@ -55,6 +56,17 @@ public class PersistentIdentifierBag extends AbstractPersistentCollection implem
super( session ); super( session );
} }
/**
* Constructs a PersistentIdentifierBag.
*
* @param session The session
* @deprecated {@link #PersistentIdentifierBag(SharedSessionContractImplementor)} should be used instead.
*/
@Deprecated
public PersistentIdentifierBag(SessionImplementor session) {
this( (SharedSessionContractImplementor) session );
}
/** /**
* Constructs a PersistentIdentifierBag. * Constructs a PersistentIdentifierBag.
* *
@ -78,6 +90,18 @@ public class PersistentIdentifierBag extends AbstractPersistentCollection implem
identifiers = new HashMap<>(); identifiers = new HashMap<>();
} }
/**
* Constructs a PersistentIdentifierBag.
*
* @param session The session
* @param coll The base elements
* @deprecated {@link #PersistentIdentifierBag(SharedSessionContractImplementor, Collection)} should be used instead.
*/
@Deprecated
public PersistentIdentifierBag(SessionImplementor session, Collection coll) {
this( (SharedSessionContractImplementor) session, coll );
}
@Override @Override
public void initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner) public void initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner)
throws HibernateException { throws HibernateException {

View File

@ -16,6 +16,7 @@ import java.util.List;
import java.util.ListIterator; import java.util.ListIterator;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.loader.CollectionAliases; import org.hibernate.loader.CollectionAliases;
import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.persister.collection.CollectionPersister;
@ -46,6 +47,17 @@ public class PersistentList extends AbstractPersistentCollection implements List
super( session ); super( session );
} }
/**
* Constructs a PersistentList.
*
* @param session The session
* @deprecated {@link #PersistentList(SharedSessionContractImplementor)} should be used instead.
*/
@Deprecated
public PersistentList(SessionImplementor session) {
this( (SharedSessionContractImplementor) session );
}
/** /**
* Constructs a PersistentList. * Constructs a PersistentList.
* *
@ -59,6 +71,18 @@ public class PersistentList extends AbstractPersistentCollection implements List
setDirectlyAccessible( true ); setDirectlyAccessible( true );
} }
/**
* Constructs a PersistentList.
*
* @param session The session
* @param list The raw list
* @deprecated {@link #PersistentList(SharedSessionContractImplementor, List)} should be used instead.
*/
@Deprecated
public PersistentList(SessionImplementor session, List list) {
this( (SharedSessionContractImplementor) session, list );
}
@Override @Override
@SuppressWarnings( {"unchecked"}) @SuppressWarnings( {"unchecked"})
public Serializable getSnapshot(CollectionPersister persister) throws HibernateException { public Serializable getSnapshot(CollectionPersister persister) throws HibernateException {

View File

@ -18,6 +18,7 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.loader.CollectionAliases; import org.hibernate.loader.CollectionAliases;
import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.persister.collection.CollectionPersister;
@ -54,6 +55,17 @@ public class PersistentMap extends AbstractPersistentCollection implements Map {
super( session ); super( session );
} }
/**
* Instantiates a lazy map (the underlying map is un-initialized).
*
* @param session The session to which this map will belong.
* @deprecated {@link #PersistentMap(SharedSessionContractImplementor)} should be used instead.
*/
@Deprecated
public PersistentMap(SessionImplementor session) {
this( (SharedSessionContractImplementor) session );
}
/** /**
* Instantiates a non-lazy map (the underlying map is constructed * Instantiates a non-lazy map (the underlying map is constructed
* from the incoming map reference). * from the incoming map reference).
@ -68,6 +80,19 @@ public class PersistentMap extends AbstractPersistentCollection implements Map {
setDirectlyAccessible( true ); setDirectlyAccessible( true );
} }
/**
* Instantiates a non-lazy map (the underlying map is constructed
* from the incoming map reference).
*
* @param session The session to which this map will belong.
* @param map The underlying map data.
* @deprecated {@link #PersistentMap(SharedSessionContractImplementor, Map)} should be used instead.
*/
@Deprecated
public PersistentMap(SessionImplementor session, Map map) {
this( (SharedSessionContractImplementor) session, map );
}
@Override @Override
@SuppressWarnings( {"unchecked"}) @SuppressWarnings( {"unchecked"})
public Serializable getSnapshot(CollectionPersister persister) throws HibernateException { public Serializable getSnapshot(CollectionPersister persister) throws HibernateException {

View File

@ -17,6 +17,7 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.loader.CollectionAliases; import org.hibernate.loader.CollectionAliases;
import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.persister.collection.CollectionPersister;
@ -54,6 +55,17 @@ public class PersistentSet extends AbstractPersistentCollection implements java.
super( session ); super( session );
} }
/**
* Instantiates a lazy set (the underlying set is un-initialized).
*
* @param session The session to which this set will belong.
* @deprecated {@link #PersistentSet(SharedSessionContractImplementor)} should be used instead.
*/
@Deprecated
public PersistentSet(SessionImplementor session) {
this( (SharedSessionContractImplementor) session );
}
/** /**
* Instantiates a non-lazy set (the underlying set is constructed * Instantiates a non-lazy set (the underlying set is constructed
* from the incoming set reference). * from the incoming set reference).
@ -72,6 +84,19 @@ public class PersistentSet extends AbstractPersistentCollection implements java.
setDirectlyAccessible( true ); setDirectlyAccessible( true );
} }
/**
* Instantiates a non-lazy set (the underlying set is constructed
* from the incoming set reference).
*
* @param session The session to which this set will belong.
* @param set The underlying set data.
* @deprecated {@link #PersistentSet(SharedSessionContractImplementor, java.util.Set)} should be used instead.
*/
@Deprecated
public PersistentSet(SessionImplementor session, java.util.Set set) {
this( (SharedSessionContractImplementor) session, set );
}
@Override @Override
@SuppressWarnings( {"unchecked"}) @SuppressWarnings( {"unchecked"})
public Serializable getSnapshot(CollectionPersister persister) throws HibernateException { public Serializable getSnapshot(CollectionPersister persister) throws HibernateException {

View File

@ -46,6 +46,17 @@ public class PersistentSortedMap extends PersistentMap implements SortedMap {
super( session ); super( session );
} }
/**
* Constructs a PersistentSortedMap.
*
* @param session The session
* @deprecated {@link #PersistentSortedMap(SharedSessionContractImplementor)} should be used instead.
*/
@Deprecated
public PersistentSortedMap(SessionImplementor session) {
this( (SharedSessionContractImplementor) session );
}
/** /**
* Constructs a PersistentSortedMap. * Constructs a PersistentSortedMap.
* *
@ -57,6 +68,18 @@ public class PersistentSortedMap extends PersistentMap implements SortedMap {
comparator = map.comparator(); comparator = map.comparator();
} }
/**
* Constructs a PersistentSortedMap.
*
* @param session The session
* @param map The underlying map data
* @deprecated {@link #PersistentSortedMap(SharedSessionContractImplementor, SortedMap)} should be used instead.
*/
@Deprecated
public PersistentSortedMap(SessionImplementor session, SortedMap map) {
this( (SharedSessionContractImplementor) session, map );
}
@SuppressWarnings({"unchecked", "UnusedParameters"}) @SuppressWarnings({"unchecked", "UnusedParameters"})
protected Serializable snapshot(BasicCollectionPersister persister, EntityMode entityMode) throws HibernateException { protected Serializable snapshot(BasicCollectionPersister persister, EntityMode entityMode) throws HibernateException {
final TreeMap clonedMap = new TreeMap( comparator ); final TreeMap clonedMap = new TreeMap( comparator );

View File

@ -43,6 +43,17 @@ public class PersistentSortedSet extends PersistentSet implements SortedSet {
super( session ); super( session );
} }
/**
* Constructs a PersistentSortedSet
*
* @param session The session
* @deprecated {@link #PersistentSortedSet(SharedSessionContractImplementor)} should be used instead.
*/
@Deprecated
public PersistentSortedSet(SessionImplementor session) {
this( (SharedSessionContractImplementor) session );
}
/** /**
* Constructs a PersistentSortedSet * Constructs a PersistentSortedSet
* *
@ -54,6 +65,18 @@ public class PersistentSortedSet extends PersistentSet implements SortedSet {
comparator = set.comparator(); comparator = set.comparator();
} }
/**
* Constructs a PersistentSortedSet
*
* @param session The session
* @param set The underlying set data
* @deprecated {@link #PersistentSortedSet(SharedSessionContractImplementor, SortedSet)} should be used instead.
*/
@Deprecated
public PersistentSortedSet(SessionImplementor session, SortedSet set) {
this( (SharedSessionContractImplementor) session, set );
}
@SuppressWarnings({"unchecked", "UnusedParameters"}) @SuppressWarnings({"unchecked", "UnusedParameters"})
protected Serializable snapshot(BasicCollectionPersister persister, EntityMode entityMode) protected Serializable snapshot(BasicCollectionPersister persister, EntityMode entityMode)
throws HibernateException { throws HibernateException {