Android DB映射机制
来源:互联网 发布:知乎 贫困生 人肉 编辑:程序博客网 时间:2024/05/17 07:45
@SuppressWarnings("unchecked")
public <T> List<T> findAll(Selector selector) throws DbException {
if (!tableIsExist(selector.getEntityType())) return null;
String sql = selector.toString();
long seq = CursorUtils.FindCacheSequence.getSeq();
findTempCache.setSeq(seq);
Object obj = findTempCache.get(sql);
if (obj != null) {
return (List<T>) obj;
}
List<T> result = new ArrayList<T>();
Cursor cursor = execQuery(sql);
if (cursor != null) {
try {
while (cursor.moveToNext()) {
T entity = (T) CursorUtils.getEntity(this, cursor, selector.getEntityType(), seq);
result.add(entity);
}
findTempCache.put(sql, result);
} catch (Throwable e) {
throw new DbException(e);
} finally {
IOUtils.closeQuietly(cursor);
}
}
return result;
}
public <T> List<T> findAll(Selector selector) throws DbException {
if (!tableIsExist(selector.getEntityType())) return null;
String sql = selector.toString();
long seq = CursorUtils.FindCacheSequence.getSeq();
findTempCache.setSeq(seq);
Object obj = findTempCache.get(sql);
if (obj != null) {
return (List<T>) obj;
}
List<T> result = new ArrayList<T>();
Cursor cursor = execQuery(sql);
if (cursor != null) {
try {
while (cursor.moveToNext()) {
T entity = (T) CursorUtils.getEntity(this, cursor, selector.getEntityType(), seq);
result.add(entity);
}
findTempCache.put(sql, result);
} catch (Throwable e) {
throw new DbException(e);
} finally {
IOUtils.closeQuietly(cursor);
}
}
return result;
}
0 0
- Android DB映射机制
- Android db
- sql DB身份验证模式机制
- hibernate与DB的映射问题
- MFC映射机制剖析
- MFC消息映射机制
- java的映射机制
- Linux 地址映射机制
- MFC消息映射机制
- 消息映射机制
- MFC消息映射机制
- 地址映射机制
- MFC消息映射机制
- MFC消息映射机制
- 消息映射机制
- MFC消息映射机制
- 外设内存映射机制
- vc消息映射机制----------------
- linux下新建用户
- SQL语言基本操作(聚合函数)
- getCacheDir()和getFilesDir()方法区别.
- NYOJ房间安排(区间覆盖)
- 远程控制桌面命令
- Android DB映射机制
- Div和Span的区别
- bg配置问题解决
- 【从零开始学NGUI 】 (四)Slider
- 第5章 图论算法与模型(更新中)
- Python执行Linux系统命令的4种方法
- 【打CF,学算法——三星级】Codeforces Round #313 (Div. 2) C. Gerald's Hexagon
- 在Visual studi C#的“///”注释内容生成XML文档
- acm解题报告 HDU 2141 Can you find it?