Java 类org.hibernate.collection.internal.PersistentList 实例源码

项目:hibernateMaster    文件:BaseRelationalDatabaseDomain.java   
protected final Collection<?> getCollection(Class<?> type,Collection<?> value) {
    if (value instanceof PersistentSet && type.isAssignableFrom(HashSet.class)) {
        return new HashSet<>();
    }else if(value instanceof PersistentList && type.isAssignableFrom(ArrayList.class)){
        return new ArrayList<>();
    }
    return value;
}
项目:cmdit    文件:HibernateProxyUtils.java   
@SuppressWarnings({ "unchecked", "rawtypes" })
private Collection<?> deepLoadCollection(Collection collection, Collection guideObj) {
    Collection result = null;

    if(guideObj != null && !guideObj.isEmpty() && 
        collection != null && !collection.isEmpty()){

        try {
            if (collection instanceof PersistentSet) {
                result = new LinkedHashSet<>();
            }else  if (collection instanceof PersistentList){
                result = new ArrayList<>();
            } else {
                result = collection.getClass().newInstance();
            }

            //Recuperar primera instancia del guideObj y usarlo como siguiente guideObj
            Object collGuideObj = guideObj.iterator().next();               
            for (Object aux : collection) {
                result.add(deepLoad(aux, collGuideObj));
            }

            collection.clear();
            collection.addAll(result);

        } catch (Throwable e) {
            e.printStackTrace();
        } 
    }

    return collection;
}
项目:jspresso-ce    文件:HibernateBackendController.java   
/**
 * Hibernate related cloning.
 * <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;
}
项目:kordapt    文件:HibernateCoreAddon.java   
@Override
public void postBootHook(AbstractApplicationContext ctx) {
    if(ctx.containsBean("xstream")){
        XStream xStream = (XStream)ctx.getBean("xstream");
        xStream.registerConverter(new HibernateProxyConverter());
        xStream.registerConverter(new HibernatePersistentCollectionConverter(xStream.getMapper()));
        xStream.alias("list", PersistentList.class);
        xStream.alias("list", PersistentBag.class);
        xStream.alias("set", PersistentSet.class);
    }

}
项目:lams    文件:ListType.java   
public PersistentCollection instantiate(SessionImplementor session, CollectionPersister persister, Serializable key) {
    return new PersistentList(session);
}
项目:lams    文件:ListType.java   
public PersistentCollection wrap(SessionImplementor session, Object collection) {
    return new PersistentList( session, (List) collection );
}
项目:kordapt    文件:HibernatePersistentCollectionConverter.java   
public boolean canConvert(final Class type) {
    return type == PersistentBag.class
            || type == PersistentList.class
            || type == PersistentSet.class;
}