当前位置: 首页>>代码示例>>Java>>正文


Java PersistenceBroker.getCollectionByQuery方法代码示例

本文整理汇总了Java中org.apache.ojb.broker.PersistenceBroker.getCollectionByQuery方法的典型用法代码示例。如果您正苦于以下问题:Java PersistenceBroker.getCollectionByQuery方法的具体用法?Java PersistenceBroker.getCollectionByQuery怎么用?Java PersistenceBroker.getCollectionByQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.ojb.broker.PersistenceBroker的用法示例。


在下文中一共展示了PersistenceBroker.getCollectionByQuery方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readArticlesByCursor

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
public Collection readArticlesByCursor(String articleName) throws Exception
{
    Criteria c = new Criteria();
    c.addLike("articleName", articleName);
    Query q = new QueryByCriteria(PerfArticleImpl.class, c);

    Collection col = null;
    PersistenceBroker broker = null;
    try
    {
        broker = PersistenceBrokerFactory.defaultPersistenceBroker();
        col = broker.getCollectionByQuery(q);
    }
    finally
    {
        if (broker != null) broker.close();
    }
    return col;
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:20,代码来源:OJBPerfTest.java

示例2: getPersons

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
/**
 * @ejb:interface-method
 */
public Collection getPersons(String firstname, String lastname)
{
    PersistenceBroker broker = getBroker();
    Criteria criteria = new Criteria();
    if (firstname != null) criteria.addEqualTo("firstname", firstname);
    if (lastname != null) criteria.addEqualTo("firstname", lastname);
    Query q = new QueryByCriteria(PersonVO.class);
    Collection result = broker.getCollectionByQuery(q);
    broker.close();
    return result;
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:15,代码来源:PersonManagerPBBean.java

示例3: getArticles

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
/**
 * @ejb:interface-method
 */
public Collection getArticles(String articleName)
{
    PersistenceBroker broker = getBroker();
    Collection result;
    try
    {
        Criteria criteria = new Criteria();
        if (articleName != null) criteria.addEqualTo("name", articleName);
        Query q = new QueryByCriteria(ArticleVO.class, criteria);
        result = broker.getCollectionByQuery(q);
    }
    finally
    {
        if (broker != null) broker.close();
    }
    return result;
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:21,代码来源:ArticleManagerPBBean.java

示例4: getCategoryByName

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
/**
 * @ejb:interface-method
 */
public Collection getCategoryByName(String categoryName)
{
    PersistenceBroker broker = getBroker();
    Collection result;
    try
    {
        Criteria criteria = new Criteria();
        if (categoryName != null) criteria.addEqualTo("categoryName", categoryName);
        Query q = new QueryByCriteria(CategoryVO.class, criteria);
        result = broker.getCollectionByQuery(q);
    }
    finally
    {
        if (broker != null) broker.close();
    }
    return result;
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:21,代码来源:ArticleManagerPBBean.java

示例5: getAllObjects

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
/**
 * Return all objects for the given class.
 */
public Collection getAllObjects(Class target)
{
    PersistenceBroker broker = getBroker();
    Collection result;
    try
    {
        Query q = new QueryByCriteria(target);
        result = broker.getCollectionByQuery(q);
    }
    finally
    {
        if (broker != null) broker.close();
    }
    return result;
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:19,代码来源:PBBaseBeanImpl.java

示例6: query

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
/**
 * Evaluate the boolean query predicate for each element of the collection and
 * return a new collection that contains each element that evaluated to true.
 * @param	predicate	An OQL boolean query predicate.
 * @return	A new collection containing the elements that evaluated true for the predicate.
 * @exception	org.odmg.QueryInvalidException	The query predicate is invalid.
 */
public DCollection query(String predicate) throws org.odmg.QueryInvalidException
{
    // 1.build complete OQL statement
    String oql = "select all from java.lang.Object where " + predicate;
    TransactionImpl tx = getTransaction();

    OQLQuery predicateQuery = tx.getImplementation().newOQLQuery();

    PBCapsule capsule = new PBCapsule(tx.getImplementation().getCurrentPBKey(), tx);
    PersistenceBroker broker = capsule.getBroker();

    try
    {
        predicateQuery.create(oql);
        Query pQ = ((OQLQueryImpl) predicateQuery).getQuery();
        Criteria pCrit = pQ.getCriteria();

        Criteria allElementsCriteria = this.getPkCriteriaForAllElements(broker);
        // join selection of elements with predicate criteria:
        pCrit.addAndCriteria(allElementsCriteria);
        Class clazz = this.getElementsExtentClass(broker);
        Query q = new QueryByCriteria(clazz, pCrit);
        if (log.isDebugEnabled()) log.debug(q.toString());
        // 2. perfom query
        return (DSetImpl) broker.getCollectionByQuery(DSetImpl.class, q);
    }
    catch (PersistenceBrokerException e)
    {
        throw new ODMGRuntimeException(e.getMessage());
    }
    finally
    {
        capsule.destroy();
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:43,代码来源:DSetImpl.java

示例7: loadData

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
/**
 * Loads the data from the database. Override this method if the objects
 * shall be loaded in a specific way.
 * 
 * @return The loaded data
 */
protected Collection loadData() throws PersistenceBrokerException
{
    PersistenceBroker broker = getBroker();
    try
    {
        Collection result;

        if (_data != null) // could be set by listener
        {
            result = _data;
        }
        else if (_size != 0)
        {
            // TODO: returned ManageableCollection should extend Collection to avoid
            // this cast
            result = (Collection) broker.getCollectionByQuery(getCollectionClass(), getQuery());
        }
        else
        {
            result = (Collection)getCollectionClass().newInstance();
        }
        return result;
    }
    catch (Exception ex)
    {
        throw new PersistenceBrokerException(ex);
    }
    finally
    {
        releaseBroker(broker);
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:39,代码来源:CollectionProxyDefaultImpl.java

示例8: ObjectSetImpl

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
/**
     * Constructor for ObjectSetImpl. Builds up an ObjectSet from an OJB Query object
     */
    public ObjectSetImpl(PersistenceBroker broker, Query query, int limit)
    {
        super();
        position = 0;
        scrolled = 0;

        // avoid double query
//        length = broker.getCount(query);
//        if (limit >= 0)
//        {
//        	length = Math.min(length,limit);
//        }
//        elements = new Vector(length);

        // thma:
        // unfortunately Iterators are currently not extent-ware
        // we have to use getCollectionBy Query () thus!
        //ojbIterator = ojbBroker.getIteratorByQuery(query);
        Collection col = broker.getCollectionByQuery(query);
        ojbIterator = col.iterator();

        length = col.size();
        if (limit >= 0)
        {
        	length = Math.min(length,limit);
        }
        elements = new Vector(length);

        setResultSetClosed(false);
    }
 
开发者ID:KualiCo,项目名称:ojb,代码行数:34,代码来源:ObjectSetImpl.java

示例9: getAllObjects

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
/**
 * @ejb:interface-method
 */
public Collection getAllObjects(Class target)
{
    if(log.isDebugEnabled()) log.debug("getAllObjects was called");
    PersistenceBroker broker = getBroker();
    Query q = new QueryByCriteria(target);
    Collection result = broker.getCollectionByQuery(q);
    broker.close();
    return result;
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:13,代码来源:PBSessionBean.java

示例10: getArticlesByName

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
/**
 * @ejb:interface-method
 */
public Collection getArticlesByName(String articleName)
{
    if(log.isDebugEnabled()) log.debug("getArticlesByName was called");
    PersistenceBroker broker = getBroker();
    Criteria crit = new Criteria();
    crit.addLike("name", articleName);
    Query q = new QueryByCriteria(ArticleVO.class, crit);
    Collection result = broker.getCollectionByQuery(q);
    broker.close();
    return result;
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:15,代码来源:PBSessionBean.java

示例11: storeUsingNestedPB

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
/**
     * Stores article and persons using other beans.
     *
     * @ejb:interface-method
     */
    public void storeUsingNestedPB(List articles, List persons)
    {
        PersistenceBroker broker = pbf.defaultPersistenceBroker();
        try
        {
            // do something with broker
            Query q = new QueryByCriteria(PersonVO.class);
            broker.getCollectionByQuery(q);
            // System.out.println("## broker1: con=" + broker.serviceConnectionManager().getConnection());
            //now use nested bean call
            // System.out.println("####### DO nested bean call");
            ArticleManagerPBLocal am = getArticleManager();
            am.storeArticles(articles);
            // System.out.println("####### END nested bean call");
            // do more with broker
            // System.out.println("## broker1: now store objects");
            storeObjects(broker, persons);
            // System.out.println("## broker1: end store, con=" + broker.serviceConnectionManager().getConnection());
        }
//        catch(LookupException e)
//        {
//            throw new EJBException(e);
//        }
        finally
        {
            // System.out.println("## close broker1 now");
            if(broker != null) broker.close();
        }
    }
 
开发者ID:KualiCo,项目名称:ojb,代码行数:35,代码来源:PersonArticleManagerPBBean.java

示例12: testObjectsFromAbstractBaseClass2

import org.apache.ojb.broker.PersistenceBroker; //导入方法依赖的package包/类
public void testObjectsFromAbstractBaseClass2() throws Exception
    {
        long stamp = System.currentTimeMillis();
        String objectName_One = "testObjectsFromAbstractBaseClass2_objOne_" + stamp;
        String objectName_Two = "testObjectsFromAbstractBaseClass2_objTwo_" + stamp;

        PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();

        Repository.SMSameTableBB dummy1 = new Repository.SMSameTableBB();
        Repository.SMInterfaceExtendA dummy2 = new Repository.SMInterfaceExtendA();

        SMObjectOne smOne_1 = new SMObjectOne(objectName_One);
        SMObjectOne smOne_2 = new SMObjectOne(objectName_One);

        SMObjectTwo smTwo_2 = new SMObjectTwo(objectName_Two);
        SMObjectTwo smTwo_1 = new SMObjectTwo(objectName_Two);
        try
        {
            broker.beginTransaction();

            broker.store(dummy1);
            broker.store(dummy2);

            broker.store(smOne_1);
            broker.store(smOne_2);
// broker.clearCache();
            broker.store(smTwo_2);
            broker.store(smTwo_1);

            broker.commitTransaction();

            // now check if store was successful
            broker.clearCache();

            Criteria cr = new Criteria();
            cr.addEqualTo("name", objectName_One);
            Query query = new QueryByCriteria(SMObjectOne.class, cr);
            Collection result = broker.getCollectionByQuery(query);

            broker.clearCache();

            Criteria cr_2 = new Criteria();
            cr_2.addEqualTo("name", objectName_Two);
            Query query_2 = new QueryByCriteria(SMObjectTwo.class, cr_2);
            Collection result_2 = broker.getCollectionByQuery(query_2);

            assertEquals("We have to found 2 SMObjectOne objects", 2, result.size());
            assertEquals("We have to found 2 SMObjectTwo objects", 2, result_2.size());
        }
        finally
        {
            if (broker != null) broker.close();
        }
    }
 
开发者ID:KualiCo,项目名称:ojb,代码行数:55,代码来源:SequenceManagerTest.java


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