T
- public final class RecordsHolder<T extends DBObject> extends Object implements Iterable<T>
RecordsHolder holder = db.selectForUpdate(QB.create(Root.class).getInstance());
System.out.println("总数:" + holder.size());
int n = 0;
for (Root r : holder.get()) {
r.setName("更新第" + n + "条。"); // 修改对象中的值
n++;
}
holder.delete(holder.size() - 1); // 删除结果集中的最后一条记录(序号从0开始)
Root root = holder.newRecord(); // 创建一条新纪录
root.setName("新插入的记录");
holder.commit(); // 提交上述修改并关闭游标(更新、删除、添加)
Modifier and Type | Field and Description |
---|---|
static int |
AFTER_LAST |
static int |
BEFORE_FIRST |
Modifier and Type | Method and Description |
---|---|
void |
close()
关闭ResultSet和statement
|
int |
commit()
将修改提交(更新到数据库)
|
int |
commitAndClose()
将修改提交到数据库
|
void |
delete(int index)
删除
|
void |
delete(T object)
删除指定的记录
|
List<T> |
get()
返回结果集
|
boolean |
isDeleted(int index)
检查指定的对象是否删除
|
Iterator<T> |
iterator() |
T |
newRecord()
创建一个新记录
|
int |
size()
返回结果的条数
|
boolean |
supportsNewRecord()
一些数据库不支持在ResultSet上新建记录,返回该标志
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public static final int BEFORE_FIRST
public static final int AFTER_LAST
public int size()
public boolean supportsNewRecord()
public T newRecord()
public boolean isDeleted(int index)
index
- 序号,从0开始public void delete(int index)
index
- 在结果集中的序号public void delete(T object)
object
- 删除结果集当中指定的对象public int commit()
SQLException
public int commitAndClose()
public void close()
SQLException
Copyright © 2020. All rights reserved.