Postgresql数据库Java中mybatis问题记录
项目场景:
Java中使用mybatis进行数据查询,使用实体类接收报错
“Error attempting to get column ‘basin_code’ from result set. Cause: org.postgresql.util.PSQLException: 不良的类型值 long : WFG_1\n; 不良的类型值 long : WFG_1; nested exception is org.postgresql.util.PSQLException: 不良的类型值 long : WFG_1”,
问题描述
提示:这里描述项目中遇到的问题:
例如:报错存在类型不匹配的问题:
查询语句为
<select id="selectAllUnitcdBasinWscdByProdId" resultType= "com.mxpt.resource.manage.domain.ModelEngineeringRelUnitWata">SELECT DISTINCT f.parent_code as basin_code, a.engr_id, a.unitcd, b.wscdfromplan_scheme_production_config_unit aINNER JOIN model_engineering_rel_unit_wata_map b on a.engr_id = b.engr_id and a.unitcd = b.unitcdINNER JOIN plan_scheme_production c on a.prod_id = c.prod_idINNER JOIN plan_scheme d on c.plansc_id = d.plansc_idINNER JOIN data_base_section e on a.bscd = e.bscd and d.bscheme_id = e.bscheme_idINNER JOIN data_base_basin f on e.basin_code = f.basin_codewheree.del_flag = 0and a.prod_id = #{prodId}ORDER BY basin_code asc, a.unitcd asc, b.wscd asc
</select>
实体类为:
/*** 计算单元小流域** @author chen* @date 2024/5/8 21:16*/
@Data
@TableName("model_engineering_rel_unit_wata_map")
public class ModelEngineeringRelUnitWata {/*** ID*/@TableId(value = "uwata_id", type = IdType.AUTO)private Long uwataId;/*** 工程ID*/@TableField(value = "engr_id")private Long engrId;/*** 计算单元编码*/@TableField(value = "unitcd")private String unitcd;/*** 小流域编码*/@TableField(value = "wscd")private String wscd;/*** 大流域编码*/@TableField(value = "basin_code", exist = false)private String basinCode;/*** 排序*/@TableField(value = "order_num")private String orderNum;public ModelEngineeringRelUnitWata(Long engrId, String unitcd, String wscd) {this.engrId = engrId;this.unitcd = unitcd;this.wscd = wscd;}
}
报错信息:“Error attempting to get column ‘basin_code’ from result set. Cause: org.postgresql.util.PSQLException: 不良的类型值 long : WFG_1\n; 不良的类型值 long : WFG_1; nested exception is org.postgresql.util.PSQLException: 不良的类型值 long : WFG_1”,
如何修改呢?为什么会报错呢?
原因分析:
提示:这里填写问题的分析:
没有找到问题和解决方案,最后换了一个实体类来接收数据
解决方案:
提示:这里填写该问题的具体解决方案:
没有找到问题和解决方案,最后换了一个实体类来接收数据。
。。。。。。
尝试各种修改,都不行…
以后找到办法再补充,如果有知道的朋友欢迎留言…