本文整理汇总了Java中com.db4o.ObjectContainer.delete方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectContainer.delete方法的具体用法?Java ObjectContainer.delete怎么用?Java ObjectContainer.delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.db4o.ObjectContainer
的用法示例。
在下文中一共展示了ObjectContainer.delete方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteStudent
import com.db4o.ObjectContainer; //导入方法依赖的package包/类
/**
* Delete student.
*
* @param studentID
* the student id
* @param hostName
* the host name
*/
public static void deleteStudent(String studentID, 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(studentID))
{
db.delete(dbRep);
break;
}
}
}
}
finally
{
db.close();
}
}
示例2: 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();
}
}
示例3: removeStudentsOfClass
import com.db4o.ObjectContainer; //导入方法依赖的package包/类
/**
* Removes the students of class.
*
* @param className
* the class name
* @param hostName
* the host name
*/
public static void removeStudentsOfClass(String className, 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.getClassName().equalsIgnoreCase(className))
{
db.delete(dbRep);
}
}
}
}
finally
{
db.close();
}
}
示例4: clearSystem
import com.db4o.ObjectContainer; //导入方法依赖的package包/类
public synchronized void clearSystem()
{
ObjectContainer conn = createConnection();
ObjectSet<CentralAuthority> systems = conn.query(CentralAuthority.class); // Change to the object you want to save
CentralAuthority system;
if (systems.size() == 0){
system = ConfigureCentralAuthority.initialize(); // If there's no System in the record, create a new one
}
else{
system = systems.get(0);
}
conn.delete(system);
conn.close();
}
示例5: 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();
}
示例6: 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();
}
示例7: 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();
}
}
示例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: 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();
}
}