Package org.apache.ojb.broker

Examples of org.apache.ojb.broker.ProductGroup


        if(ojbSkipKnownIssueProblem("Update by reachabilitiy doesn't work proper"))
        {
            return;
        }
        Transaction tx = null;
        ProductGroup pg;
        Article article;
        Article article2;
        org.apache.ojb.broker.Person person;
        org.apache.ojb.broker.Project project;
        Identity aOid = null;
        Identity aOid2 = null;
        Identity pgOid = null;
        Identity prsOid = null;
        Identity prjOid = null;

        //perform transaction
        try
        {
            tx = _kit.getTransaction(_conn);
            tx.begin();

            pg = new ProductGroup();
            pg.setId(new Integer(77777));
            pgOid = _conn.getIdentity(pg);
            pg.setName("1");
            _conn.makePersistent(pg);
            article = Article.createInstance();
            article.setArticleId(new Integer(77777));
            aOid = _conn.getIdentity(article);
            article.setStock(333);
            pg.add(article);
            article.setProductGroup(pg);
            article2 = Article.createInstance();
            article2.setArticleId(new Integer(77778));
            aOid2 = _conn.getIdentity(article2);
            article2.setStock(334);
            pg.add(article2);
            article2.setProductGroup(pg);
            _conn.makePersistent(article);
            _conn.makePersistent(article2);
            person = new org.apache.ojb.broker.Person(77777, "first", "last");
            prsOid = _conn.getIdentity(person);
            project = new org.apache.ojb.broker.Project(77777, "title", "desc");
            prjOid = _conn.getIdentity(project);
            _conn.makePersistent(person);
            _conn.makePersistent(project);
            tx.commit();


            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();
            _conn.invalidateAll();
View Full Code Here


    }

    public void testSwizzling() throws Throwable
    {
        Transaction tx = null;
        ProductGroup pg;
        Article article;
        Article article2;

        try
        {
            tx = _kit.getTransaction(_conn);
            tx.begin();

            pg = new ProductGroup();
            pg.setId(new Integer(77777));
            _conn.makePersistent(pg);
            article = Article.createInstance();
            article.setArticleId(new Integer(77777));
            article.setStock(333);
            pg.add(article);
            article.setProductGroup(pg);
            _conn.makePersistent(article);
            article2 = Article.createInstance();
            article2.setArticleId(article.getArticleId());
            article2.setStock(334);
            article2.setProductGroup(pg);
            _conn.makePersistent(article2);
            article = (Article) pg.getAllArticles().get(0);
            assertEquals("should be equal", 334, article.getStock());
        }
        finally
        {
            if (tx != null)
View Full Code Here

  public void testProductGroup5()
  {
    resetStmtCount();
    myPB.clearCache();
    myPB.beginTransaction();
    ProductGroup pg =
            (ProductGroup)myPB.getObjectByIdentity(new Identity(null, ProductGroup.class, new Object[] {new Integer(5)}));
    assertStmtCount("getObjectByIdentity", 4);
    resetStmtCount();
    List articles = pg.getAllArticles();
    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();
    // SELECT ... FROM Kategorien WHERE Kategorie_Nr = '5'
    // SELECT ... FROM Artikel A0 WHERE Kategorie_Nr =  '5'
    // SELECT ... FROM BOOKS A0   WHERE Kategorie_Nr =  '5'
    // SELECT ... FROM CDS A0     WHERE Kategorie_Nr =  '5'
    assertStmtCount("toString", 4);
View Full Code Here

      Collection results = myPB.getCollectionByQuery(q);
      assertEquals("Number of ProductGroups", 5, results.size());
      Collection articles = new ArrayList();
      for (Iterator it = results.iterator();it.hasNext();)
      {
          ProductGroup p = (ProductGroup) it.next();
          articles.addAll(p.getAllArticles());
      }
      assertEquals("Total number of Articles", 59, articles.size());
     
      //SELECT A0.KategorieName,A0.Kategorie_Nr,A0.Beschreibung FROM Kategorien A0 WHERE A0.Kategorie_Nr <=  '5'
      //SELECT ... FROM CDS A0 WHERE A0.Kategorie_Nr IN ( '1' , '4' , '2' , '5' , '3' )
View Full Code Here

      Collection results = myPB.getCollectionByQuery(q);
      assertEquals("Number of ProductGroups", 5, results.size());
      Collection articles = new ArrayList();
      for (Iterator it = results.iterator();it.hasNext();)
      {
          ProductGroup p = (ProductGroup) it.next();
          articles.addAll(p.getAllArticles());
      }
      assertEquals("Total number of Articles", 59, articles.size());
     
      //SELECT A0.KategorieName,A0.Kategorie_Nr,A0.Beschreibung FROM Kategorien A0 WHERE A0.Kategorie_Nr <=  '5'
      //SELECT ... FROM CDS A0 WHERE A0.Kategorie_Nr =  '5'
View Full Code Here

TOP

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

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.