Package org.apache.ojb.odmg.shared

Examples of org.apache.ojb.odmg.shared.Article


        // clear named roots.
        clearNRM();
        Transaction tx = odmg.newTransaction();
        //bind object to name
        tx.begin();
        Article example = createArticle();
        Identity oid = new Identity(example, ((HasBroker)tx).getBroker());

        try
        {
            db.bind(example, bindingName);
            tx.commit();
        }
        catch (ObjectNameNotUniqueException ex)
        {
            tx.abort();
            fail(ex.getMessage());
        }

        // TestThreadsNLocks look up
        Article lookedUp1 = null;
        tx = odmg.newTransaction();
        tx.begin();

        try
        {
View Full Code Here


        Transaction tx = odmg.newTransaction();
        // 1. perform binding
        tx.begin();

        Article example = createArticle();

        try
        {
            db.bind(example, name);
            tx.commit();
        }
        catch (ObjectNameNotUniqueException ex)
        {
            tx.abort();
            fail(ex.getMessage());
        }

        // 2. perform unbind
        tx = odmg.newTransaction();
        tx.begin();
        try
        {
            db.unbind(name);
            tx.commit();
        }
        catch (ObjectNameNotFoundException ex)
        {
            tx.abort();
            fail("name " + name + "should be known");
        }

        // 3. check if name is really unknown now
        tx = odmg.newTransaction();
        tx.begin();
        try
        {
            Article value = (Article) db.lookup(name);
        }
        catch (ObjectNameNotFoundException ex)
        {
            // OK !
            tx.commit();
View Full Code Here

        //perform transaction
        try
        {
            tx.begin();

            Article example = new Article();
            example.setArticleId(777);
            example.setProductGroupId(7);
            db.makePersistent(example);

            // modify Object
            example.setStock(333);
            example.addToStock(47);
            example.addToStock(7);
            example.addToStock(4);

            //System.out.println("now commit all changes...");
            tx.commit();
        }
        catch (Exception ex)
View Full Code Here

            OQLQuery query = odmg.newOQLQuery();
            query.create("select anArticle from " + Article.class.getName() + " where articleId = 60");
            List results = (List) query.execute();

            Article a = (Article) results.get(0);

            // cross check with PersistenceBroker lookup
            // 1. get OID
            Article example = new Article();
            example.setArticleId(60);
            Identity oid = new Identity(example, ((TransactionImpl) tx).getBroker());
            // 2. lookup object by OID
            PersistenceBroker broker = ((TransactionImpl) tx).getBroker();
            broker.clearCache();
            Article b = (Article) broker.getObjectByIdentity(oid);

            assertEquals("should be same object", a, b);

            //System.out.println("now commit all changes...");
            tx.commit();
View Full Code Here

            // look it up again
            DList newResults = (DList) db.lookup(name);

            assertEquals(originalSize, newResults.size());
            Article art = (Article) newResults.get(0);
            assertNotNull(art);
//            OJB.getLogger().info(results);

            tx.commit();
View Full Code Here

            query.create("select anArticle from " + Article.class.getName() + " where articleId = $678");
            query.bind(new Integer(30));

            List results = (List) query.execute();

            Article a = (Article) results.get(0);

            //crosscheck with PersistenceBroker lookup
            // 1. get OID
            Article example = new Article();
            example.setArticleId(30);
            Identity oid = new Identity(example, ((TransactionImpl) tx).getBroker());

            // 2. lookup object by OID
            PersistenceBroker broker = ((TransactionImpl) tx).getBroker();
            broker.clearCache();
            Article b = (Article) broker.getObjectByIdentity(oid);

            assertEquals("should be same object", a, b);

            //System.out.println("now commit all changes...");
            tx.commit();
View Full Code Here

            // retrieve an Article
            OQLQuery query = odmg.newOQLQuery();
            query.create("select anArticle from " + Article.class.getName() + " where articleId = $678");
            query.bind(new Integer(30));
            List results = (List) query.execute();
            Article a = (Article) results.get(0);

            // manipulate metadata
            broker = ((TransactionImpl) tx).getBroker();
            cld = broker.getClassDescriptor(Article.class);
            tablename = cld.getFullTableName();
            cld.setTableName("ELVIS");
            broker.getDescriptorRepository().setClassDescriptor(cld);

            //broker will crash as metadata is corrupt
            a.addToStock(5);
            tx.commit();
            fail("Can commit tx with corrupt metadata");
        }
        catch (Throwable t)
        {
View Full Code Here

        pg1.setName("BatchModeTest ProductGroup #1");
        database.makePersistent(pg1);

        tx.checkpoint();

        Article a1 = Article.createInstance();
        a1.setArticleName("BatchModeTest Article #1");
        a1.setProductGroup(pg1);
        pg1.addArticle(a1);
        database.makePersistent(a1);

        ProductGroup pg2 = new ProductGroup();
        pg2.setName("BatchModeTest ProductGroup #2");
        database.makePersistent(pg2);

        Article a2 = Article.createInstance();
        a2.setArticleName("BatchModeTest Article #2");
        a2.setProductGroup(pg2);
        pg2.addArticle(a2);

        tx.checkpoint();

        database.deletePersistent(a1);
View Full Code Here

            tx1 = (TransactionImpl) odmg.newTransaction();
            tx2 = (TransactionImpl) odmg.newTransaction();
            tx1.begin();
            tx2.begin();
            obj = new Article();
            obj.setArticleId(333);

        }
        catch (ODMGException e)
        {
View Full Code Here

            tx1 = (TransactionImpl) odmg.newTransaction();
            tx2 = (TransactionImpl) odmg.newTransaction();
            tx1.begin();
            tx2.begin();

            obj = new Article();
            obj.setArticleId(333);

        }
        catch (ODMGException e)
        {
View Full Code Here

TOP

Related Classes of org.apache.ojb.odmg.shared.Article

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.