diff --git a/Aria/src/main/java/com/arialyy/aria/orm/DbEntity.java b/Aria/src/main/java/com/arialyy/aria/orm/DbEntity.java
index f6856acc..15b71db8 100644
--- a/Aria/src/main/java/com/arialyy/aria/orm/DbEntity.java
+++ b/Aria/src/main/java/com/arialyy/aria/orm/DbEntity.java
@@ -102,6 +102,19 @@ public abstract class DbEntity {
return util.findData(clazz, expression);
}
+ /**
+ * 模糊查询一组数据
+ *
+ * DownloadEntity.findDatas(DownloadEntity.class, "downloadUrl like http://");
+ *
+ *
+ * @return 没有数据返回null
+ */
+ public static List findDataByFuzzy(Class clazz, String conditions) {
+ DelegateWrapper util = DelegateWrapper.getInstance();
+ return util.findDataByFuzzy(clazz, conditions);
+ }
+
/**
* 查询一行数据
*
diff --git a/Aria/src/main/java/com/arialyy/aria/orm/DelegateFind.java b/Aria/src/main/java/com/arialyy/aria/orm/DelegateFind.java
index e292a67f..2eb8fff0 100644
--- a/Aria/src/main/java/com/arialyy/aria/orm/DelegateFind.java
+++ b/Aria/src/main/java/com/arialyy/aria/orm/DelegateFind.java
@@ -355,6 +355,26 @@ class DelegateFind extends AbsDelegate {
return data;
}
+ /**
+ * 模糊查寻数据
+ */
+ List findDataByFuzzy(SQLiteDatabase db, Class clazz, String conditions) {
+ db = checkDb(db);
+ if(TextUtils.isEmpty(conditions)){
+ throw new IllegalArgumentException("sql语句表达式不能为null或\"\"");
+ }
+ if(!conditions.toUpperCase().contains("LIKE")){
+ throw new IllegalArgumentException("sql语句表达式未包含LIEK");
+ }
+ String sql =
+ "SELECT rowid, * FROM " + CommonUtil.getClassName(clazz) + " WHERE "+conditions;
+ print(FIND_DATA, sql);
+ Cursor cursor = db.rawQuery(sql, null);
+ List data = cursor.getCount() > 0 ? newInstanceEntity(clazz, cursor) : null;
+ closeCursor(cursor);
+ close(db);
+ return data;
+ }
/**
* 查找表的所有数据
*/
diff --git a/Aria/src/main/java/com/arialyy/aria/orm/DelegateWrapper.java b/Aria/src/main/java/com/arialyy/aria/orm/DelegateWrapper.java
index e87c5b9d..faa8fc25 100644
--- a/Aria/src/main/java/com/arialyy/aria/orm/DelegateWrapper.java
+++ b/Aria/src/main/java/com/arialyy/aria/orm/DelegateWrapper.java
@@ -118,6 +118,13 @@ public class DelegateWrapper {
return mDManager.getDelegate(DelegateFind.class).findData(mDb, clazz, expression);
}
+ /**
+ * 模糊查寻数据
+ */
+ List findDataByFuzzy(Class clazz, String conditions) {
+ return mDManager.getDelegate(DelegateFind.class).findDataByFuzzy(mDb, clazz, conditions);
+ }
+
/**
* 通过rowId判断数据是否存在
*/