Examples of QueryByIdentity


Examples of org.apache.ojb.broker.query.QueryByIdentity

    {
        try
        {
            ProductGroup samplePG = new ProductGroup();
            samplePG.setId(1);
            InterfaceProductGroup pg = (InterfaceProductGroup) broker.getObjectByQuery(new QueryByIdentity(samplePG));
            Iterator iter = pg.getAllArticles().iterator();
            InterfaceArticle a1 = null;
            InterfaceArticle a2 = null;
            a1 = (InterfaceArticle) iter.next();
            while (iter.hasNext())
View Full Code Here

Examples of org.apache.ojb.broker.query.QueryByIdentity

                //broker.getClassDescriptor(Article.class).getFieldDescriptorByName("articleId"));

        // now check if is really unique !
        Article tmp = new Article();
        tmp.setArticleId(uid);
        Query q = new QueryByIdentity(tmp);
        InterfaceArticle result = (InterfaceArticle) broker.getObjectByQuery(q);

        assertNull("" + uid + " should be unique", result);

        //System.out.println("next free UID for InterfaceArticle : " + uid);
View Full Code Here

Examples of org.apache.ojb.broker.query.QueryByIdentity

        GUID guid = new GUID();

        PersistenceBroker broker1 = PersistenceBrokerFactory.defaultPersistenceBroker();
        broker1.beginTransaction();

        Article a1 = (Article) broker1.getObjectByQuery(new QueryByIdentity(oid));
        String originalName = a1.getArticleName();
        a1.setArticleName(guid.toString());

// start a second transaction
        PersistenceBroker broker2 = PersistenceBrokerFactory.defaultPersistenceBroker();
        broker2.beginTransaction();

        Article a2 = (Article) broker2.getObjectByQuery(new QueryByIdentity(oid));

        assertEquals(guid.toString(), a1.getArticleName());
        assertEquals(originalName, a2.getArticleName());
        assertNotSame(a1, a2);
View Full Code Here

Examples of org.apache.ojb.broker.query.QueryByIdentity

        broker.beginTransaction();
        broker.store(samplePG);
        broker.commitTransaction();
        broker.clearCache();

        InterfaceProductGroup pg = (InterfaceProductGroup) broker.getObjectByQuery(new QueryByIdentity(samplePG));
        List list = pg.getAllArticles();
        assertNotNull(list);
        assertEquals(3, list.size());
        NumberRange range = new NumberRange(a1_.getArticleId(), a3_.getArticleId());
        InterfaceArticle a1 = null;
View Full Code Here

Examples of org.apache.ojb.broker.query.QueryByIdentity

        tx.abort();

        tx = (TransactionExt) odmg.newTransaction();
        tx.begin();
        broker = tx.getBroker();
        QueryByIdentity query2 = new QueryByIdentity(obj);
        Object result = broker.getObjectByQuery(query2);
        tx.commit();

        assertNull("We should not find objects from aborted tx", result);
    }
View Full Code Here

Examples of org.apache.ojb.broker.query.QueryByIdentity

        tx.abort();

        tx = (TransactionExt) odmg.newTransaction();
        tx.begin();
        broker = tx.getBroker();
        QueryByIdentity query2 = new QueryByIdentity(obj);
        Object result = broker.getObjectByQuery(query2);
        tx.commit();

        assertNull("We should not find objects from aborted tx", result);
    }
View Full Code Here

Examples of org.apache.ojb.broker.query.QueryByIdentity

        else
        {
            // if query is Identity based transform it to a criteria based query first
            if (query instanceof QueryByIdentity)
            {
                QueryByIdentity qbi = (QueryByIdentity) query;
                Object oid = qbi.getExampleObject();
                // make sure it's an Identity
                if (!(oid instanceof Identity))
                {
                    oid = serviceIdentity().buildIdentity(oid);
                }
View Full Code Here

Examples of org.apache.ojb.broker.query.QueryByIdentity

        // 1. build an example object with matching primary key values:
        Product example = new Product();
        example.setId(id);

        // 2. build a QueryByIdentity from this sample instance:
        Query query = new QueryByIdentity(example);
        try
        {
            // 3. start broker transaction
            broker.beginTransaction();
View Full Code Here

Examples of org.apache.ojb.broker.query.QueryByIdentity

        // we do this by a query by example (QBE):
        // 1. build an example object with matching primary key values:
        Product example = new Product();
        example.setId(id);
        // 2. build a QueryByIdentity from this sample instance:
        Query query = new QueryByIdentity(example);
        try
        {
            // start broker transaction
            broker.beginTransaction();
            // lookup the product specified by the QBE
View Full Code Here

Examples of org.apache.ojb.broker.query.QueryByIdentity

        GUID guid = new GUID();

        PersistenceBroker broker1 = PersistenceBrokerFactory.defaultPersistenceBroker();
        broker1.beginTransaction();

        Article a1 = (Article) broker1.getObjectByQuery(new QueryByIdentity(oid));
        String originalName = a1.getArticleName();
        a1.setArticleName(guid.toString());

// start a second transaction
        PersistenceBroker broker2 = PersistenceBrokerFactory.defaultPersistenceBroker();
        broker2.beginTransaction();

        Article a2 = (Article) broker2.getObjectByQuery(new QueryByIdentity(oid));

        assertEquals(guid.toString(), a1.getArticleName());
        assertEquals(originalName, a2.getArticleName());
        assertNotSame(a1, a2);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.