当前位置:网站首页>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
边栏推荐
- 你還不知道責任鏈模式的使用場景嗎?
- Find daffodils - for loop practice
- select 同时接收普通数据 和 带外数据
- UML项目实例——抖音的UML图描述
- OC 转 Swift 条件编译、标记、宏、 Log、 版本检测、过期提示
- Achievements in science and Technology (21)
- 【JZ46 把数字翻译成字符串】
- On the insecurity of using scanf in VS
- DS1302的电子万年历_51单片机,年月日、星期、时分秒、农历和温度,带闹钟,全套资料
- Svn detailed use tutorial
猜你喜欢

电容

线程同步、生命周期

Using MATLAB programming to realize the steepest descent method to solve unconstrained optimization problems

UML项目实例——抖音的UML图描述

qt之.pro文件详解

QT Detailed explanation of pro file

《JVM系列》 第七章 -- 字节码执行引擎

DS1302的电子万年历_51单片机,年月日、星期、时分秒、农历和温度,带闹钟,全套资料

八路抢答器系统51单片机设计【附Proteus仿真、C程序、原理图及PCB文件、元器件清单和论文等】

Chapter 7 of JVM series -- bytecode execution engine
随机推荐
select 同时接收普通数据 和 带外数据
Usage of BC
ArrayList collection basic usage
Mq-2 and DS18B20 fire temperature smoke alarm system design, 51 single chip microcomputer, with simulation, C code, schematic diagram, PCB, etc
AT89C51 MCU digital voltmeter development, measuring range 0 ~ 5V, proteus simulation, schematic diagram, PCB and C program, etc
UML project example -- UML diagram description of tiktok
Contraction mapping theorem
基于TLC5615的多路可调数控直流稳压电源,51单片机,含Proteus仿真和C代码等
555 timer + 74 series chip to build eight way responder, 30s countdown, proteus simulation, etc
L'externalisation a duré quatre ans.
51单片机+LCD12864液晶显示的俄罗斯方块游戏,Proteus仿真、AD原理图、代码、论文等
Do (local scope), initializer, memory conflict, swift pointer, inout, unsafepointer, unsafebitcast, success
OpenFaaS实战之四:模板操作(template)
单相交交变频器的Matlab Simulink建模设计,附Matlab仿真、PPT和论文等资料
Unity_代码方式添加绑定按钮点击事件
capacitance
OC 转 Swift 条件编译、标记、宏、 Log、 版本检测、过期提示
三、梯度下降求解最小θ
直流可调稳压电源的Proteus仿真设计(附仿真+论文等资料)
交通灯系统51单片机设计(附Proteus仿真、C程序、原理图及PCB、论文等全套资料)