当前位置:网站首页>The list attribute in the entity is empty or null, and is set to an empty array
The list attribute in the entity is empty or null, and is set to an empty array
2022-04-23 05:42:00 【wyazyf】
/**
* // Handling empty arrays
* @param object
* @throws Exception
*/
public static void getObjectValue(Object object) throws Exception {
if (object != null) {//if (object!=null ) ----begin
// Get this kind of
Class<?> clz = object.getClass();
// Gets all properties of the entity class , return Field Array
Field[] fields = clz.getDeclaredFields();
for (Field field : fields) {// --for() begin
if(field.getGenericType().toString().contains("java.util.List")){
if(field.get(object)==null){
field.setAccessible(true);
field.set(object,new ArrayList<>());
// System.out.println(" Property name :" + field.getName());
// System.out.println(" Attribute types :" + field.getGenericType());
// System.out.println(" Property value :" + String.valueOf(field.get(object)));
}
}
}
}
}
版权声明
本文为[wyazyf]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230538215211.html
边栏推荐
- Linear sieve method (prime sieve)
- Use of qwbengneview and qwebchannel.
- C, class library
- The address value indicated by the pointer and the value of the object indicated by the pointer (learning notes)
- 踩坑:nacos利用startup.cmd -m standalone启动错误
- Hongji micro classroom | cyclone RPA's "flexible digital employee" actuator
- Write the declaration of a function to return the reference of the array, and the array contains 10 string objects (notes)
- Contract lock loophole
- Utf8 to STD: string and STD: string to utf8
- QT displays the specified position and size of the picture
猜你喜欢

Cross platform packaging of QT packaging program

Breadth first search topics (BFS)

Batch import of orange single micro service

Radar equipment (greedy)

‘EddiesObservations‘ object has no attribute ‘filled‘

AcWing 836. Merge set (merge set)

Jiugong magic square - the 8th Lanqiao provincial competition - group C (DFS and comparison of all magic square types)

Flutter nouvelle génération de rendu graphique Impeller

3d slicer中拉直体的生成

Isosceles triangle - the 9th Lanqiao provincial competition - group C
随机推荐
Error 2003 (HY000) when Windows connects MySQL: can't connect to MySQL server on 'localhost' (10061)
idea插件---背景播放歌曲
js数字大写方法
Step on the pit: Nacos uses startup CMD - M standalone startup error
Flutter nouvelle génération de rendu graphique Impeller
Traversal array, object parent-child communication props / $emit
SQL statement simple optimization
Common interview questions - 4 (MySQL)
Pilotage growth · ingenuity empowerment -- yonmaster developer training and pilotage plan is fully launched
What financial products will benefit during May Day?
五一劳动节期间什么理财产品会有收益?
Solid contract DoS attack
Sea Level Anomaly 和 Sea Surface Height Anomaly 的区别
Usage and difference of shellexecute, shellexecuteex and winexec in QT
Data mining -- understanding data
[the background color changes after clicking a line]
[machine learning] scikit learn introduction
MySQL create Oracle exercise table
Frequently asked interview questions - 1 (non technical)
Some pits used by uni