This commit is contained in:
Redkale
2016-07-25 17:48:58 +08:00
parent 66c2f0970f
commit 63d7e85fb4
8 changed files with 32 additions and 17 deletions

View File

@@ -13,6 +13,8 @@ import java.util.function.Consumer;
import org.redkale.util.*; import org.redkale.util.*;
/** /**
*
* DataSource 为数据库或内存数据库的数据源提供类似JPA、Hibernate的接口与功能。
* *
* <p> * <p>
* 详情见: http://redkale.org * 详情见: http://redkale.org

View File

@@ -7,6 +7,8 @@
package org.redkale.source; package org.redkale.source;
/** /**
*
* 不被标记为&#64;javax.persistence.Transient 的字段均视为过滤条件
* *
* <p> 详情见: http://redkale.org * <p> 详情见: http://redkale.org
* @author zhangjx * @author zhangjx

View File

@@ -10,6 +10,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.*; import java.lang.annotation.*;
/** /**
* 过滤字段标记
* *
* <p> * <p>
* 详情见: http://redkale.org * 详情见: http://redkale.org

View File

@@ -6,6 +6,7 @@
package org.redkale.source; package org.redkale.source;
/** /**
* 函数表达式, 均与SQL定义中的表达式相同
* *
* <p> * <p>
* 详情见: http://redkale.org * 详情见: http://redkale.org

View File

@@ -6,17 +6,20 @@
package org.redkale.source; package org.redkale.source;
/** /**
* 常见的SQL聚合函数
*
* <p>
* 详情见: http://redkale.org
* *
* <p> 详情见: http://redkale.org
* @author zhangjx * @author zhangjx
*/ */
public enum FilterFunc { public enum FilterFunc {
AVG, AVG, //平均值
COUNT, COUNT, //总数
DISTINCTCOUNT, DISTINCTCOUNT, //去重总数
MAX, MAX, //最大值
MIN, MIN, //最小值
SUM; SUM; //求和
public String getColumn(String col) { public String getColumn(String col) {
if (this == DISTINCTCOUNT) return "COUNT(DISTINCT " + col + ")"; if (this == DISTINCTCOUNT) return "COUNT(DISTINCT " + col + ")";

View File

@@ -51,7 +51,7 @@ import java.lang.annotation.*;
* </pre></blockquote> * </pre></blockquote>
* 转换的SQL语句为: WHERE id = ? AND ((desc LIKE ? AND name LIKE ?) OR (age = ? OR birthday = ?)) * 转换的SQL语句为: WHERE id = ? AND ((desc LIKE ? AND name LIKE ?) OR (age = ? OR birthday = ?))
* 因为默认是AND关系 &#64;FilterGroup("") 等价于 &#64;FilterGroup("[AND]") * 因为默认是AND关系 &#64;FilterGroup("") 等价于 &#64;FilterGroup("[AND]")
* 所以示例二的&#64;FilterGroup("[OR]g1.[AND]subg1") 可以简化为 &#64;FilterGroup("[OR]g1") * 所以示例二的&#64;FilterGroup("[OR]g1.[AND]subg1") 可以简化为 &#64;FilterGroup("[OR]g1.subg1")
*/ */
/** /**
* <p> * <p>

View File

@@ -13,7 +13,9 @@ import static org.redkale.source.FilterExpress.*;
import org.redkale.util.Attribute; import org.redkale.util.Attribute;
/** /**
* 注意: 在调用 createSQLExpress 之前必须先调用 createSQLJoin 在调用 createPredicate 之前必须先调用 isCacheUseable * 注意: <br>
* 在调用 createSQLExpress 之前必须先调用 createSQLJoin <br>
* 在调用 createPredicate 之前必须先调用 isCacheUseable
* *
* *
* 详情见: http://redkale.org * 详情见: http://redkale.org
@@ -147,6 +149,7 @@ public class FilterNode {
* @param func EntityInfo的加载器 * @param func EntityInfo的加载器
* @param joinTabalis 关联表集合 * @param joinTabalis 关联表集合
* @param info Entity类的EntityInfo * @param info Entity类的EntityInfo
*
* @return SQL的join语句 不存在返回null * @return SQL的join语句 不存在返回null
*/ */
protected <T> CharSequence createSQLJoin(final Function<Class, EntityInfo> func, final Map<Class, String> joinTabalis, final EntityInfo<T> info) { protected <T> CharSequence createSQLJoin(final Function<Class, EntityInfo> func, final Map<Class, String> joinTabalis, final EntityInfo<T> info) {
@@ -192,6 +195,7 @@ public class FilterNode {
* 该方法需要重载 * 该方法需要重载
* *
* @param entityApplyer EntityInfo的加载器 * @param entityApplyer EntityInfo的加载器
*
* @return 是否可以使用缓存 * @return 是否可以使用缓存
*/ */
protected boolean isCacheUseable(final Function<Class, EntityInfo> entityApplyer) { protected boolean isCacheUseable(final Function<Class, EntityInfo> entityApplyer) {
@@ -208,6 +212,7 @@ public class FilterNode {
* @param <T> Entity类的泛型 * @param <T> Entity类的泛型
* @param joinTabalis 关联表的集合 * @param joinTabalis 关联表的集合
* @param info EntityInfo * @param info EntityInfo
*
* @return JOIN的SQL语句 * @return JOIN的SQL语句
*/ */
protected <T> CharSequence createSQLExpress(final EntityInfo<T> info, final Map<Class, String> joinTabalis) { protected <T> CharSequence createSQLExpress(final EntityInfo<T> info, final Map<Class, String> joinTabalis) {

View File

@@ -6,7 +6,8 @@
package org.redkale.source; package org.redkale.source;
/** /**
* FilterValue主要用于复杂的表达式 例如: col / 10 = 3 、MOD(col, 8) &gt; 0 这些都不是单独一个数值能表达的因此需要FilterValue 才构建 8 、 &gt; 、0 组合值. * FilterValue主要用于复杂的表达式。<br>
* 例如: col / 10 = 3 、MOD(col, 8) &gt; 0 这些都不是单独一个数值能表达的因此需要FilterValue 才构建 8 、 &gt; 、0 组合值.
* *
* <p> * <p>
* 详情见: http://redkale.org * 详情见: http://redkale.org