Package org.apache.ojb.broker

Examples of org.apache.ojb.broker.InterfaceArticle


            crit.addEqualTo("articleName", "334");
            q = QueryFactory.newQuery(Article.class, crit);
            it = _conn.getIteratorByQuery(q);
            if (it.hasNext())
            {
                InterfaceArticle article = (InterfaceArticle) it.next();
                assertEquals("should be equal", 77777, article.getArticleId());
                assertEquals("should be equal", "334", article.getArticleName());
                article.setArticleName("335"); // test update
                if (it.hasNext())
                {
                    fail("Query returned more than 1 object");
                }
            }
            else
            {
                fail("Query returned empty result set");
            }
            tx.commit();

            // get from the database via OQLQuery Iterator
            tx = _kit.getTransaction(_conn);
            _conn.invalidate(oid);
            tx.begin();
            oql = _conn.newOQLQuery();
            oql.create("select a from " + Article.class.getName()
                + " where articleId=$1 and articleName=$2");
            oql.bind(new Integer(77777));
            oql.bind("335");
            it = _conn.getIteratorByOQLQuery(oql);
            if (it.hasNext())
            {
                InterfaceArticle article = (InterfaceArticle) it.next();
                assertEquals("should be equal", 77777, article.getArticleId());
                assertEquals("should be equal", "335", article.getArticleName());
                article.setArticleName("336"); // test update
                if (it.hasNext())
                {
                    fail("Query returned more than 1 object");
                }
            }
            else
            {
                fail("Query returned empty result set");
            }
            tx.commit();

            // get from the database via OQLQuery Collection
            tx = _kit.getTransaction(_conn);
            _conn.invalidate(oid);
            tx.begin();
            oql.bind(new Integer(77777));
            oql.bind("336");
            it = ((Collection) oql.execute()).iterator();
            if (it.hasNext())
            {
                InterfaceArticle article = (InterfaceArticle) it.next();
                assertEquals("should be equal", 77777, article.getArticleId());
                assertEquals("should be equal", "336", article.getArticleName());
                article.setArticleName("337"); // test update
                if (it.hasNext())
                {
                    fail("Query returned more than 1 object");
                }
            }
View Full Code Here


            temp = (InterfaceProductGroup) it.next();
            Collection articles = temp.getAllArticles();
            Iterator it2 = articles.iterator();
            while (it2.hasNext())
            {
                InterfaceArticle art = (InterfaceArticle) it2.next();
                if (art.getArticleName() != null)
                {
                    if (art.getArticleName().equals("OneToManyUpdateTest"))
                    {
                        found = true;
                    }
                }
            }
View Full Code Here

            Collection articles = temp.getAllArticles();
            counter = counter + articles.size();
            Iterator it2 = articles.iterator();
            while (it2.hasNext())
            {
                InterfaceArticle art = (InterfaceArticle) it2.next();
                if (art.getArticleName() != null)
                {
                    assertEquals(name, art.getArticleName());
                }
            }
        }
        assertEquals(3, counter);
    }
View Full Code Here

    assertEquals(12, articles.size());
    assertStmtCount("getAllArticles", 0);
    resetStmtCount();
    for (Iterator articleIterator = articles.iterator(); articleIterator.hasNext(); )
    {
      InterfaceArticle article = (InterfaceArticle)articleIterator.next();
      logger.info("articleId " + article.getArticleId());
      // SELECT ... FROM Artikel WHERE Artikel_Nr = ...
    }
    assertStmtCount("collect ids: ", 1)// batch retrieval!
    resetStmtCount();
    String str = pg.toString();
View Full Code Here

            Collection articles = temp.getAllArticles();
            counter = counter + articles.size();
            Iterator it2 = articles.iterator();
            while (it2.hasNext())
            {
                InterfaceArticle art = (InterfaceArticle) it2.next();
                if (art.getArticleName() != null)
                {
                    assertEquals(name, art.getArticleName());
                }
            }
        }
        assertEquals(3, counter);
    }
View Full Code Here

            crit.addEqualTo("articleName", "334");
            q = QueryFactory.newQuery(Article.class, crit);
            it = _conn.getIteratorByQuery(q);
            if (it.hasNext())
            {
                InterfaceArticle article = (InterfaceArticle) it.next();
                assertEquals("should be equal", 77777, article.getArticleId().intValue());
                assertEquals("should be equal", "334", article.getArticleName());
                article.setArticleName("335"); // test update
                if (it.hasNext())
                {
                    fail("Query returned more than 1 object");
                }
            }
            else
            {
                fail("Query returned empty result set");
            }
            tx.commit();

            // get from the database via OQLQuery Iterator
            tx = _kit.getTransaction(_conn);
            _conn.invalidate(oid);
            tx.begin();
            oql = _conn.newOQLQuery();
            oql.create("select a from " + Article.class.getName()
                + " where articleId=$1 and articleName=$2");
            oql.bind(new Integer(77777));
            oql.bind("335");
            it = _conn.getIteratorByOQLQuery(oql);
            if (it.hasNext())
            {
                InterfaceArticle article = (InterfaceArticle) it.next();
                assertEquals("should be equal", 77777, article.getArticleId().intValue());
                assertEquals("should be equal", "335", article.getArticleName());
                article.setArticleName("336"); // test update
                if (it.hasNext())
                {
                    fail("Query returned more than 1 object");
                }
            }
            else
            {
                fail("Query returned empty result set");
            }
            tx.commit();

            // get from the database via OQLQuery Collection
            tx = _kit.getTransaction(_conn);
            _conn.invalidate(oid);
            tx.begin();
            oql.bind(new Integer(77777));
            oql.bind("336");
            it = ((Collection) oql.execute()).iterator();
            if (it.hasNext())
            {
                InterfaceArticle article = (InterfaceArticle) it.next();
                assertEquals("should be equal", 77777, article.getArticleId().intValue());
                assertEquals("should be equal", "336", article.getArticleName());
                article.setArticleName("337"); // test update
                if (it.hasNext())
                {
                    fail("Query returned more than 1 object");
                }
            }
View Full Code Here


            tx = _kit.getTransaction(_conn);
            tx.begin();
            pg = (ProductGroup) _conn.getObjectByIdentity(pgOid);
            InterfaceArticle articleNew1 = (InterfaceArticle) pg.getAllArticles().get(0);
            InterfaceArticle articleNew2 = (InterfaceArticle) pg.getAllArticles().get(1);
            if (!_conn.getIdentity(articleNew2).equals(aOid2))
            {
                articleNew2 = (InterfaceArticle) pg.getAllArticles().get(0);
                articleNew1 = (InterfaceArticle) pg.getAllArticles().get(1);
                if (!_conn.getIdentity(article2).equals(aOid2))
                {
                    fail("Missing the second article");
                }
            }
            articleNew1.setStock(433);
            articleNew2.setStock(434);
            pg.setName("2");
            tx.commit();

            tx = _kit.getTransaction(_conn);
            tx.begin();
View Full Code Here

    assertEquals(12, articles.size());
    assertStmtCount("getAllArticles", 0);
    resetStmtCount();
    for (Iterator articleIterator = articles.iterator(); articleIterator.hasNext(); )
    {
      InterfaceArticle article = (InterfaceArticle)articleIterator.next();
      logger.info("articleId " + article.getArticleId());
      // SELECT ... FROM Artikel WHERE Artikel_Nr = ...
    }
    assertStmtCount("collect ids: ", 1)// batch retrieval!
    resetStmtCount();
    String str = pg.toString();
View Full Code Here

TOP

Related Classes of org.apache.ojb.broker.InterfaceArticle

Copyright © 2018 www.massapicom. 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.