Package org.odmg

Examples of org.odmg.Implementation


        try
        {
            databaseName = TestHelper.DEF_DATABASE_NAME;

            // get facade instance
            Implementation odmg = OJB.getInstance();
            Database db = odmg.newDatabase();
            //open database
            db.open(databaseName, Database.OPEN_READ_WRITE);

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


        try
        {
            databaseName = TestHelper.DEF_DATABASE_NAME;

            // get facade instance
            Implementation odmg = OJB.getInstance();
            Database db = odmg.newDatabase();
            //open database
            db.open(databaseName, Database.OPEN_READ_WRITE);

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

            obj = new Article();
            obj.setArticleId(333);
View Full Code Here

        try
        {
            databaseName = TestHelper.DEF_DATABASE_NAME;

            // get facade instance
            Implementation odmg = OJB.getInstance();
            db = odmg.newDatabase();
            //open database
            db.open(databaseName, Database.OPEN_READ_WRITE);

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

            tx1.begin();
            tx2.begin();

            obj = new Article();
View Full Code Here

     * Note: The name attribute was declared as
     * unique in the DB.
     */
    public void testDuplicateInsertion() throws Exception
    {
        Implementation odmg = OJB.getInstance();
        Database db = odmg.newDatabase();
        String name = "testDuplicateInsertion_" + System.currentTimeMillis();
        String nameNew = "testDuplicateInsertion_New_" + System.currentTimeMillis();

        db.open(databaseName, Database.OPEN_READ_WRITE);
        //System.out.println("TEST: Database open");
View Full Code Here

        tx.commit();
    }

    public void testSimpleQueryDelete() throws Exception
    {
        Implementation odmg = OJB.getInstance();
        Database db = odmg.newDatabase();
        String name = "testSimpleQueryDelete - " + System.currentTimeMillis();

        db.open(databaseName, Database.OPEN_READ_WRITE);
        Site site = new Site();
        site.setName(name);
        Transaction tx = odmg.newTransaction();
        tx.begin();
        tx.lock(site, Transaction.WRITE);
        tx.commit();

        OQLQuery query = odmg.newOQLQuery();
        query.create("select sites from " + Site.class.getName() + " where name=$1");
        query.bind(name);
        tx.begin();
        List result = (List) query.execute();
        if (result.size() == 0)
        {
            fail("Stored object not found");
        }
        tx.commit();

        tx.begin();
        db.deletePersistent(site);
        tx.commit();

        query = odmg.newOQLQuery();
        query.create("select sites from " + Site.class.getName() + " where name=$1");
        query.bind(name);
        tx.begin();
        List result2 = (List) query.execute();
        if (result2.size() > 0)
View Full Code Here

            if(useImplicitLocking)
            {
                restore = true;
                conf.setUseImplicitLocking(false);
            }
            Implementation odmg = OJB.getInstance();
            Database db = odmg.newDatabase();
            db.open(databaseName, Database.OPEN_READ_WRITE);

            String name = "testImplicitLocking - " + System.currentTimeMillis();
            String queryString = "select sites from " + Site.class.getName() + " where name = $1";

            /* Create an object */
            Site site = new Site();
            site.setName(name);

            Transaction tx = odmg.newTransaction();
            tx.begin();
            tx.lock(site, Transaction.WRITE);
            tx.commit();

            /* Retrieve from the object created, and set the year*/
            OQLQuery query = odmg.newOQLQuery();
            query.create(queryString);
            query.bind(name);

            tx.begin();
            List result = (List) query.execute();
            assertEquals(1, result.size());
            site = (Site) result.get(0);
            assertNotNull(site);
            assertNull(site.getYear());
            tx.lock(site, Transaction.UPGRADE);
            site.setYear(new Integer(2003));

            tx.commit();

            /* Flush the cache, and retrieve the object again */
            query = odmg.newOQLQuery();
            query.create(queryString);
            query.bind(name);
            tx.begin();
            ((HasBroker) tx).getBroker().clearCache();
            result = (List) query.execute();
View Full Code Here

       */
      public void testStoreRetrieveSameTxn()
      {
        try
        {
          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());
          }

          Person mum = new PersonImpl();
          TransactionImpl txn = (TransactionImpl)odmg.newTransaction();
          txn.begin();
          txn.lock(mum, Transaction.WRITE);
          System.out.println("locked for write: " + mum);
          Identity mumId = new Identity(mum, txn.getBroker());
          txn.commit();
View Full Code Here

    public void testRetrieveNonExistent()
  {
    try
    {
      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());
      }
      // construct an id that does not exist in the database
      Identity id = new Identity(PersonImpl.class, Person.class,  new Integer[]{new Integer(-1)});
      TransactionImpl txn = (TransactionImpl)odmg.newTransaction();
      txn.begin();
      txn.getObjectByIdentity(id);
      txn.abort();
    }
    catch (Exception exc)
View Full Code Here

  public void testRetrieveOutsideTxn()
  {
    try
    {
      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());
      }
      // construct an id that does not exist in the database
      Identity id = new Identity(Person.class, Person.class, new Integer[]{new Integer(-1)});
      TransactionImpl txn = (TransactionImpl)odmg.newTransaction();
      try
      {
        txn.getObjectByIdentity(id);
        fail("expected TransactionNotInProgressException not thrown");
      }
View Full Code Here

        try
        {
            databaseName = TestHelper.DEF_DATABASE_NAME;

            // get facade instance
            Implementation odmg = OJB.getInstance();
            Database db = odmg.newDatabase();
            //open database
            db.open(databaseName, Database.OPEN_READ_WRITE);

            tx1 = (TransactionImpl) odmg.newTransaction();
            tx2 = (TransactionImpl) odmg.newTransaction();
            tx1.begin();
            tx2.begin();
            obj = new Article();
            obj.setArticleId(333);
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.