Skip to content

Commit

Permalink
修改了使用 setResultTransformer 的方式,修改了新版本的 Fenix 文档
Browse files Browse the repository at this point in the history
  • Loading branch information
blinkfox committed May 28, 2020
1 parent 41b1b4e commit 32520e5
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 100 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

## 一、特性

- 简单、轻量级、无副作用的集成和使用,jar 包仅 `181 KB`
- 简单、轻量级、无副作用的集成和使用,jar 包仅 `176 KB`
- 作为 JPA 的扩展和增强,兼容 Spring Data JPA 原有功能和各种特性;
- 提供了 `XML`、Java 链式 `API` 和动态条件注解等四种方式来书写动态 SQL;
- `XML` 的方式功能强大,让 SQL 和 Java 代码解耦,易于维护;
Expand Down
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v2.3.2 修复某些情况下 JDBC 连接未释放的问题(强烈推荐升级) (2020-05-28)

- 修复了在异步多线程情况下,返回自定义实体 Bean 类型时,JDBC 连接未释放的问题,老版本可以使用 `@Transactional` 注解解决;

## v2.3.1 兼容支持最新 v2.3.0 版本的 Spring Data JPA (2020-05-18)

- 支持最新的 Spring Data JPA 版本(`v2.3.0`),同时也能兼容之前的 Spring Data JPA 版本;
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
## 特性

- 简单、轻量级、无副作用的集成和使用,jar 包仅 `181 KB`
- 简单、轻量级、无副作用的集成和使用,jar 包仅 `176 KB`
- 作为 JPA 的扩展和增强,兼容 Spring Data JPA 原有功能和各种特性;
- 提供了 `XML`、Java 链式 `API` 和动态条件注解等四种方式来书写动态 SQL;
- `XML` 的方式功能强大,让 SQL 和 Java 代码解耦,易于维护;
Expand Down
4 changes: 2 additions & 2 deletions docs/_coverpage.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
![logo](assets/images/logo.png)

# Fenix <small>2.3.1</small>
# Fenix <small>2.3.2</small>

> 为解决复杂动态 SQL 而生的 Spring Data JPA 扩展库
- 简单、可扩展、轻量级 (~181 KB jar)
- 简单、可扩展、轻量级 (~176 KB jar)
- 可返回任意自定义的实体对象
- 比 MyBatis 更加强大的动态 SQL 能力
- 支持 XML 文件、Java 链式 API、动态注解等四种方式书写动态 SQL
Expand Down
1 change: 1 addition & 0 deletions docs/more-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ Page<UserBlogInfo> queryUserBlogPageWithFenixResultType(@Param("userId") String
> 1. 上面的代码关键之处,就在 fenix 节点中配置了 `resultType` 属性的值为我们定义的**实体类的全路径名** `com.blinkfox.fenix.vo.UserBlogInfo`。这样查询结果返回的时候就能自动识别并返回了。
> 2. 另一个要点是所有查询列**都必须使用 as**来返回一个“别名”,且**这个“别名”必须跟实体类的属性名一致,不区分大小写**
> 3. 此种方式再运行时可能会与 `spring-boot-devtools.jar` 冲突,报 `No converter found capable of converting from type [xxx] to type [xxx]` 错误。建议不使用 `spring-boot-devtools.jar`
> 4. 在 Fenix `v2.3.1` 及之前的版本,**在异步多线程情况下,可能出现 JDBC 连接无法释放的问题**,强烈建议你升级 Fenix 版本为 `v2.3.2` 及之后的版本。
### (3) Java 中的使用示例

Expand Down
8 changes: 4 additions & 4 deletions docs/quick-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
<dependency>
<groupId>com.blinkfox</groupId>
<artifactId>fenix-spring-boot-starter</artifactId>
<version>2.3.1</version>
<version>2.3.2</version>
</dependency>
```

### Gradle

```bash
compile 'com.blinkfox:fenix-spring-boot-starter:2.3.1'
compile 'com.blinkfox:fenix-spring-boot-starter:2.3.2'
```

### 激活 Fenix (@EnableFenix)
Expand Down Expand Up @@ -90,14 +90,14 @@ fenix:
<dependency>
<groupId>com.blinkfox</groupId>
<artifactId>fenix</artifactId>
<version>2.3.1</version>
<version>2.3.2</version>
</dependency>
```

### Gradle

```bash
compile 'com.blinkfox:fenix:2.3.1'
compile 'com.blinkfox:fenix:2.3.2'
```

### 激活 Fenix FactoryBean
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
<dependency>
<groupId>com.blinkfox</groupId>
<artifactId>stalker</artifactId>
<version>1.0.1</version>
<version>1.1.1</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public final class FenixConfigManager {
+ " | __)/ __ \\ / \\| \\ \\/ /\n"
+ " | \\\\ ___/| | \\ |> < \n"
+ " \\___ / \\___ >___| /__/__/\\_ \\\n"
+ " \\/ \\/ \\/ \\/ v2.3.1\n";
+ " \\/ \\/ \\/ \\/ v2.3.2\n";

/**
* Fenix 配置信息实例.
Expand Down
81 changes: 0 additions & 81 deletions src/main/java/com/blinkfox/fenix/helper/ProxyHelper.java

This file was deleted.

15 changes: 6 additions & 9 deletions src/main/java/com/blinkfox/fenix/jpa/QueryResultBuilder.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.blinkfox.fenix.jpa;

import com.blinkfox.fenix.exception.FenixException;
import com.blinkfox.fenix.helper.ProxyHelper;
import javax.persistence.Query;
import org.hibernate.query.NativeQuery;
import org.hibernate.transform.ResultTransformer;
Expand Down Expand Up @@ -46,19 +45,17 @@ final class QueryResultBuilder {
* @param isNative 是否原生 SQL
* @return 额外改造后的 {@code Query} 实例.
*/
@SuppressWarnings({"deprecation", "rawtypes"})
@SuppressWarnings("deprecation")
Query build(boolean isNative) {
ResultTransformer resultTransformer = new FenixResultTransformer<>(this.getResultTypeClass());
if (isNative) {
// 获取该查询对应的 NativeQuery,设置转换类型.
NativeQuery<?> nativeQuery = ProxyHelper.getTarget(this.query);
nativeQuery.setResultTransformer(resultTransformer);
return this.query;
this.query.unwrap(NativeQuery.class)
.setResultTransformer(new FenixResultTransformer<>(this.getResultTypeClass()));
} else {
org.hibernate.query.Query hibernateQuery = ProxyHelper.getTarget(this.query);
hibernateQuery.setResultTransformer(resultTransformer);
return this.query;
this.query.unwrap(org.hibernate.query.Query.class)
.setResultTransformer(new FenixResultTransformer<>(this.getResultTypeClass()));
}
return this.query;
}

/**
Expand Down

0 comments on commit 32520e5

Please sign in to comment.