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

数据库 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 

白衣非少年
浏览 82回答 2
2回答

陪伴而非守候

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

Cats萌萌

上一句case中的字段是gene_ids hibernate的语句中case中的字段是cropgene_ids 2个不是相同的字段,能查出来有鬼了
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

SQL Server