当前位置:网站首页>MySQL string to array, merge result set, and convert to array
MySQL string to array, merge result set, and convert to array
2022-06-11 05:18:00 【A programmer who doesn't like to stay up late but often stays u】
1. Use GROUP_CONCAT Function to merge multiple result sets 
2. Use CONCAT Function to add [ ]

3. The entity class receives data
private String id;
private String name;
private String[] item;
If that doesn't work , Custom annotation processing
@TableField(typeHandler = ArrayStringTypeHandler.class, jdbcType = JdbcType.VARCHAR)
private String[] item;
/** * Store in database , take String Array to string ; * Get data from database , Convert the string to LONG Array . */
@MappedTypes({
String[].class})
@MappedJdbcTypes({
JdbcType.VARCHAR})
public class ArrayStringTypeHandler extends BaseTypeHandler<String[]> {
private static String[] l = new String[]{
};
@Override
public void setNonNullParameter(PreparedStatement ps, int i,
String[] parameter, JdbcType jdbcType) throws SQLException {
ps.setString(i, JSONUtil.toJsonStr(parameter));
}
@Override
public String[] getNullableResult(ResultSet rs, String columnName)
throws SQLException {
return JSONUtil.parseArray(rs.getString(columnName)).toArray(l);
}
@Override
public String[] getNullableResult(ResultSet rs, int columnIndex)
throws SQLException {
return JSONUtil.parseArray(rs.getString(columnIndex)).toArray(l);
}
@Override
public String[] getNullableResult(CallableStatement cs, int columnIndex)
throws SQLException {
return JSONUtil.parseArray(cs.getString(columnIndex)).toArray(l);
}
}
边栏推荐
- 工具类ObjectUtil常用的方法
- Lianrui electronics made an appointment with you with SIFA to see two network cards in the industry's leading industrial automation field first
- 49. 字母异位词分组
- Introduction to coordinate system in navigation system
- Opencv learning path (2-5) -- Deep parsing imwrite function
- Huawei equipment configuration MCE
- Comparison of gigabit network card chips: who is better, a rising star or a Jianghu elder?
- Differences between the four MQ
- New product pre-sale: 25g optical network card based on Intel 800 series is coming
- Cascade EF gan: local focus progressive facial expression editing
猜你喜欢

Inventory | ICLR 2022 migration learning, visual transformer article summary

Zed2 camera manual

The central rural work conference has released important signals. Ten ways for AI technology to help agriculture can be expected in the future

GAMES101作业7-Path Tracing实现过程&代码详细解读

WinForm (I) introduction to WinForm and use of basic controls

Lr-link Lianrui fully understands the server network card

选择数字资产托管人时,要问的 6 个问题

KD-Tree and LSH

Huawei equipment is configured to access the virtual private network through GRE

lower_ Personal understanding of bound function
随机推荐
What is the difference between gigabit network card and 10 Gigabit network card?
Common methods of tool class objectutil
Paper reproduction: expressive body capture
English digital converter
Click the icon is not sensitive how to adjust?
Section I: classification and classification of urban roads
About custom comparison methods of classes and custom methods of sort functions
Wechat applet uploads the data obtained from database 1 to database 2
ROS compilation error: could not find a package configuration file provided by "XXX“
New product release: Lianrui launched a dual port 10 Gigabit bypass network card
Preliminary understanding of DFS and BFS
KD-Tree and LSH
mysql字符串转数组,合并结果集,转成数组
Using keras to build the basic model yingtailing flower
js promise,async,await简单笔记
董明珠称“格力手机做得不比苹果差”哪里来的底气?
22、生成括号
jvm调优六:GC日志分析和常量池详解
jvm调优五:jvm调优工具和调优实战
Huawei equipment is configured to access the virtual private network through GRE