Package org.apache.ojb.broker

Examples of org.apache.ojb.broker.Identity


        database.makePersistent(em1);
        database.makePersistent(m1);
        tx.commit();

        tx.begin();
        Identity m1_oid = new Identity(m1, tx.getBroker());
        Identity ex1_oid = new Identity(ex1, tx.getBroker());
        Identity em1_oid = new Identity(em1, tx.getBroker());

        tx.getBroker().clearCache();

        Employee newEm1 = (Employee) tx.getBroker().getObjectByIdentity(em1_oid);
        Executive newEx1 = (Executive) tx.getBroker().getObjectByIdentity(ex1_oid);
View Full Code Here


        database.makePersistent(em1);
        database.makePersistent(m1);
        tx.commit();

        tx.begin();
        Identity m1_oid = new Identity(m1, tx.getBroker());
        Identity ex1_oid = new Identity(ex1, tx.getBroker());
        Identity em1_oid = new Identity(em1, tx.getBroker());

        tx.getBroker().clearCache();

        Employee newEm1 = (Employee) tx.getBroker().getObjectByIdentity(em1_oid);
        Executive newEx1 = (Executive) tx.getBroker().getObjectByIdentity(ex1_oid);
View Full Code Here

            tx.begin();

            tx.registerConnection(conn2);

            example = (Article) conn1.getObjectByIdentity(
                    new Identity(Article.class, Article.class,
                                 new Object[]{new Integer(77779)}));
            if (example == null)
            {
                example = Article.createInstance();
                example.setArticleId(77779);
View Full Code Here

          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();
          txn.begin();

          Person mum2 = (Person)txn.getObjectByIdentity(mumId);
          System.out.println("retrieved: " + mum2);
View Full Code Here

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

      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

  public void testAccessArticleTwice()
  {
    resetStmtCount();
    myPB.clearCache();
    myPB.beginTransaction();
    Identity id = new Identity(null, InterfaceArticle.class, new Object[] {new Integer(200)});
    logger.info(id.toString());
    assertNull(id.getObjectsRealClass());
    myPB.getObjectByIdentity(id);
    assertEquals(CdArticle.class, id.getObjectsRealClass());
    assertStmtCount("access one cd", 1, 3); // 3 tables: Artikel, BOOKS, CDS
    resetStmtCount();
    myPB.getObjectByIdentity(id);
    assertStmtCount("access one cd again", 1); // lookup again, but exploit objectsRealClass
    myPB.commitTransaction();
View Full Code Here

    assertNotSame(pb0, pb1);

    resetStmtCount();
    pb0.clearCache();
    pb0.beginTransaction();
    Identity id = new Identity(null, CloneableGroup.class, new Object[] {new Integer(1)});
    logger.info(id.toString());
    assertNull(id.getObjectsRealClass());
    Object group0 = pb0.getObjectByIdentity(id);
    assertNotNull(group0);
    assertEquals(CloneableGroup.class, id.getObjectsRealClass());
    assertStmtCount("access one group", 1);
    pb0.commitTransaction();

    resetStmtCount();
    pb1.beginTransaction();
View Full Code Here

            //create a TestClassBProxy and persist it
            //so that when loading it again we will
            //get a dynamic proxy object
            TestClassBProxy b = new TestClassBProxy();
            new Identity(b,((HasBroker)tx).getBroker());


            tx.lock(b, Transaction.WRITE);
            tx.commit();
            String bOid = b.getOid();
View Full Code Here

        String postfix = "_testCircularStore_" + System.currentTimeMillis();
        Person junior = createComplexFamily(postfix);
        broker.beginTransaction();
        broker.store(junior);
        broker.commitTransaction();
        Identity oidJunior = new Identity(junior, broker);
        Identity oidSenior = new Identity(junior.getFather(), broker);
        broker.clearCache();

        Criteria crit = new Criteria();
        crit.addLike("name", "jeffChild_%" + postfix);
        Query q = QueryFactory.newQuery(Person.class, crit);
View Full Code Here

TOP

Related Classes of org.apache.ojb.broker.Identity

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.