当前位置:网站首页>When splicing HQL, the new field does not appear in the construction method
When splicing HQL, the new field does not appear in the construction method
2022-04-23 14:45:00 【Luo Luo's 1024】
Problem description
In the use of hibernate Splicing hql when , The new field does not appear in the construction method ( Here's a simplified version , The real situation is much more complicated )
// Entity class
public class Tmd {
private String CBh;
private Integer NSjzzaqxx;
//private String CAjysly;// Add a new field
public static final String cTmdConstructorFields = "(CBh,NSjzzaqxx)";
//public static final String cTmdConstructorFields = "(CBh,NSjzzaqxx,CAjysly)";// Add new fields to the constructor
//......Constructos......
//......getter/setter......
}
// Tool class
public class DatamodelUtils{
public static String CTmdConstructorFields = Tmd.cTmdConstructorFields;
}
adopt Hibernate Query object , Use here select new The way ,SQL How many parameters does the object in have , Entity classes should also have constructors with the same data type and number of parameters
StringBuilder hql = new StringBuilder();
hql.append("select new ").append("com.luo.Tmd").append(DatamodelUtils.CTmdConstructorFields);
This is what runs on the server , Because of the need , I am here Tmd Added a new field CAjysly, The constructor has also been modified , Finally, I put the revised Tmd.class The work put on the test environment is currently work in , Restart project , Report errors
Caused by: org.springframework.orm.hibernate3.HibernateQueryException: Unable to locate appropriate constructor on class .....
Read the log , Found no fields I added , The last one is hql That's true
select new com.luo.Tmd(CBh,NSjzzaqxx)
Why don't I add new fields ?
Cause analysis :
After adding a field , The code is not compiled
Then I immediately go to the generation environment to check Tmd.class, See if I didn't compile , Subsequent use arthas Went to see Tmd.class, It is found that the new field exists , There are also... In the constructor , At this time, I am very confused
// Before modification DatamodelUtils.class
public static String CTmdConstructorFields = "(CBh,NSjzzaqxx)";
And then look at it DatamodelUtils.CTmdConstructorFields
value , It turns out to be "(CBh,NSjzzaqxx)"
, It's still the original value , At this point, I probably understand , My replacement file is just Tmd.class, however DatamodelUtils.class It's still the same , Did not reload , Because the server didn't detect DatamodelUtils The change of
Solution :
Yes DatamodelUtils Recompile , Publish to the test environment
Reflection summary :
In the case of an incremental replacement file , Modification of constants , Remember where constants are used , Have to recompile , And then release
版权声明
本文为[Luo Luo's 1024]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231426114272.html
边栏推荐
- 想要成为架构师?夯实基础最重要
- Matrix exchange row and column
- 你還不知道責任鏈模式的使用場景嗎?
- Electronic scale weighing system design, hx711 pressure sensor, 51 single chip microcomputer (proteus simulation, C program, schematic diagram, thesis and other complete data)
- Swift Protocol 关联对象 资源名称管理 多线程GCD 延迟 once
- Usage of BC
- 科技的成就(二十一)
- 【Servlet】Servlet 详解(使用+原理)
- What is the main purpose of PCIe X1 slot?
- Raised exception class eaccexviolation with 'access violation at address 45efd5 in module error
猜你喜欢
Sword finger offer II 019 Delete at most one character to get palindrome (simple)
四层和八层电梯控制系统Proteus仿真设计,51单片机,附仿真和Keil C代码
[detailed explanation of factory mode] factory method mode
51单片机+LCD12864液晶显示的俄罗斯方块游戏,Proteus仿真、AD原理图、代码、论文等
Detailed explanation of SAR command
详解TCP的三次握手
Interviewer: let's talk about the process of class loading and the mechanism of class loading (parental delegation mechanism)
Proteus simulation design of four storey and eight storey elevator control system, 51 single chip microcomputer, with simulation and keil c code
51 Single Chip Microcomputer Design of traffic light system (with Proteus simulation, C program, schematic diagram, PCB, thesis and other complete data)
Swift: entry of program, swift calls OC@_ silgen_ Name, OC calls swift, dynamic, string, substring
随机推荐
数组模拟队列进阶版本——环形队列(真正意义上的排队)
8.4 循环神经网络从零实现
基于TLC5615的多路可调数控直流稳压电源,51单片机,含Proteus仿真和C代码等
Electronic scale weighing system design, hx711 pressure sensor, 51 single chip microcomputer (proteus simulation, C program, schematic diagram, thesis and other complete data)
Usage of BC
Eight way responder system 51 Single Chip Microcomputer Design [with Proteus simulation, C program, schematic diagram, PCB files, component list and papers, etc.]
GIS数据处理-cesium中模型位置设置
【工厂模式详解】工厂方法模式
8.2 文本预处理
Chapter 7 of JVM series -- bytecode execution engine
Solve the problem of SSH configuration file optimization and slow connection
利用 MATLAB 编程实现最速下降法求解无约束最优化问题
帧同步 实现
三、梯度下降求解最小θ
DVWA之暴力破解(Brute Force)Low-->high
基于单片机的DS18B20的数字温度监控报警系统设计【LCD1602显示+Proteus仿真+C程序+论文+按键设置等】
PWM speed regulation control system of DC motor based on 51 single chip microcomputer (with complete set of data such as Proteus simulation + C program)
在游戏世界组建一支AI团队,超参数的多智能体「大乱斗」开赛
8.5 循环神经网络简洁实现
一个月把字节,腾讯,阿里都面了,写点面经总结……