Example usage for org.hibernate.collection.internal PersistentList PersistentList

List of usage examples for org.hibernate.collection.internal PersistentList PersistentList

Introduction

In this page you can find the example usage for org.hibernate.collection.internal PersistentList PersistentList.

Prototype

@Deprecated
public PersistentList(SessionImplementor session) 

Source Link

Document

Constructs a PersistentList.

Usage

From source file:com.corvid.json.hibernate.usertype.JsonListUserType.java

License:Apache License

@Override
public PersistentCollection instantiate(SessionImplementor session, CollectionPersister persister)
        throws HibernateException {
    return new PersistentList(session);
}

From source file:com.erinors.hpb.server.handler.ListHandler.java

License:Apache License

@Override
public Object merge(MergingContext context, Object object) {
    if (!(object instanceof List)) {
        return null;
    }/* ww  w  .  j  a  v  a2  s .c o m*/

    List<?> source = (List<?>) object;
    List<?> result;

    if (source instanceof UninitializedPersistentList) {
        result = new PersistentList(context.getSessionImplementor());
        context.addProcessedObject(object, result);
    } else if (source instanceof com.erinors.hpb.shared.impl.PersistentList) {
        PersistentList list = new PersistentList(context.getSessionImplementor(), new ArrayList<Object>());
        context.addProcessedObject(object, list);

        for (Object element : source) {
            list.add(context.merge(element));
        }

        if (((com.erinors.hpb.shared.impl.PersistentList<?>) source).isDirty()) {
            list.dirty();
        } else {
            list.clearDirty();
        }

        result = list;
    } else {
        List<Object> list = new ArrayList<Object>(source.size());
        context.addProcessedObject(object, list);

        for (Object element : source) {
            list.add(context.merge(element));
        }

        result = list;
    }

    return result;
}

From source file:org.jspresso.framework.application.backend.persistence.hibernate.HibernateBackendController.java

License:Open Source License

/**
 * Hibernate related cloning.// w  w  w .java2 s.co  m
 * <p/>
 * {@inheritDoc}
 */
@SuppressWarnings("unchecked")
@Override
protected <E> E cloneUninitializedProperty(Object owner, E propertyValue) {
    E clonedPropertyValue = propertyValue;
    if (isInitialized(owner)) {
        if (propertyValue instanceof PersistentCollection) {
            if (unwrapProxy((((PersistentCollection) propertyValue).getOwner())) != unwrapProxy(owner)) {
                if (propertyValue instanceof PersistentSet) {
                    clonedPropertyValue = (E) new PersistentSet(
                            // Must reset the session.
                            // See bug #902
                            /* ((PersistentSet) propertyValue).getSession() */null);
                } else if (propertyValue instanceof PersistentList) {
                    clonedPropertyValue = (E) new PersistentList(
                            // Must reset the session.
                            // See bug #902
                            /* ((PersistentList) propertyValue).getSession() */null);
                }
                changeCollectionOwner((Collection<?>) clonedPropertyValue, owner);
                ((PersistentCollection) clonedPropertyValue).setSnapshot(
                        ((PersistentCollection) propertyValue).getKey(),
                        ((PersistentCollection) propertyValue).getRole(), null);
            }
        } else {
            if (propertyValue instanceof HibernateProxy) {
                return (E) getHibernateSession().load(
                        ((HibernateProxy) propertyValue).getHibernateLazyInitializer().getEntityName(),
                        ((IEntity) propertyValue).getId());
            }
        }
    }
    return clonedPropertyValue;
}