Package com.google.appengine.api.datastore

Examples of com.google.appengine.api.datastore.Transaction


    }

    public static Key persistEntity(Entity entity)
    {
      Key key = entity.getKey();
      Transaction txn = datastore.beginTransaction();
      try {
        key = datastore.put(entity);
        txn.commit();
      } finally {
        if (txn.isActive())
          txn.rollback();
        else {
          addToCache(key, entity);
        }
      }
      return key;
View Full Code Here


try{
         //(entit + " put 2 " + columns);
//          EntityManager em = EMF.get().createEntityManager();
//Entity  tx = em.get ();

  Transaction trans = datastore.beginTransaction()  ;
  boolean suc = false;


try{

//tx.begin();
       datastore.put(e);

         long k = e.getKey().getId();
trans.commit();
suc = true;
return k;
   } finally {
 
    //if (tx.isActive())
    //{
        //tx.rollback();
      if (!suc)
           try{
     
           trans.rollback();
      }catch (Exception e2){
        tools.util.LogMgr.err("JGU.put TABLE.rollback " + e2.toString());
      }

    //}
View Full Code Here

  }
 
  public static Transaction getTransaction(){
 
  DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
  Transaction trans = datastore.beginTransaction()  ;
  return trans;
  }
View Full Code Here

try{
  //        EntityManager em = EMF.get().createEntityManager();
//EntityTransaction tx = em.getTransaction();
           DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();

  Transaction trans = datastore.beginTransaction()  ;
boolean suc = false;
try{

//tx.begin();
   
   
           checkThread();

         Key key = KeyFactory.createKey(pk,kind,id);
                datastore.delete(key);
trans.commit();
    suc = true;
                    return;
 
 
 
   } finally {
 
    //if (tx.isActive())
    //{
        //tx.rollback();
      if (!suc)try{
     
           trans.rollback();
      }catch (Exception e){
        tools.util.LogMgr.err("JGU.delete TABLE.rollback " + e.toString());
      }

    //}
View Full Code Here

           public static void transUpdate(String kind,Hashtable columns,long id,Key pk,jiqlConnection conn)throws Exception
  {


DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
Transaction trans = datastore.beginTransaction();
conn.setTransaction(trans);

          Key key = KeyFactory.createKey(pk,kind,id);
        Entity e = datastore.get(key);
     Enumeration en = columns.keys();
View Full Code Here

    private TweetMeta t = new TweetMeta();

    public Tweet tweet(Map<String, Object> input) {
        Tweet tweet = new Tweet();
        BeanUtil.copy(input, tweet);
        Transaction tx = Datastore.beginTransaction();
        Datastore.put(tx, tweet);
        tx.commit();
        return tweet;
    }
View Full Code Here

        // TODO Auto-generated method stub
        return Datastore.query(t).sort(t.createdDate.desc).asList();
    }

    public void deleteTweet(Key key) {
        Transaction tx = Datastore.beginTransaction();
        Datastore.delete(tx, key);
        tx.commit();
    }
View Full Code Here

        Datastore.delete(tx, key);
        tx.commit();
    }
   
    public void delete(Key key, Long version) {
        Transaction tx = Datastore.beginTransaction();
        Tweet tweet = Datastore.get(tx, t, key, version);
        Datastore.delete(tx, tweet.getKey());
        tx.commit();
    }
View Full Code Here

        Datastore.delete(tx, tweet.getKey());
        tx.commit();
    }

    public void updateTweet(Key key, String content) {
        Transaction tx = Datastore.beginTransaction();
        Tweet tweet = Datastore.get(Tweet.class, key);
        tweet.setContent(content);
        Datastore.put(tx, tweet);
        tx.commit();
    }
View Full Code Here

        tx.commit();
    }

    public void updateTweet(Key key, Long version, Map<String, Object> input) {
        // TODO Auto-generated method stub
        Transaction tx = Datastore.beginTransaction();
        Tweet tweet = Datastore.get(tx, t, key, version);
        BeanUtil.copy(input, tweet);
        Datastore.put(tx, tweet);
        tx.commit();
    }
View Full Code Here

TOP

Related Classes of com.google.appengine.api.datastore.Transaction

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.