Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
ldp-docs
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
doc
ldp-docs
Commits
df16100a
Commit
df16100a
authored
Sep 22, 2020
by
马超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 新增HqlWhereHelper组合嵌套使用文档
parent
1235932c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
103 additions
and
2 deletions
+103
-2
Example样例工程开发文档.md
开发文档/Example样例工程开发文档.md
+30
-1
Hibernate条件查询工具类使用.md
开发文档/Hibernate条件查询工具类使用.md
+72
-0
LDP-MCS系统配置项使用说明.md
操作文档/LDP-MCS系统配置项使用说明.md
+1
-1
No files found.
开发文档/Example样例工程开发文档.md
View file @
df16100a
...
@@ -145,6 +145,14 @@ LDP框架支持两种操作方式,分别为Hibernate、JDBC。这两种操作
...
@@ -145,6 +145,14 @@ LDP框架支持两种操作方式,分别为Hibernate、JDBC。这两种操作
*
@return 数据集
*
@return 数据集
*
/
*
/
List
<T>
findByHql(Class
<T>
clazz, Map
<String
,
Object
>
paramMap, OrderColumn... orderColumns);
List
<T>
findByHql(Class
<T>
clazz, Map
<String
,
Object
>
paramMap, OrderColumn... orderColumns);
/
**
*
hibernate 方式查询带参数
*
*
@param hql hql
*
@param paramMap 参数
*
@return 数据集
*
/
List
<T>
findByHql(String hql, Map
<String
,
Object
>
paramMap);
/
**
/
**
*
hibernate 方式分页查询,带参数
*
hibernate 方式分页查询,带参数
*
*
...
@@ -156,6 +164,16 @@ LDP框架支持两种操作方式,分别为Hibernate、JDBC。这两种操作
...
@@ -156,6 +164,16 @@ LDP框架支持两种操作方式,分别为Hibernate、JDBC。这两种操作
*
@return 分页数据
*
@return 分页数据
*
/
*
/
Pagination findPageByHql(Class
<T>
clazz, Map
<String
,
Object
>
paramMap, Object pageIndex, Object pageSize, OrderColumn... orderColumns);
Pagination findPageByHql(Class
<T>
clazz, Map
<String
,
Object
>
paramMap, Object pageIndex, Object pageSize, OrderColumn... orderColumns);
/
**
*
hibernate 方式分页查询,带参数
*
*
@param hql hql
*
@param paramMap 参数
*
@param pageIndex 当前页
*
@param pageSize 页面数据量
*
@return 分页数据
*
/
Pagination findPageByHql(String hql, Map
<String
,
Object
>
paramMap, Object pageIndex, Object pageSize);
/
**
/
**
*
hibernate 方式分页查询,带参数
*
hibernate 方式分页查询,带参数
*
*
...
@@ -166,6 +184,16 @@ LDP框架支持两种操作方式,分别为Hibernate、JDBC。这两种操作
...
@@ -166,6 +184,16 @@ LDP框架支持两种操作方式,分别为Hibernate、JDBC。这两种操作
*
@return 分页数据
*
@return 分页数据
*
/
*
/
Pagination findPageByHql(Class
<T>
clazz, Object pageIndex, Object pageSize, OrderColumn... orderColumns);
Pagination findPageByHql(Class
<T>
clazz, Object pageIndex, Object pageSize, OrderColumn... orderColumns);
/
**
*
hibernate 方式分页查询,带参数
*
*
@param hql hql
*
@param pageIndex 当前页
*
@param pageSize 页面数据量
*
@return 分页数据
*
/
Pagination findPageByHql(String hql, Object pageIndex, Object pageSize);
/**
/**
* 通过sql和参数查询entity数据集
* 通过sql和参数查询entity数据集
*
*
...
@@ -322,13 +350,14 @@ LDP框架支持两种操作方式,分别为Hibernate、JDBC。这两种操作
...
@@ -322,13 +350,14 @@ LDP框架支持两种操作方式,分别为Hibernate、JDBC。这两种操作
* @return 数据集
* @return 数据集
*/
*/
List<T> findByConditions(Class<T> clazz,LinkedList<Condition> conditions, OrderColumn... orderColumns);
List<T> findByConditions(Class<T> clazz,LinkedList<Condition> conditions, OrderColumn... orderColumns);
</pre>
</pre>
</blockcode
</blockcode
</details>
</details>
#### 1.1.2 Hibernate调用示例
#### 1.1.2 Hibernate调用示例
参照com.sinra.ldp.example.service.impl.ExampleServiceImpl.java,这里需要注意的是
**@AutoService**
注解,这个注解主要是在新增和更新时,对于实体类中配置了@AutoComputed字段根据规则进行自动填充。例如
参照com.sinra.ldp.example.service.impl.ExampleServiceImpl.java,这里需要注意的是
**@AutoService**
注解,这个注解主要是在新增和更新时,对于实体类中配置了@AutoComputed字段根据规则进行自动填充。例如
...
...
开发文档/Hibernate条件查询工具类使用.md
View file @
df16100a
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
Hibernate 复杂查询需要依赖工具类——
**HqlWhereHelper**
,通过调用工具类
**buildConditions()**
方法,生成带顺序的条件列表
**LinkedList<Condition>**
,最终按顺序生成HQL语句。
Hibernate 复杂查询需要依赖工具类——
**HqlWhereHelper**
,通过调用工具类
**buildConditions()**
方法,生成带顺序的条件列表
**LinkedList<Condition>**
,最终按顺序生成HQL语句。
## 简单使用示例
**HqlWhereHelper**
调用示例:
**HqlWhereHelper**
调用示例:
```
java
```
java
...
@@ -17,6 +19,14 @@ LinkedList<Condition> conditions = HqlWhereHelper.getInstance().and("key","value
...
@@ -17,6 +19,14 @@ LinkedList<Condition> conditions = HqlWhereHelper.getInstance().and("key","value
| LIKE | like |
| LIKE | like |
| IN | in |
| IN | in |
| NOTIN | not in |
| NOTIN | not in |
| ISNULL | is null |
| ISNOTNULL | is not null |
| GT | > |
| LT | < |
| GE | >= |
| LE | <= |
**HqlWhereHelper **
条件组合的方法列表如下,所有的方法都可以重复调用并随意组合,第一个方法也可以随意调用,不会多生成一个and或者or:
**HqlWhereHelper **
条件组合的方法列表如下,所有的方法都可以重复调用并随意组合,第一个方法也可以随意调用,不会多生成一个and或者or:
...
@@ -94,6 +104,27 @@ LinkedList<Condition> conditions = HqlWhereHelper.getInstance().and("key","value
...
@@ -94,6 +104,27 @@ LinkedList<Condition> conditions = HqlWhereHelper.getInstance().and("key","value
* @return
* @return
*/
*/
public
HqlWhereHelper
or
(
String
key
,
Object
value
,
FilterType
filterType
);
public
HqlWhereHelper
or
(
String
key
,
Object
value
,
FilterType
filterType
);
/**
* 使用and 拼接组合条件的前括号
*
* @return
*/
public
HqlWhereHelper
addGroup
();
/**
* 使用or 拼接组合条件的前括号
*
* @return
*/
public
HqlWhereHelper
orGroup
();
/**
* 后括号
*
* @return
*/
public
HqlWhereHelper
endGroup
();
```
```
组合条件示例:
组合条件示例:
...
@@ -108,6 +139,47 @@ LinkedList<Condition> conditions = HqlWhereHelper.getInstance()
...
@@ -108,6 +139,47 @@ LinkedList<Condition> conditions = HqlWhereHelper.getInstance()
.
buildConditions
();
.
buildConditions
();
```
```
## 组合嵌套条件
在HQL中有部分条件需要组合和嵌套,
**HqlWhereHelper**
支持使用
`addGroup()`
、
`orGroup()`
、
`endGroup()`
来实现组合和嵌套,
`addGroup()`
与
`orGroup()`
需要配合
`endGroup()`
来写。
addGroup 生成的代码是AND 加上左括号
```
sql
AND
(
```
orGroup生成的代码是 OR 加上左括号
```
sql
OR
(
```
而endGroup生成右括号
```
sql
)
```
以下是示例:
```
java
LinkedList
<
Condition
>
conditions
=
HqlWhereHelper
.
getInstance
()
.
and
(
"key1"
,
"value1"
)
.
addGroup
()
.
and
(
"key2"
,
10
,
FilterType
.
GE
)
.
and
(
"key2"
,
50
,
FilterType
.
LE
)
.
endGroup
()
.
orLike
(
"key3"
,
"value3"
)
.
buildConditions
();
```
上面代码生成的条件如下:
```
sql
WHERE
key1
=
value1
AND
(
key2
>=
10
AND
key2
<=
50
)
OR
key3
like
'value3'
```
...
...
操作文档/LDP-MCS系统配置项使用说明.md
View file @
df16100a
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@


配置项相关接口文档:http://api.dev.shxrtech.com/project/25/interface/api/cat_519
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment