为了账号安全,请及时绑定邮箱和手机立即绑定

前者能够获取到我要的数据,后者我怎么都是0? 请问这两段代码有什么不同?

前者能够获取到我要的数据,后者我怎么都是0? 请问这两段代码有什么不同?

白衣非少年 2023-03-21 17:13:40
数据库 MySQL 开发环境 SSH 第一段原生态sql语句: select lookum_crop_ids, capture_time, gene_symbol, patch_id, max(case when gene_ids = 23 then gene_real else 0 end) as kw, max(case when gene_ids = 24 then gene_real else 0 end) as ks, max(case when gene_ids = 25 then gene_real else 0 end) as co2, max(case when gene_ids = 26 then gene_real else 0 end) as gz, max(case when gene_ids = 27 then gene_real else 0 end) as tw, max(case when gene_ids = 28 then gene_real else 0 end) as ts from lookum_monitor_hisinfo where 1=1 and lookum_crop_ids = 67 group by patch_id, lookum_crop_ids; 第二段是经过hibernate加工后的hql select lookummoni0_.lookum_crop_ids as col_0_0_, lookummoni0_.capture_time as col_1_0_, lookummoni0_.gene_symbol as col_2_0_, lookummoni0_.patch_id as col_3_0_, max(case when lookummoni0_.cropgene_ids=23 then lookummoni0_.gene_real else 0 end) as col_4_0_, max(case when lookummoni0_.cropgene_ids=24 then lookummoni0_.gene_real else 0 end) as col_5_0_, max(case when lookummoni0_.cropgene_ids=25 then lookummoni0_.gene_real else 0 end) as col_6_0_, max(case when lookummoni0_.cropgene_ids=26 then lookummoni0_.gene_real else 0 end) as col_7_0_, max(case when lookummoni0_.cropgene_ids=27 then lookummoni0_.gene_real else 0 end) as col_8_0_, max(case when lookummoni0_.cropgene_ids=28 then lookummoni0_.gene_real else 0 end) as col_9_0_ from lookum_monitor_hisinfo lookummoni0_ where 1=1 and lookummoni0_.lookum_crop_ids=67 group by lookummoni0_.patch_id , lookummoni0_.lookum_crop_ids 
查看完整描述

2 回答

?
陪伴而非守候

TA贡献1757条经验 获得超8个赞

如果是注解的话变量与字段要一致, 如果不一致需要添加@Column(name = "xxx")

查看完整回答
反对 回复 2023-03-24
?
Cats萌萌

TA贡献1805条经验 获得超9个赞

上一句case中的字段是gene_ids 
hibernate的语句中case中的字段是cropgene_ids 
2个不是相同的字段,能查出来有鬼了

查看完整回答
反对 回复 2023-03-24
  • 2 回答
  • 0 关注
  • 58 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信