当前位置: 首页>>代码示例>>Java>>正文


Java ObjectContainer.commit方法代码示例

本文整理汇总了Java中com.db4o.ObjectContainer.commit方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectContainer.commit方法的具体用法?Java ObjectContainer.commit怎么用?Java ObjectContainer.commit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.db4o.ObjectContainer的用法示例。


在下文中一共展示了ObjectContainer.commit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: save

import com.db4o.ObjectContainer; //导入方法依赖的package包/类
public void save(T obj) {
	if (obj == null) {
		return;
	}

	synchronized (DB4OUtils.class) {

		ObjectContainer oc = Db4oEmbedded.openFile(DB4OUtils
				.getDataBasePath());
		try {

			oc.store(obj);
			oc.commit();
			
		} catch (Exception e) {
			e.printStackTrace();
		} finally {

			oc.close();
		}
	}
}
 
开发者ID:yukozh,项目名称:CodeComb.Mobile.Android,代码行数:23,代码来源:BaseProvider.java

示例2: create

import com.db4o.ObjectContainer; //导入方法依赖的package包/类
public void create(ITransazione sale) throws ObjectAlreadyExistsDbException
{
    ObjectContainer client = DbManagerSingleton.getInstance().getClient();
    int exist = client.queryByExample(sale).size();
    if(exist > 0)
        throw new ObjectAlreadyExistsDbException();
    if(sale.getClass() != TransazioneSmartProxy.class)
        client.store(new TransazioneSmartProxy(sale));
    else
        client.store(sale);
    client.commit();
}
 
开发者ID:GameShopAdvance,项目名称:GameShop-Advance,代码行数:13,代码来源:DbVenditaSingleton.java

示例3: saveObj

import com.db4o.ObjectContainer; //导入方法依赖的package包/类
@Override
public void saveObj(ScriptableObject obj, String type) {
    ObjectContainer con = getDB(type);
    HashMap<Object, Object> map;
    if (obj.has("_id_", obj)) { //Update
        map = con.ext().getByID((long) obj.get("_id_"));
    } else { //Save
        map = new HashMap<>();
    }

    for (Object id : obj.getAllIds()) {
        map.put(id, obj.get(id));
    }
    con.store(map);
    con.commit();
}
 
开发者ID:govu,项目名称:govu,代码行数:17,代码来源:DB4OProvider.java

示例4: delete

import com.db4o.ObjectContainer; //导入方法依赖的package包/类
@Override
public void delete(ScriptableObject obj, String type) {
    //TODO delete by _id_
    ObjectContainer con = getDB(type);

    final HashMap<Object, Object> map = new HashMap<>();
    for (Object id : obj.getAllIds()) {
        map.put(id, obj.get(id));
    }
    ObjectSet<HashMap<Object, Object>> maps = con.query(new Predicate<HashMap<Object, Object>>() {
        @Override
        public boolean match(HashMap<Object, Object> et) {
            for (Object key : map.keySet()) {
                if (!(et.containsKey(key) && et.get(key).equals(map.get(key)))) {
                    return false;
                }
            }
            return true;
        }
    });
    while (maps.hasNext()) {
        con.delete(maps.next());
    }
    con.commit();
}
 
开发者ID:govu,项目名称:govu,代码行数:26,代码来源:DB4OProvider.java

示例5: saveOrUpdateAll

import com.db4o.ObjectContainer; //导入方法依赖的package包/类
public void saveOrUpdateAll(Collection<T> col, final Match<T> match)
		throws Exception {
	if (col == null || col.size() == 0) {
		return;
	}

	synchronized (DB4OUtils.class) {

		ObjectContainer oc = Db4oEmbedded.openFile(DB4OUtils
				.getDataBasePath());

		try {
			for (final T obj : col) {

				ObjectSet<T> os = oc.query(new Predicate<T>() {

					/**
				 * 
				 */
					private static final long serialVersionUID = 2793555621552211152L;

					@Override
					public boolean match(T t) {
						// TODO Auto-generated method stub
						return match.match(t, obj);
					}
				});

				if (os.size() > 0) {
					T old = os.get(0);
					DB4OUtils.copyFields(obj, old);

					oc.store(old);

				} else {
					oc.store(obj);
				}
				
			}

			oc.commit();
		} catch (Exception e) {
			oc.rollback();
			throw e;

		} finally {

			oc.close();
		}

	}
}
 
开发者ID:yukozh,项目名称:CodeComb.Mobile.Android,代码行数:53,代码来源:BaseProvider.java

示例6: saveOrUpdate

import com.db4o.ObjectContainer; //导入方法依赖的package包/类
public void saveOrUpdate(final T obj, final Match<T> match) {
	if (obj == null) {
		return;
	}

	synchronized (DB4OUtils.class) {

		ObjectContainer oc = Db4oEmbedded.openFile(DB4OUtils
				.getDataBasePath());
		try {

			ObjectSet<T> os = oc.query(new Predicate<T>() {

				/**
			 * 
			 */
				private static final long serialVersionUID = 2793555621552211152L;

				@Override
				public boolean match(T t) {
					// TODO Auto-generated method stub
					return match.match(t, obj);
				}
			});

			if (os.size() > 0) {
				T old = os.get(0);
				DB4OUtils.copyFields(obj, old);

				oc.store(old);

			} else {
				
				oc.store(obj);
			}
			
			oc.commit();

		} catch (Exception e) {
			e.printStackTrace();
		} finally {

			
			oc.close();
		}
	}
}
 
开发者ID:yukozh,项目名称:CodeComb.Mobile.Android,代码行数:48,代码来源:BaseProvider.java

示例7: create

import com.db4o.ObjectContainer; //导入方法依赖的package包/类
public void create(IScontoVenditaStrategy sconto) throws ObjectAlreadyExistsDbException
{
    ObjectContainer client = DbManagerSingleton.getInstance().getClient();
    int exist = client.queryByExample(sconto).size();
    if(exist > 0)
        throw new ObjectAlreadyExistsDbException();
    client.store(sconto);
    client.commit();
}
 
开发者ID:GameShopAdvance,项目名称:GameShop-Advance,代码行数:10,代码来源:DbScontoVenditaSingleton.java

示例8: create

import com.db4o.ObjectContainer; //导入方法依赖的package包/类
public void create(CartaCliente carta) throws ObjectAlreadyExistsDbException
{
    ObjectContainer client = DbManagerSingleton.getInstance().getClient();
    CartaCliente example = new CartaCliente(carta.getId());
    int exist = client.queryByExample(example).size();
    System.err.println("Clienti n."+exist);
    if(exist > 0)
        throw new ObjectAlreadyExistsDbException();
    client.store(carta);
    client.commit();
}
 
开发者ID:GameShopAdvance,项目名称:GameShop-Advance,代码行数:12,代码来源:DbCartaClienteSingleton.java

示例9: create

import com.db4o.ObjectContainer; //导入方法依赖的package包/类
public void create(IDescrizioneProdotto desc) throws ObjectAlreadyExistsDbException{
    ObjectContainer client = DbManagerSingleton.getInstance().getClient();
    int result = client.queryByExample(desc).size();
    if(result > 0)
        throw new ObjectAlreadyExistsDbException();
    if(desc.getClass() != DescrizioneProdottoSmartProxy.class)
        client.store(new DescrizioneProdottoSmartProxy(desc));
    else
        client.store(desc);
    client.commit();
}
 
开发者ID:GameShopAdvance,项目名称:GameShop-Advance,代码行数:12,代码来源:DbDescrizioneProdottoSingleton.java

示例10: update

import com.db4o.ObjectContainer; //导入方法依赖的package包/类
public void update(IDescrizioneProdotto desc) {
    ObjectContainer client = DbManagerSingleton.getInstance().getClient();
    client.store(desc);
    client.commit();
}
 
开发者ID:GameShopAdvance,项目名称:GameShop-Advance,代码行数:6,代码来源:DbDescrizioneProdottoSingleton.java

示例11: create

import com.db4o.ObjectContainer; //导入方法依赖的package包/类
public void create(IPrenotazione book) throws ObjectAlreadyExistsDbException
{
    ObjectContainer client = DbManagerSingleton.getInstance().getClient();
    int exist = client.queryByExample(book).size();
    if(exist > 0)
        throw new ObjectAlreadyExistsDbException();
    if(book.getClass() != PrenotazioneSmartProxy.class)
        client.store(new PrenotazioneSmartProxy(book));
    else
        client.store(book);
    client.commit();
}
 
开发者ID:GameShopAdvance,项目名称:GameShop-Advance,代码行数:13,代码来源:DbPrenotazioneSingleton.java

示例12: invoke

import com.db4o.ObjectContainer; //导入方法依赖的package包/类
public Object invoke(MethodInvocation methodInvocation) throws Throwable {
       Transactional transactional = readTransactionMetadata(methodInvocation);
       if (transactional.type() != null && transactional.type() == TransactionType.READ_ONLY) {
           throw new UnsupportedOperationException("Transaction type READ_ONLY is not supported with DB4O");
       }

	ObjectContainer oc = internalWorkManager.beginWork();

	Object result;
	try {
		result = methodInvocation.proceed();
	} catch (Exception e) {
           try {
               if (rollbackIfNecessary(transactional, e, oc))
                   oc.commit();

           } finally {
               if (isUnitOfWorkTransaction())
                   endWork();
           }

		throw e;
	}

	// normal, so commit the transaction
	try {
		oc.commit();
	} finally {
           if (isUnitOfWorkTransaction())
               endWork();
       }

	return result;
}
 
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:35,代码来源:Db4oLocalTxnInterceptor.java

示例13: deleteObj

import com.db4o.ObjectContainer; //导入方法依赖的package包/类
@Override
public void deleteObj(ScriptableObject obj, String type) {
    ObjectContainer con = getDB(type);

    final HashMap<Object, Object> map = new HashMap<>();
    for (Object id : obj.getAllIds()) {
        map.put(id, obj.get(id));
    }

    ObjectSet<HashMap<Object, Object>> maps = con.query(new Predicate<HashMap<Object, Object>>() {
        @Override
        public boolean match(HashMap<Object, Object> et) {
            for (Object key : map.keySet()) {
                if (!(et.containsKey(key) && et.get(key).equals(map.get(key)))) {
                    return false;
                }
            }
            return true;
        }
    });

    if (maps.hasNext()) {
        con.delete(maps.next());
        con.commit();
    }

}
 
开发者ID:govu,项目名称:govu,代码行数:28,代码来源:DB4OProvider.java

示例14: storeSystem

import com.db4o.ObjectContainer; //导入方法依赖的package包/类
public synchronized void storeSystem(CentralAuthority system) {
    ObjectContainer conn = createConnection();
    conn.store(system);
    conn.commit();
    conn.close();
}
 
开发者ID:abhishek-nandgaonkar,项目名称:HealTech,代码行数:7,代码来源:DB4OUtil.java

示例15: saveOrUpdate

import com.db4o.ObjectContainer; //导入方法依赖的package包/类
public void saveOrUpdate(final T obj, final Match<T> match) {
	if (obj == null) {
		return;
	}

	synchronized (DB4OUtils.class) {

		ObjectContainer oc = Db4oEmbedded.openFile(DB4OUtils
				.getDataBasePath());
		try {

			ObjectSet<T> os = oc.query(new Predicate<T>() {

				/**
			 * 
			 */
				private static final long serialVersionUID = 2793555621552211152L;

				@Override
				public boolean match(T t) {
					// TODO Auto-generated method stub
					return match.match(t, obj);
				}
			});

			if (os.size() > 0) {
				T old = os.get(0);
				DB4OUtils.copyFields(obj, old);

				oc.store(old);


			} else {
				
				oc.store(obj);

			}
			
			oc.commit();

		} catch (Exception e) {
			e.printStackTrace();
		} finally {

			
			oc.close();
		}
	}
}
 
开发者ID:yukozh,项目名称:CodeComb.Mobile.Android,代码行数:50,代码来源:BaseProvider.java


注:本文中的com.db4o.ObjectContainer.commit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。