Package org.apache.ojb.broker

Examples of org.apache.ojb.broker.ProductGroup


  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

            return;
        }
        clearTestData();
        Transaction tx = _kit.getTransaction(_conn);
        tx.begin();
        ProductGroup pg = new ProductGroup();
        pg.setId(new Integer(77777));
        pg.setName("1");
        _conn.makePersistent(pg);
        Article article = Article.createInstance();
        article.setArticleId(new Integer(77777));
        article.setStock(333);
        pg.add(article);
        article.setProductGroup(pg);
        _conn.makePersistent(article);
        Identity pgOid = _conn.getIdentity(pg);
        tx.commit();

        tx = _kit.getTransaction(_conn);
        tx.begin();
        pg = (ProductGroup) _conn.getObjectByIdentity(pgOid);
        pg.getAllArticlesInGroup().clear();
        tx.commit();

        tx = _kit.getTransaction(_conn);
        tx.begin();
        pg = (ProductGroup) _conn.getObjectByIdentity(pgOid);
        assertEquals("should be equal", 0, pg.getAllArticlesInGroup().size());
        tx.commit();

        tx = _kit.getTransaction(_conn);
        tx.begin();
        pg = (ProductGroup) _conn.getObjectByIdentity(pgOid);
        pg.getAllArticlesInGroup().add(article);
        tx.commit();

        tx = _kit.getTransaction(_conn);
        tx.begin();
        pg = (ProductGroup) _conn.getObjectByIdentity(pgOid);
        assertEquals("should be equal", 1, pg.getAllArticlesInGroup().size());
        tx.commit();
        clearTestData();
    }
View Full Code Here

            _conn.deletePersistent(b2);
        }

        Article article = Article.createInstance();
        article.setArticleId(new Integer(77777));
        ProductGroup pg = new ProductGroup();
        pg.setId(new Integer(77777));
        Identity oidArt = _conn.getIdentity(article);
        Identity oidPG = _conn.getIdentity(pg);
        article = (Article) _conn.getObjectByIdentity(oidArt);
        if (article != null)
        {
View Full Code Here

        /**
         * 1. create the article.
         */
        Transaction tx = odmg.newTransaction();
        tx.begin();
        ProductGroup group = new ProductGroup();
        group.setGroupName(name);
        tx.lock(group, Transaction.WRITE);
        for (int i = 0; i < COUNT; i++)
        {
            Article article = createArticle(name);
            group.add(article);
        }
        tx.commit();
        /**
         * 2. query on the article to make sure it is everything we set it up to be.
         */
 
View Full Code Here

    {
        // arminw: fixed
        // if(ojbSkipKnownIssueProblem()) return;
        String name = "testUpdateWithProxy_" + System.currentTimeMillis();

        ProductGroup pg1 = new ProductGroup(null, name + "_1", "a group");
        ProductGroup pg2 = new ProductGroup(null, name + "_2", "a group");
        Article a1 = createArticle(name);
        a1.setProductGroup(pg1);
        TransactionExt tx = (TransactionExt) odmg.newTransaction();
        tx.begin();
        database.makePersistent(a1);
View Full Code Here

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

            ProductGroup pg = new ProductGroup();
            pg.setId(new Integer(77777));
            pg.setName("1");
            _conn.makePersistent(pg);
            Article article = Article.createInstance();
            article.setArticleId(new Integer(77777));
            article.setStock(373);
            pg.add(article);
            article.setProductGroup(pg);
            _conn.makePersistent(article);
            tx.commit();

            Identity aOid = _conn.getIdentity(article);
            Identity pgOid = _conn.getIdentity(pg);

            tx = _kit.getTransaction(_conn);
            tx.begin();
            pg = (ProductGroup) _conn.getObjectByIdentity(pgOid);
            pg.setName("2");
            _conn.makePersistent(pg);
            tx.rollback();

            tx = _kit.getTransaction(_conn);
            tx.begin();
            article = (Article) _conn.getObjectByIdentity(aOid);
            assertEquals("should be equal", "1", article.getProductGroup().getName());
            tx.commit();

            // test checkpoint
            tx = _kit.getTransaction(_conn);
            tx.begin();
            pg = (ProductGroup) _conn.getObjectByIdentity(pgOid);
            pg.setName("2");
            _conn.makePersistent(pg);
            tx.checkpoint();
            tx.rollback();

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

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

            ProductGroup pg = new ProductGroup();
            pg.setId(new Integer(77777));
            pg.setName("1");
            _conn.makePersistent(pg);
            tx.commit();

            Identity pgOid = _conn.getIdentity(pg);

            tx = _kit.getTransaction(_conn);
            tx.begin();
            pg = (ProductGroup) _conn.getObjectByIdentity(pgOid);
            pg.setName("2");

            tx2 = _kit.getTransaction(conn2);
            tx2.begin();
            pg = (ProductGroup) conn2.getObjectByIdentity(pgOid);
            assertEquals("should be equal", "1", pg.getName());
            tx2.commit();
            tx.commit();

            try
            {
View Full Code Here

    public void testOtmLocks() throws Throwable
    {
        Transaction tx = null;
        Transaction tx2 = null;
        OTMConnection conn2;
        ProductGroup pg = null;
        ProductGroup pg2 = null;
        Identity pOid = null;
        Identity pOid2 = null;

        conn2 = _kit.acquireConnection(PersistenceBrokerFactory.getDefaultKey());

        try
        {
            tx = _kit.getTransaction(_conn);
            tx.begin();
            pg = new ProductGroup();
            pg.setId(new Integer(77777));
            pg.setName("1");
            pOid = _conn.getIdentity(pg);
            if (_conn.getObjectByIdentity(pOid) == null)
            {
                _conn.makePersistent(pg);
            }
            pg2 = new ProductGroup();
            pg2.setId(new Integer(77778));
            pg2.setName("1");
            pOid2 = _conn.getIdentity(pg2);
            if (_conn.getObjectByIdentity(pOid2) == null)
            {
                _conn.makePersistent(pg2);
            }
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.