This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
package org.redkale.source;
|
package org.redkale.source;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
|
* 不被标记为@javax.persistence.Transient 的字段均视为过滤条件
|
||||||
*
|
*
|
||||||
* <p> 详情见: http://redkale.org
|
* <p> 详情见: http://redkale.org
|
||||||
* @author zhangjx
|
* @author zhangjx
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
package org.redkale.source;
|
package org.redkale.source;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 函数表达式, 均与SQL定义中的表达式相同
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* 详情见: http://redkale.org
|
* 详情见: http://redkale.org
|
||||||
|
|||||||
@@ -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 + ")";
|
||||||
|
|||||||
@@ -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关系, @FilterGroup("") 等价于 @FilterGroup("[AND]")
|
* 因为默认是AND关系, @FilterGroup("") 等价于 @FilterGroup("[AND]")
|
||||||
* 所以示例二的@FilterGroup("[OR]g1.[AND]subg1") 可以简化为 @FilterGroup("[OR]g1")
|
* 所以示例二的@FilterGroup("[OR]g1.[AND]subg1") 可以简化为 @FilterGroup("[OR]g1.subg1")
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
|||||||
@@ -13,9 +13,11 @@ 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
|
||||||
*
|
*
|
||||||
* @author zhangjx
|
* @author zhangjx
|
||||||
@@ -143,10 +145,11 @@ public class FilterNode {
|
|||||||
/**
|
/**
|
||||||
* 该方法需要重载
|
* 该方法需要重载
|
||||||
*
|
*
|
||||||
* @param <T> Entity类的泛型
|
* @param <T> Entity类的泛型
|
||||||
* @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) {
|
||||||
@@ -205,9 +209,10 @@ 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) {
|
||||||
|
|||||||
@@ -6,7 +6,8 @@
|
|||||||
package org.redkale.source;
|
package org.redkale.source;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FilterValue主要用于复杂的表达式, 例如: col / 10 = 3 、MOD(col, 8) > 0 这些都不是单独一个数值能表达的,因此需要FilterValue 才构建 8 、 > 、0 组合值.
|
* FilterValue主要用于复杂的表达式。<br>
|
||||||
|
* 例如: col / 10 = 3 、MOD(col, 8) > 0 这些都不是单独一个数值能表达的,因此需要FilterValue 才构建 8 、 > 、0 组合值.
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* 详情见: http://redkale.org
|
* 详情见: http://redkale.org
|
||||||
|
|||||||
Reference in New Issue
Block a user