本文整理汇总了Java中com.db4o.ObjectContainer.store方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectContainer.store方法的具体用法?Java ObjectContainer.store怎么用?Java ObjectContainer.store使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.db4o.ObjectContainer
的用法示例。
在下文中一共展示了ObjectContainer.store方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: moveStudent
import com.db4o.ObjectContainer; //导入方法依赖的package包/类
/**
* Move student.
*
* @param studentID
* the student id
* @param newClass
* the new class
* @param hostName
* the host name
*/
public static void moveStudent(String studentID, String newClass, String hostName)
{
ObjectContainer db = Db4oClientServer.openClient(generateConfig(), hostName, Database.DB_PORT, Database.DB_USER, Database.DB_PASS);
try
{
List<StudentDatabaseFormat> dbReps = db.query(StudentDatabaseFormat.class);
if (dbReps.size() > 0)
{
for (StudentDatabaseFormat dbRep : dbReps)
{
if (dbRep.getStudentID().equals(studentID))
{
dbRep.setClassname(newClass);
db.delete(dbRep);
db.store(dbRep);
break;
}
}
}
}
finally
{
db.close();
}
}
示例2: 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();
}
}
}
示例3: put
import com.db4o.ObjectContainer; //导入方法依赖的package包/类
@Override
public void put(final K key, V value) throws StorageOperationException {
ObjectContainer db = Db4oEmbedded.openFile(getConfiguration(), source);
ObjectSet<V> set = db.query(new Predicate<V>() {
@Override
public boolean match(V v) {
if (key.match(v))
return true;
else
return false;
}
});
db.delete(set);
db.store(value);
db.close();
}
示例4: 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();
}
示例5: 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();
}
示例6: modifyStudent
import com.db4o.ObjectContainer; //导入方法依赖的package包/类
/**
* Modify student.
*
* @param student
* the student
* @param hostName
* the host name
*/
public static void modifyStudent(Student student, String hostName)
{
ObjectContainer db = Db4oClientServer.openClient(generateConfig(), hostName, Database.DB_PORT, Database.DB_USER, Database.DB_PASS);
try
{
List<StudentDatabaseFormat> dbReps = db.query(StudentDatabaseFormat.class);
if (dbReps != null)
{
for (StudentDatabaseFormat dbRep : dbReps)
{
if (dbRep.getStudentID().equals(student.getStudentID()))
{
ArrayList<GalleryItemDatabaseFormat> galleryItems = dbRep.getGalleryItems();
db.delete(dbRep);
StudentDatabaseFormat dbRepNew = studentTodb(student);
for (GalleryItemDatabaseFormat galleryItem : galleryItems)
{
dbRepNew.addGalleryItem(galleryItem);
}
db.store(dbRepNew);
break;
}
}
}
}
finally
{
db.close();
}
}
示例7: storeStudent
import com.db4o.ObjectContainer; //导入方法依赖的package包/类
/**
* Store student.
*
* @param student
* the student
* @param hostName
* the host name
*/
public static void storeStudent(Student student, String hostName)
{
StudentDatabaseFormat dbRep = studentTodb(student);
ObjectContainer db = Db4oClientServer.openClient(generateConfig(), hostName, Database.DB_PORT, Database.DB_USER, Database.DB_PASS);
try
{
db.store(dbRep);
}
finally
{
db.close();
}
}
示例8: updateStudentRep
import com.db4o.ObjectContainer; //导入方法依赖的package包/类
/**
* Update student rep.
*
* @param student
* the student
* @param hostName
* the host name
*/
public static void updateStudentRep(final StudentRepresentation student, final String hostName)
{
Thread cachingThread = new Thread(new Runnable()
{
@Override
public void run()
{
ObjectContainer db = Db4oClientServer.openClient(generateConfig(), hostName, Database.DB_PORT, Database.DB_USER, Database.DB_PASS);
try
{
List<StudentDatabaseFormat> dbReps = db.query(StudentDatabaseFormat.class);
if (dbReps != null)
{
for (StudentDatabaseFormat dbRep : dbReps)
{
if (dbRep.getStudentID().equals(student.getStudentId()))
{
db.delete(dbRep);
StudentDatabaseFormat dbRepToStore = studentRepTodb(student);
db.store(dbRepToStore);
break;
}
}
}
}
finally
{
db.close();
}
}
});
cachingThread.start();
}
示例9: 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();
}
}
}
示例10: 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();
}
}
}
示例11: 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();
}
示例12: 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();
}
示例13: 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();
}
示例14: update
import com.db4o.ObjectContainer; //导入方法依赖的package包/类
public void update(IDescrizioneProdotto desc) {
ObjectContainer client = DbManagerSingleton.getInstance().getClient();
client.store(desc);
client.commit();
}
示例15: 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();
}