org.hibernate.collection.internal.PersistentSet Java Examples

The following examples show how to use org.hibernate.collection.internal.PersistentSet. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HibernateUtils.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * If object is proxy, get unwrapped non-proxy object.
 *
 * @param proxy Object to check and unwrap
 * @return Unwrapped object if proxyied, if not just returns same object
 */
@SuppressWarnings( "unchecked" )
public static <T> T unwrap( T proxy )
{
    if ( !isProxy( proxy ) )
    {
        return proxy;
    }

    Hibernate.initialize( proxy );

    if ( HibernateProxy.class.isInstance( proxy ) )
    {
        Object result = ((HibernateProxy) proxy).writeReplace();

        if ( !SerializableProxy.class.isInstance( result ) )
        {
            return (T) result;
        }
    }

    if ( PersistentCollection.class.isInstance( proxy ) )
    {
        PersistentCollection persistentCollection = (PersistentCollection) proxy;

        if ( PersistentSet.class.isInstance( persistentCollection ) )
        {
            Map<?, ?> map = (Map<?, ?>) persistentCollection.getStoredSnapshot();
            return (T) new LinkedHashSet<>( map.keySet() );
        }

        return (T) persistentCollection.getStoredSnapshot();
    }

    return proxy;
}
 
Example #2
Source File: SetType.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public PersistentCollection instantiate(SharedSessionContractImplementor session, CollectionPersister persister, Serializable key) {
	return new PersistentSet( session );
}
 
Example #3
Source File: SetType.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public PersistentCollection wrap(SharedSessionContractImplementor session, Object collection) {
	return new PersistentSet( session, (java.util.Set) collection );
}
 
Example #4
Source File: HibernateCollectionConverterImpl.java    From yes-cart with Apache License 2.0 4 votes vote down vote up
@Override
public boolean canConvert(final Class type) {
    return PersistentBag.class == type || PersistentList.class == type || PersistentSet.class == type;
}