Package org.odmg

Examples of org.odmg.Implementation


    }

    public void testNrmAndDlists() throws Exception
    {
        // get facade instance
        Implementation odmg = OJB.getInstance();
        Database db = odmg.newDatabase();
        //open database
        try
        {
            db.open(databaseName, Database.OPEN_READ_WRITE);
        }
        catch (ODMGException ex)
        {
            fail("ODMGException: " + ex.getMessage());
        }
        Transaction tx = odmg.newTransaction();

        //perform transaction
        try
        {
            //=============================
            // this test needs DList impl as oql query collection class
            ((ImplementationImpl) odmg).setOqlCollectionClass(DListImpl_2.class);
            //=============================

            tx.begin();

            OQLQuery query = odmg.newOQLQuery();
            query.create("select x from " + Article.class.getName() + " where productGroupId = 7");
            List results = (List) query.execute();

            int originalSize = results.size();
            assertTrue("result count have to be > 0", originalSize > 0);

//            OJB.getLogger().debug(results);

            String name = "gimme fruits_" + System.currentTimeMillis();

            db.bind(results, name);
            tx.commit();

            tx = odmg.newTransaction();
            tx.begin();

            ((TransactionImpl) tx).getBroker().clearCache();

            // look it up again
View Full Code Here


    }

    public void testOQLQueryBind()
    {
        // get facade instance
        Implementation odmg = OJB.getInstance();
        Database db = odmg.newDatabase();
        //open database
        try
        {
            db.open(databaseName, Database.OPEN_READ_WRITE);
        }
        catch (ODMGException ex)
        {
            fail("ODMGException: " + ex.getMessage());
        }
        Transaction tx = odmg.newTransaction();

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

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

    }

    public void YYYtestOQLQueryOnCollections() throws Exception
    {
        // get facade instance
        Implementation odmg = OJB.getInstance();
        Database db = odmg.newDatabase();
        //open database
        db.open(databaseName, Database.OPEN_READ_WRITE);
        Transaction tx = odmg.newTransaction();

        //perform transaction
        try
        {
            tx.begin();
            OQLQuery query = odmg.newOQLQuery();
            query.create("select aLotOfArticles from " + Article.class.getName() + " where productGroupId = 4");

            DCollection results = (DCollection) query.execute();
            results = results.query("price > 35");

            // now perform control query
            query = odmg.newOQLQuery();
            query.create(
                    "select aLotOfArticles from "
                    + Article.class.getName()
                    + " where productGroupId = 4 and price  > 35");
View Full Code Here

    /**try to open non-existing db*/
    public void YYYtestWrongDbName()
    {
        // get facade instance
        Implementation objectserver = OJB.getInstance();
        Database db = objectserver.newDatabase();

        //try open database with non existing repository file:
        String wrongDatabaseName = "ThereIsNoSuchFile";
        try
        {
View Full Code Here

    /**try to crash odmg and broker tx*/
    public void YYYtestBrokerCrash()
    {
        // get facade instance
        Implementation odmg = OJB.getInstance();
        Database db = odmg.newDatabase();
        PersistenceBroker broker = null;
        ClassDescriptor cld = null;
        String tablename = null;

        //open database
        try
        {
            db.open(databaseName, Database.OPEN_READ_WRITE);
        }
        catch (ODMGException ex)
        {
            fail("ODMGException: " + ex.getMessage());
        }
        try
        {
            Transaction tx = odmg.newTransaction();
            tx.begin();

            // 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);

View Full Code Here

     * object that uses int's as foreign keys. If this doesn't work, it means we can't use int's
     * as foreign keys in ODMG. :(
     */
    public void testCreateWithoutRelatedObject() throws Exception
    {
        Implementation odmg = OJB.getInstance();
        Database db = odmg.newDatabase();
        db.open(databaseName, Database.OPEN_READ_WRITE);
        try
        {
            Transaction tx = odmg.newTransaction();
            tx.begin();
            Table_1Object table1Ojb = new Table_1Object();
            db.makePersistent(table1Ojb);
            tx.commit();
        }
View Full Code Here

    /**
     * do the create with a related object to prove it works in ODMG mode.
     */
    public void testCreateWithRelatedObject() throws Exception
    {
        Implementation odmg = OJB.getInstance();
        Database db = odmg.newDatabase();
        db.open(databaseName, Database.OPEN_READ_WRITE);
        try
        {
            Transaction tx = odmg.newTransaction();
            tx.begin();
            Table_1Object table1Obj = new Table_1Object();
            Table_2Object table2Obj = new Table_2Object();
            table1Obj.setTable2Object(table2Obj);
            db.makePersistent(table2Obj);
View Full Code Here

    /**
     * test removing all
     */
    public void testRemoveAll() throws Exception
    {
        Implementation odmg = OJB.getInstance();
        Database db = odmg.newDatabase();

        db.open(databaseName, Database.OPEN_READ_WRITE);

        // 1. Get a list of some articles
        Transaction tx = odmg.newTransaction();
        tx.begin();

        OQLQuery query = odmg.newOQLQuery();
        String oql =
                "select allPersons from "
                + org.apache.ojb.broker.Person.class.getName();
        query.create(oql);
        ManageableCollection allPersons =
View Full Code Here

    /**
     * test getting all (make sure basic operation is still functional)
     */
    public void testGetAllUnrestricted() throws Exception
    {
        Implementation odmg = OJB.getInstance();
        Database db = odmg.newDatabase();
        db.open(databaseName, Database.OPEN_READ_WRITE);
        try
        {
            // 1. remove all data
            removeAllData(db, odmg);
            // 2. Insert a bunch of articles objects into the database

            createData(db, odmg);

            // 3. Get a list of some articles
            Transaction tx = odmg.newTransaction();
            tx.begin();

            OQLQuery query = odmg.newOQLQuery();
            String sql =
                    "select allPersons from "
                    + org.apache.ojb.broker.Person.class.getName();
            query.create(sql);

View Full Code Here

     * test starting at an index and ending at an index.
     */

    public void testGetSomeA() throws Exception
    {
        Implementation odmg = OJB.getInstance();
        Database db = odmg.newDatabase();
        db.open(databaseName, Database.OPEN_READ_WRITE);
        int start = 10;
        int end = 15;
        try
        {
            // 1. remove all data
            removeAllData(db, odmg);
            // 2. Insert a bunch of articles objects into the database

            createData(db, odmg);

            // 3. Get a list of some articles
            Transaction tx = odmg.newTransaction();
            tx.begin();

            EnhancedOQLQuery query = odmg.newOQLQuery();
            String sql =
                    "select somePersons from "
                    + org.apache.ojb.broker.Person.class.getName();
            query.create(sql, start, end);

View Full Code Here

TOP

Related Classes of org.odmg.Implementation

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.