Comments (8)
那你在 springboot 的入口,scanBasePackages 把 ngbatis 的包往前放
@SpringBootApplication(scanBasePackages = {"org.nebula.contrib", "your.domain"})
public class NgbatisDemoApplication {
}
修改 scanBasePackages 的顺序即可,其他保持你原来的样子。
让 ngbatis 的 bean 先加载,自己域下的 bean 后加载,这样就能覆盖掉有 bug 的 MapResultHandler
等下个版本发布,到时候再来回复这个issue,你把刚刚创建的文件删掉即可。
from ngbatis.
不用这么客气的~
拓展自己项目里比较个性的类型,也可以用继承AbstractResultHandler的方法,第一个泛型是dao方法的返回值类型,第二个是xml的resultType(xml没有写默认与dao方法返回值类型一致)
from ngbatis.
刚刚提交一个版本,如果你用的是1.1.0-rc版本,可以自己先继承一个AbstractResultHandler<Map, Map>,参考MapResultHandler,加一个rowsSize为0的判断
from ngbatis.
判断条件如下:
if (result.rowsSize() == 0) {
return null;
}
参考 ObjectResultHanlder.java
from ngbatis.
加了但是没起效
@Component
public class MyMapResultHandler extends AbstractResultHandler<Map, Map> {
@Override
public Map handle(Map newResult, ResultSet result, Class resultType) {
if (result.rowsSize() == 0) {
return null;
}
List<String> columnNames = result.getColumnNames();
ResultSet.Record record = result.rowValues(0);
for (int i = 0; i < columnNames.size(); i++) {
ValueWrapper valueWrapper = record.values().get(i);
newResult.put( columnNames.get(i ), ResultSetUtil.getValue( valueWrapper ));
}
return newResult;
}
}
from ngbatis.
好的,解决了感谢
from ngbatis.
If this bug occurs in your project,
The following can be used as temporary solutions:
-
Create a class in your project, for example:
@Component public class MyMapResultHandler extends AbstractResultHandler<Map, Map> { @Override public Map handle(Map newResult, ResultSet result, Class resultType) { if (result.rowsSize() == 0) { return null; } List<String> columnNames = result.getColumnNames(); ResultSet.Record record = result.rowValues(0); for (int i = 0; i < columnNames.size(); i++) { ValueWrapper valueWrapper = record.values().get(i); newResult.put( columnNames.get(i ), ResultSetUtil.getValue( valueWrapper )); } return newResult; } }
-
In scanBasePackages array, confirm that the package of ngbatis is before the project package :
@SpringBootApplication(scanBasePackages = {"org.nebula.contrib", "your.domain"}) public class NgbatisDemoApplication { }
-
Comment on this issue to receive notification when the next version is released, and then delete
MyMapResultHandler
from ngbatis.
@zb139407 @hejiahuichengxuyuan
新版本1.1.1已经发布,如果maven还下载不下来,应该是多个仓库还没同步的问题,可以明天再试试。
切换版本后,MyMapResultHandler
可以从项目中移除了。
from ngbatis.
Related Issues (20)
- xml中指明 resultType为 java.util.Map 时程序阻塞不执行 HOT 2
- java.lang.ClassCastException[update: caused by hot-reload plugin] HOT 7
- bulk insert for edges HOT 2
- go from语句 HOT 16
- error on dependency version HOT 9
- docs: searching in en docs is broken HOT 2
- No extra connection: All servers are broken. HOT 2
- 批量插入数据报错 HOT 1
- NebulaDaoBasic是否可以实现一个listEndNodes方法 HOT 2
- 支持 springboot 3.x 有时间计划嘛? HOT 8
- The problem and solution of the first query taking a long time. 第一次查询的性能问题及解决方法
- 两个脚本都基于 USE SPACE 动态切换图空间,第一个生效,第二个不生效。
- 微信丨NgBatis交流群 · NGC22 0611-29
- StackOverflowError HOT 5
- java.net.SocketException: Socket closed HOT 1
- ResultSet error: SyntaxError: syntax error near ` go ' HOT 7
- 返回值映射问题 HOT 1
- 查询失败: Create Session failed HOT 2
- 龙行龘龘,灯火万家
- 同mybatis-plus共用提示:java.lang.NullPointerException at org.nebula.contrib.ngbatis.proxy.MapperProxy.invoke(MapperProxy.java:74) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ngbatis.