休眠:java.lang.Integer和int之间有什么区别?
两者之间有什么明显的区别
<property name="pwdRetryCount" type="java.lang.Integer"> <column name="pwd_retry_count" />
</property>
和
<property name="pwdRetryCount" type="int"> <column name="pwd_retry_count" />
</property>
回答:
它们仅在处理空值时有明显的区别。
这是因为int是原始数据类型不能为其分配null,而java.lang.Integer它的包装器类 int 可以接受null。
因此,如果pwd_retry_countcolumn可为空并且您用于 int映射实体对象,则对于pwd_retry_countnull 的记录,
将发生错误,因为 int无法存储null。
以上是 休眠:java.lang.Integer和int之间有什么区别? 的全部内容, 来源链接: utcz.com/qa/411099.html

