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

Java PersistentBag类代码示例

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

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



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

示例1: testShowCollectionLoading

import org.hibernate.collection.PersistentBag; //导入依赖的package包/类
/**
 * Show collection loading
 */
@Test
public void testShowCollectionLoading() {
  setTestUserContext();

  final OBQuery<Order> orderQuery = OBDal.getInstance().createQuery(Order.class, "");
  orderQuery.setMaxResult(1);
  Order order = orderQuery.uniqueResult();
  final List<OrderLine> orderLineList = order.getOrderLineList();

  // is a hibernate special thing
  Assert.assertTrue(orderLineList instanceof PersistentBag);

  // this will load the list, all OrderLines are loaded in Memory
  System.err.println(orderLineList.size());
}
 
开发者ID:mauyr,项目名称:openbravo-brazil,代码行数:19,代码来源:DalPerformanceExampleTest.java


示例2: instantiate

import org.hibernate.collection.PersistentBag; //导入依赖的package包/类
public PersistentCollection instantiate(SessionImplementor session, CollectionPersister persister, Serializable key)
throws HibernateException {
	if ( session.getEntityMode()==EntityMode.DOM4J ) {
		return new PersistentElementHolder(session, persister, key);
	}
	else {
		return new PersistentBag(session);
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:10,代码来源:BagType.java


示例3: wrap

import org.hibernate.collection.PersistentBag; //导入依赖的package包/类
public PersistentCollection wrap(SessionImplementor session, Object collection) {
	if ( session.getEntityMode()==EntityMode.DOM4J ) {
		return new PersistentElementHolder( session, (Element) collection );
	}
	else {
		return new PersistentBag( session, (Collection) collection );
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:9,代码来源:BagType.java


示例4: testWriteMethodDirtying

import org.hibernate.collection.PersistentBag; //导入依赖的package包/类
public void testWriteMethodDirtying() {
	BagOwner parent = new BagOwner( "root" );
	BagOwner child = new BagOwner( "c1" );
	parent.getChildren().add( child );
	child.setParent( parent );
	BagOwner otherChild = new BagOwner( "c2" );

	Session session = openSession();
	session.beginTransaction();
	session.save( parent );
	session.flush();
	// at this point, the list on parent has now been replaced with a PersistentBag...
	PersistentBag children = ( PersistentBag ) parent.getChildren();

	assertFalse( children.remove( otherChild ) );
	assertFalse( children.isDirty() );

	ArrayList otherCollection = new ArrayList();
	otherCollection.add( child );
	assertFalse( children.retainAll( otherCollection ) );
	assertFalse( children.isDirty() );

	otherCollection = new ArrayList();
	otherCollection.add( otherChild );
	assertFalse( children.removeAll( otherCollection ) );
	assertFalse( children.isDirty() );

	children.clear();
	session.delete( child );
	assertTrue( children.isDirty() );

	session.flush();

	children.clear();
	assertFalse( children.isDirty() );

	session.delete( parent );
	session.getTransaction().commit();
	session.close();
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:41,代码来源:PersistentBagTest.java


示例5: init

import org.hibernate.collection.PersistentBag; //导入依赖的package包/类
public void init()
{
  collectionMap.put(PersistentBag.class, ArrayList.class);
  collectionMap.put(PersistentList.class, ArrayList.class);
  collectionMap.put(PersistentMap.class, HashMap.class);
  collectionMap.put(PersistentSet.class, HashSet.class);
  collectionMap.put(PersistentSortedMap.class, TreeMap.class);
  collectionMap.put(PersistentSortedSet.class, TreeSet.class);
}
 
开发者ID:micromata,项目名称:projectforge-webapp,代码行数:10,代码来源:HibernateMapper.java


示例6: setObjectPropertyDeep

import org.hibernate.collection.PersistentBag; //导入依赖的package包/类
public static void setObjectPropertyDeep(Object bo, String propertyName, Class type, Object propertyValue,
        int depth) throws FormatException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
    // Base return cases to avoid null pointers & infinite loops
    if (depth == 0 || isNull(bo) || !PropertyUtils.isReadable(bo, propertyName)) {
        return;
    }

    // need to materialize the updateable collections before resetting the property, because it may be used in the retrieval
    try {
        materializeUpdateableCollections(bo);
    } catch(ClassNotPersistableException ex){
        //Not all classes will be persistable in a collection. For e.g. externalizable business objects.
        LOG.info("Not persistable dataObjectClass: "+bo.getClass().getName()+", field: "+propertyName);
    }

// Set the property in the BO
    setObjectProperty(bo, propertyName, type, propertyValue);

    // Now drill down and check nested BOs and BO lists
    PropertyDescriptor[] propertyDescriptors = PropertyUtils.getPropertyDescriptors(bo.getClass());
    for (int i = 0; i < propertyDescriptors.length; i++) {
        PropertyDescriptor propertyDescriptor = propertyDescriptors[i];

        // Business Objects
        if (propertyDescriptor.getPropertyType() != null && (BusinessObject.class).isAssignableFrom(
                propertyDescriptor.getPropertyType()) && PropertyUtils.isReadable(bo,
                propertyDescriptor.getName())) {
            Object nestedBo = getPropertyValue(bo, propertyDescriptor.getName());
            if (nestedBo instanceof BusinessObject) {
                setObjectPropertyDeep((BusinessObject) nestedBo, propertyName, type, propertyValue, depth - 1);
            }
        }

        // Lists
        else if (propertyDescriptor.getPropertyType() != null && (List.class).isAssignableFrom(
                propertyDescriptor.getPropertyType()) && getPropertyValue(bo, propertyDescriptor.getName())
                != null) {

            List propertyList = (List) getPropertyValue(bo, propertyDescriptor.getName());

            // Complete Hibernate Hack - fetches the proxied List into the PersistenceContext and sets it on the BO Copy.
            if (propertyList instanceof PersistentBag) {
                try {
                    PersistentBag bag = (PersistentBag) propertyList;
                    PersistableBusinessObject pbo =
                            (PersistableBusinessObject) KRADServiceLocator.getEntityManagerFactory()
                                    .createEntityManager().find(bo.getClass(), bag.getKey());
                    Field field1 = pbo.getClass().getDeclaredField(propertyDescriptor.getName());
                    Field field2 = bo.getClass().getDeclaredField(propertyDescriptor.getName());
                    field1.setAccessible(true);
                    field2.setAccessible(true);
                    field2.set(bo, field1.get(pbo));
                    propertyList = (List) getPropertyValue(bo, propertyDescriptor.getName());
                    ;
                } catch (Exception e) {
                    LOG.error(e.getMessage(), e);
                }
            }
            // End Complete Hibernate Hack

            for (Object listedBo : propertyList) {
                if (listedBo != null && listedBo instanceof BusinessObject) {
                    setObjectPropertyDeep(listedBo, propertyName, type, propertyValue, depth - 1);
                }
            } // end for
        }
    } // end for
}
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:69,代码来源:ObjectUtils.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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