Comments (2)
没有
from mybatis-plus.
研究了一下, 使用一个定制的typeHandler可以实现:
/**
-
Type Handler for like "Status" Enum String field.
-
@author Felix Zhang 2024-05-06 10:30
-
@Version 1.0.0
*/
@MappedJdbcTypes({JdbcType.OTHER})
@MappedTypes({String.class})
@slf4j
public class StringEnumTypeHandler extends BaseTypeHandler {@OverRide
public void setNonNullParameter(PreparedStatement ps, int i, T parameter, JdbcType jdbcType) throws SQLException {
log.info("String: " + parameter);
ps.setString(i, parameter);
}@OverRide
public T getNullableResult(ResultSet rs, String columnName) throws SQLException {
log.info("value: " + rs.getString(columnName));
return (T) rs.getString(columnName);
}@OverRide
public T getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
return (T) rs.getString(columnIndex);
}@OverRide
public T getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
return (T) cs.getString(columnIndex);
}
}
然后在mybatis配置里配置 type-handlers-package 为你的包名
然后Java里使用String类型, Jdbc类型就用Other就可以.
Java里也可以用 Integer, 不过就要另外写一个typeHandler了.
from mybatis-plus.
Related Issues (20)
- 3.5.6xml中两行空行报错 HOT 1
- 代码生成器 HOT 1
- 因为MP加快了开发进度 导致我被裁员失去工作 MP 作者需要赔偿 HOT 70
- 分页插件返回IPage时包含请求参数的问题 HOT 3
- where()
- pgsql 主键id 使用uuid类型时 接口保存发生错误 HOT 5
- java.lang.NoClassDefFoundError: com/baomidou/mybatisplus/extension/plugins/inner/InnerInterceptor HOT 2
- 在不设置FieldStrategy的情况下,批量更新怎么更新字段为null值
- 安全漏洞 HOT 2
- 生成了错误的(空)查询条件语句 HOT 2
- 救命,求修复SQL注入安全漏洞,更新一版3.5.7 HOT 23
- mybatis-plus-generator-3.5.6 oracle TIMESTAMP_WITH_TIMEZONE类型未维护
- ServuceImpl的saveOrUpdateBatch中校验是否需要更新是单条查询造成速度慢的优化 HOT 1
- mybatis-plus4 凉了吗~ HOT 3
- 代码生成器,entity格式不准确 HOT 3
- 希望能解析到合并注解的自定义注解 HOT 3
- mybatisplus-generator 没有实现 notLike table HOT 2
- 3.4.3.4 怎么没有源码了或者式标签呢 HOT 1
- xml 取值错误 #{param.msgStatus}
- QueryWrapper 的 and 方法,其能否改变里面嵌套的wrapper为自定义的wrapper 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 mybatis-plus.