|
|
@ -219,11 +219,13 @@ class DelegateFind extends AbsDelegate { |
|
|
|
boolean paged = false; |
|
|
|
boolean paged = false; |
|
|
|
if (page != -1 && num != -1) { |
|
|
|
if (page != -1 && num != -1) { |
|
|
|
paged = true; |
|
|
|
paged = true; |
|
|
|
sql = sql.concat(String.format(" Group by %s LIMIT %s,%s", pTableName.concat(".").concat(m.parentColumn()), (page - 1) * num, num)); |
|
|
|
sql = sql.concat(String.format(" Group by %s LIMIT %s,%s", |
|
|
|
|
|
|
|
pTableName.concat(".").concat(m.parentColumn()), (page - 1) * num, num)); |
|
|
|
} |
|
|
|
} |
|
|
|
Cursor cursor = db.rawQuery(sql, null); |
|
|
|
Cursor cursor = db.rawQuery(sql, null); |
|
|
|
List<T> data = |
|
|
|
List<T> data = |
|
|
|
newInstanceEntity(wrapperClazz, parentClazz, childClazz, cursor, pColumn, cColumn,paged, db,m.entityColumn(),m.parentColumn()); |
|
|
|
newInstanceEntity(wrapperClazz, parentClazz, childClazz, cursor, pColumn, cColumn, |
|
|
|
|
|
|
|
paged, db, m.entityColumn(), m.parentColumn()); |
|
|
|
|
|
|
|
|
|
|
|
closeCursor(cursor); |
|
|
|
closeCursor(cursor); |
|
|
|
return data; |
|
|
|
return data; |
|
|
@ -247,7 +249,8 @@ class DelegateFind extends AbsDelegate { |
|
|
|
Class<T> wrapperClazz, Class<P> parentClazz, |
|
|
|
Class<T> wrapperClazz, Class<P> parentClazz, |
|
|
|
Class<C> childClazz, |
|
|
|
Class<C> childClazz, |
|
|
|
Cursor cursor, |
|
|
|
Cursor cursor, |
|
|
|
List<Field> pColumn, List<Field> cColumn,boolean paged,SQLiteDatabase db,String entityColumn,String parentColumn) { |
|
|
|
List<Field> pColumn, List<Field> cColumn, boolean paged, SQLiteDatabase db, |
|
|
|
|
|
|
|
String entityColumn, String parentColumn) { |
|
|
|
List<T> wrappers = new ArrayList<>(); |
|
|
|
List<T> wrappers = new ArrayList<>(); |
|
|
|
SparseArray<List<DbEntity>> childs = new SparseArray<>(); // 所有子表数据
|
|
|
|
SparseArray<List<DbEntity>> childs = new SparseArray<>(); // 所有子表数据
|
|
|
|
SparseArray<DbEntity> parents = new SparseArray<>(); // 所有父表数据
|
|
|
|
SparseArray<DbEntity> parents = new SparseArray<>(); // 所有父表数据
|
|
|
@ -260,11 +263,12 @@ class DelegateFind extends AbsDelegate { |
|
|
|
parents.put(pRowId, createParent(pRowId, parentClazz, pColumn, cursor)); |
|
|
|
parents.put(pRowId, createParent(pRowId, parentClazz, pColumn, cursor)); |
|
|
|
} |
|
|
|
} |
|
|
|
if (paged) { |
|
|
|
if (paged) { |
|
|
|
List<C> list = createChildren(db, childClazz, pColumn, entityColumn, parentColumn, parents.get(pRowId)); |
|
|
|
List<C> list = createChildren(db, childClazz, pColumn, entityColumn, parentColumn, |
|
|
|
if(list!=null) |
|
|
|
parents.get(pRowId)); |
|
|
|
|
|
|
|
if (list != null) { |
|
|
|
childs.get(pRowId).addAll(list); |
|
|
|
childs.get(pRowId).addAll(list); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
childs.get(pRowId).add(createChild(childClazz, cColumn, cursor)); |
|
|
|
childs.get(pRowId).add(createChild(childClazz, cColumn, cursor)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -296,10 +300,12 @@ class DelegateFind extends AbsDelegate { |
|
|
|
|
|
|
|
|
|
|
|
return wrappers; |
|
|
|
return wrappers; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 创建子对象集合 |
|
|
|
* 创建子对象集合 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private <T extends DbEntity> List<T> createChildren(SQLiteDatabase db,Class<T> childClazz, List<Field> pColumn, |
|
|
|
private <T extends DbEntity> List<T> createChildren(SQLiteDatabase db, Class<T> childClazz, |
|
|
|
|
|
|
|
List<Field> pColumn, |
|
|
|
String entityColumn, String parentColumn, DbEntity parents) |
|
|
|
String entityColumn, String parentColumn, DbEntity parents) |
|
|
|
throws IllegalAccessException { |
|
|
|
throws IllegalAccessException { |
|
|
|
|
|
|
|
|
|
|
@ -315,6 +321,7 @@ class DelegateFind extends AbsDelegate { |
|
|
|
} |
|
|
|
} |
|
|
|
return new ArrayList<T>(); |
|
|
|
return new ArrayList<T>(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 创建子对象 |
|
|
|
* 创建子对象 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|