• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PersistentSet类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.hibernate.collection.internal.PersistentSet的典型用法代码示例。如果您正苦于以下问题:Java PersistentSet类的具体用法?Java PersistentSet怎么用?Java PersistentSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PersistentSet类属于org.hibernate.collection.internal包,在下文中一共展示了PersistentSet类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: shouldMap

import org.hibernate.collection.internal.PersistentSet; //导入依赖的package包/类
@Override
public <S, D> boolean shouldMap(Type<S> type, String s, S s1, Type<D> type1, String s2, D d,
    MappingContext mappingContext) {
  if (type != null && s1 != null) {
    if (type.isCollection()) {
      if (s1 instanceof AbstractPersistentCollection) {
        return false;
      }

      if (((PersistentSet) s1).wasInitialized()) {
        return false;
      }
    }
  }

  return true;
}
 
开发者ID:empt-ak,项目名称:meditor,代码行数:18,代码来源:OrikaHibernateFilter.java


示例2: getCollection

import org.hibernate.collection.internal.PersistentSet; //导入依赖的package包/类
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;
}
 
开发者ID:battlesteed,项目名称:hibernateMaster,代码行数:9,代码来源:BaseRelationalDatabaseDomain.java


示例3: unwrap

import org.hibernate.collection.internal.PersistentSet; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:42,代码来源:HibernateUtils.java


示例4: testJoinOrderBy

import org.hibernate.collection.internal.PersistentSet; //导入依赖的package包/类
/**
 * Tests fix for bug #928.
 */
@Test
@SuppressWarnings("unchecked")
public void testJoinOrderBy() {
  final HibernateBackendController hbc = (HibernateBackendController) getBackendController();
  EnhancedDetachedCriteria crit = EnhancedDetachedCriteria.forClass(Department.class);

  DetachedCriteria companyCrit = crit.getSubCriteriaFor(crit, Department.COMPANY, JoinType.INNER_JOIN);
  companyCrit.add(Restrictions.eq(Nameable.NAME, "Design2See"));

  DetachedCriteria teamsCrit = crit.getSubCriteriaFor(crit, Department.TEAMS, JoinType.LEFT_OUTER_JOIN);
  teamsCrit.add(Restrictions.eq(OrganizationalUnit.OU_ID, "HR-001"));

  crit.addOrder(Order.desc(Nameable.NAME));
  crit.addOrder(Order.asc(IEntity.ID));

  List<Department> depts = hbc.findByCriteria(crit, null, Department.class);
  for (Department d : depts) {
    // force collection sorting.
    Set<Team> teams = d.getTeams();
    Set<?> innerSet;
    try {
      if (teams instanceof ICollectionWrapper<?>) {
        teams = (Set<Team>) ((ICollectionWrapper) teams).getWrappedCollection();
      }
      innerSet = (Set<?>) ReflectHelper.getPrivateFieldValue(PersistentSet.class, "set", teams);
    } catch (Exception ex) {
      throw new RuntimeException(ex);
    }
    assertTrue("innerSet is a LinkedHashSet", LinkedHashSet.class.isInstance(innerSet));
  }
}
 
开发者ID:jspresso,项目名称:hrsample-ce,代码行数:35,代码来源:JspressoModelTest.java


示例5: deepLoadCollection

import org.hibernate.collection.internal.PersistentSet; //导入依赖的package包/类
@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;
}
 
开发者ID:malaguna,项目名称:cmdit,代码行数:33,代码来源:HibernateProxyUtils.java


示例6: ensureInnerLinkedHashSet

import org.hibernate.collection.internal.PersistentSet; //导入依赖的package包/类
/**
 * Ensures that the collection held by a Persistent Set is actually a
 * LinkedHashSet.
 *
 * @param collection
 *          the collection to ensure implementation of.
 */
public static void ensureInnerLinkedHashSet(Collection<?> collection) {
  if (collection instanceof PersistentSet) {
    try {
      Set<?> innerSet = (Set<?>) ReflectHelper.getPrivateFieldValue(
          PersistentSet.class, "set", collection);
      if (innerSet != null && !(innerSet instanceof LinkedHashSet<?>)) {
        ReflectHelper.setPrivateFieldValue(PersistentSet.class, "set",
            collection, new LinkedHashSet<>(innerSet));
      }
    } catch (Exception ex) {
      LOG.error("Failed to replace internal Hibernate set implementation");
    }
  }
}
 
开发者ID:jspresso,项目名称:jspresso-ce,代码行数:22,代码来源:HibernateHelper.java


示例7: cloneUninitializedProperty

import org.hibernate.collection.internal.PersistentSet; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:jspresso,项目名称:jspresso-ce,代码行数:38,代码来源:HibernateBackendController.java


示例8: postBootHook

import org.hibernate.collection.internal.PersistentSet; //导入依赖的package包/类
@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);
    }

}
 
开发者ID:korwe,项目名称:kordapt,代码行数:13,代码来源:HibernateCoreAddon.java


示例9: instantiate

import org.hibernate.collection.internal.PersistentSet; //导入依赖的package包/类
public PersistentCollection instantiate(SessionImplementor session, CollectionPersister persister, Serializable key) {
	return new PersistentSet(session);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:4,代码来源:SetType.java


示例10: wrap

import org.hibernate.collection.internal.PersistentSet; //导入依赖的package包/类
public PersistentCollection wrap(SessionImplementor session, Object collection) {
	return new PersistentSet( session, (java.util.Set) collection );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:4,代码来源:SetType.java


示例11: canConvert

import org.hibernate.collection.internal.PersistentSet; //导入依赖的package包/类
public boolean canConvert(final Class type) {
    return type == PersistentBag.class
            || type == PersistentList.class
            || type == PersistentSet.class;
}
 
开发者ID:korwe,项目名称:kordapt,代码行数:6,代码来源:HibernatePersistentCollectionConverter.java



注:本文中的org.hibernate.collection.internal.PersistentSet类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EventHandler类代码示例发布时间:2022-05-22
下一篇:
Java VisTextField类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap