The beginning of the sql statement is as follows:
select sum(amount) amount, status from (select sum(demandAmount) amount, cast(case when processStatus = 'a' or processStatus = 'b' then '已完工' else '未完工' end as varchar2(14)) status from t_outsource_order where machineNo like '%xxx%' and (isdelete is null or isdelete <> '1') and processStatus is not null group by processStatus) group by status
The results of normal
Then in a Java execution on the ignorant, just take the first character to the status of this field is or is not, a variety of debug do not know what the problem is, then debug process found taken out of the field type is char instead of String type of online search, we found a solution.
Problem Cause: Constants are considered in the database is a CHAR type, Hibernate when the value of saving it as a type of Character, Character and can store only one character, so the resulting return value there is only one character. Hibernate official already exists for this bug, but never repaired.
The final solution I use is to use the cast function oracle conversion type, modify the statement as follows:
select sum(amount) amount, status from (select sum(demandAmount) amount, cast(case when processStatus = 'a' or processStatus = 'b' then '已完工' else '未完工' end as varchar2(14)) status from t_outsource_order where machineNo like '%xxx%' and (isdelete is null or isdelete <> '1') and processStatus is not null group by processStatus) group by status
Java will not get lost less in this to be a record.
Links to online articles found: https: //www.2cto.com/database/201802/716725.html
Reproduced in: https: //www.cnblogs.com/panlongfeng/p/9929742.html
The beginning of the sql statement is as follows:
select sum(amount) amount, status from (select sum(demandAmount) amount, cast(case when processStatus = 'a' or processStatus = 'b' then '已完工' else '未完工' end as varchar2(14)) status from t_outsource_order where machineNo like '%xxx%' and (isdelete is null or isdelete <> '1') and processStatus is not null group by processStatus) group by status
The results of normal
Then in a Java execution on the ignorant, just take the first character to the status of this field is or is not, a variety of debug do not know what the problem is, then debug process found taken out of the field type is char instead of String type of online search, we found a solution.
Problem Cause: Constants are considered in the database is a CHAR type, Hibernate when the value of saving it as a type of Character, Character and can store only one character, so the resulting return value there is only one character. Hibernate official already exists for this bug, but never repaired.
The final solution I use is to use the cast function oracle conversion type, modify the statement as follows:
select sum(amount) amount, status from (select sum(demandAmount) amount, cast(case when processStatus = 'a' or processStatus = 'b' then '已完工' else '未完工' end as varchar2(14)) status from t_outsource_order where machineNo like '%xxx%' and (isdelete is null or isdelete <> '1') and processStatus is not null group by processStatus) group by status
Java will not get lost less in this to be a record.
Links to online articles found: https: //www.2cto.com/database/201802/716725.html