Package org.apache.ojb.broker

Examples of org.apache.ojb.broker.ProductGroup


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

            ProductGroup pg = new ProductGroup();
            pg.setId(77777);
            pg.setName("1");
            _conn.makePersistent(pg);
            Article article = Article.createInstance();
            article.setArticleId(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(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(77777);
            pg.setName("1");
            pOid = _conn.getIdentity(pg);
            if (_conn.getObjectByIdentity(pOid) == null)
            {
                _conn.makePersistent(pg);
            }
            pg2 = new ProductGroup();
            pg2.setId(77778);
            pg2.setName("1");
            pOid2 = _conn.getIdentity(pg2);
            if (_conn.getObjectByIdentity(pOid2) == null)
            {
                _conn.makePersistent(pg2);
            }
View Full Code Here

    }

    public void testUpdateByReachability() throws Throwable
    {
        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(77777);
            pgOid = _conn.getIdentity(pg);
            pg.setName("1");
            _conn.makePersistent(pg);
            article = Article.createInstance();
            article.setArticleId(77777);
            aOid = _conn.getIdentity(article);
            article.setStock(333);
            pg.add(article);
            article.setProductGroup(pg);
            article2 = Article.createInstance();
            article2.setArticleId(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);
            article2 = (Article) pg.getAllArticles().get(0);
            article = (Article) pg.getAllArticles().get(1);
            if (!_conn.getIdentity(article2).equals(aOid2))
            {
                article = (Article) pg.getAllArticles().get(0);
                article2 = (Article) pg.getAllArticles().get(1);
                if (!_conn.getIdentity(article2).equals(aOid2))
                {
                    fail("Missing the second article");
                }
            }
            article.setStock(433);
            article2.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(77777);
            _conn.makePersistent(pg);
            article = Article.createInstance();
            article.setArticleId(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

         * 1. create the article.
         */
        int id = groupID;
        Transaction tx = odmg.newTransaction();
        tx.begin();
        ProductGroup group = new ProductGroup();
        tx.lock(group, Transaction.WRITE);
        group.setId(id);
        group.setGroupName("id" + id);
        for (int i = 0; i < COUNT; i++)
        {
            Article article = createArticle(i);
            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

        /**
         * 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

            _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

            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

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.