当前位置:网站首页>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
边栏推荐
- Four ways of SSH restricting login
- 外包干了四年,废了...
- ArrayList collection basic usage
- ASEMI整流模块MDQ100-16在智能开关电源中的作用
- Detailed explanation of C language knowledge points -- first knowledge of C language [1]
- 1 - first knowledge of go language
- MQ-2和DS18B20的火灾温度-烟雾报警系统设计,51单片机,附仿真、C代码、原理图和PCB等
- Swift:Entry of program、Swift调用OC、@_silgen_name 、 OC 调用Swift、dynamic、String、Substring
- 数组模拟队列进阶版本——环形队列(真正意义上的排队)
- SVN详细使用教程
猜你喜欢
Swift:Entry of program、Swift调用OC、@_silgen_name 、 OC 调用Swift、dynamic、String、Substring
ASEMI整流模块MDQ100-16在智能开关电源中的作用
51单片机的直流电机PWM调速控制系统(附Proteus仿真+C程序等全套资料)
【STC8G2K64S4】比较器介绍以及比较器掉电检测示例程序
【无标题】
DVWA之暴力破解(Brute Force)Low-->high
Detailed explanation of SAR command
线程同步、生命周期
do(Local scope)、初始化器、内存冲突、Swift指针、inout、unsafepointer、unsafeBitCast、successor、
电容
随机推荐
MCU function signal generator, output four kinds of waveforms, adjustable frequency, schematic diagram, simulation and C program
Usage of BC
redis的五种数据类型
利用 MATLAB 编程实现最速下降法求解无约束最优化问题
Advanced application of I / O multiplexing: Processing TCP and UDP services at the same time
Find daffodils - for loop practice
Don't you know the usage scenario of the responsibility chain model?
AT89C52 MCU frequency meter (1Hz ~ 20MHz) design, LCD1602 display, including simulation, schematic diagram, PCB and code, etc
What is the main purpose of PCIe X1 slot?
Matrix exchange row and column
Basic regular expression
A good tool: aardio
[servlet] detailed explanation of servlet (use + principle)
【NLP】HMM隐马尔可夫+维特比分词
raised exception class EAccexxViolation with ‘Access violation at address 45EFD5 in module 出错
【Proteus仿真】自动量程(范围<10V)切换数字电压表
Epolloneshot event of epoll -- instance program
Solve the problem of SSH configuration file optimization and slow connection
Programming philosophy - automatic loading, dependency injection and control inversion
你还不知道责任链模式的使用场景吗?