无法将int字段设置为空值 [英] Can not set int field to null value

查看:459
本文介绍了无法将int字段设置为空值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有此int列:

@Column(length = 4)
private int contract_owner_id;

我不需要为每个表行设置始终值.当我进行选择查询时,我得到了这个异常:

I don't need to set always value for every table row. I get this exception when I make select query:

Can not set int field org.entity.contracts.contract_owner_id to null value

当表列中没有数据时,是否有某种方法可以设置麻木的设置?

Is there some way to set numb setups when there is no data into the table column?

推荐答案

原始数据类型 int 不能为 nullable .在这种情况下,您需要使用包装程序类"Integer".因此,只需替换类型即可.

The primitive datatype int isn't nullable. You need to use the Wrapper class "Integer" in this case. So just replace the type.

这篇关于无法将int字段设置为空值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆