Package org.odmg

Examples of org.odmg.Implementation.newTransaction()


     * @param number  The number of items to sell
     */
    public static void sellProduct(Product product, int number)
    {
        Implementation impl = OJB.getInstance();
        Transaction    tx   = impl.newTransaction();

        tx.begin();

        tx.lock(product, Transaction.WRITE);
        product.setStock(product.getStock() -  number);
View Full Code Here


     * @param product The product to delete
     */
    public static void deleteProduct(Product product)
    {
        Implementation impl = OJB.getInstance();
        Transaction    tx = impl.newTransaction();

        tx.begin();

        Database db = impl.getDatabase(product);

View Full Code Here

     * @param product The product to update in the database
     */
    public static void persistChanges(Product product)
    {
        Implementation impl = OJB.getInstance();
        TransactionExt tx  = (TransactionExt)impl.newTransaction();

        tx.begin();
        tx.markDirty(product);
        tx.commit();
    }
View Full Code Here

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

            /* 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*/
 
View Full Code Here

          }
          String name = "testStoreRetrieveSameTxn_" + System.currentTimeMillis();
          Person mum = new PersonImpl();
          mum.setFirstname(name);

          TransactionExt txn = (TransactionExt)odmg.newTransaction();
          txn.begin();
          txn.lock(mum, Transaction.WRITE);
          // System.out.println("locked for write: " + mum);
          txn.commit();
View Full Code Here

      {
        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

      {
        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

//        log.info("Init ODMG-API");
            PerformanceArticle art2 = createArticle(1001);
            Implementation ojb = OJB.getInstance();
            Database db = ojb.newDatabase();
            db.open(databaseName, Database.OPEN_READ_WRITE);
            Transaction tx = ojb.newTransaction();
            tx.begin();
            tx.lock(art2, Transaction.WRITE);
            tx.commit();

            tx.begin();
View Full Code Here

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

        Transaction tx = odmg.newTransaction();
        tx.begin();
        // create DList and bound by name
        DList list = odmg.newDList();
        db.bind(list, name);
        tx.commit();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.