Hibernate:java.lang.Integer和int之间有什么区别吗?
两者之间有什么明显的区别吗Hibernate:java.lang.Integer和int之间有什么区别吗?,hibernate,Hibernate,两者之间有什么明显的区别吗 <property name="pwdRetryCount" type="java.lang.Integer"> <column name="pwd_retry_count" /> </property> 及 它们只有在处理空值时才有明显的区别 这是因为int是不能为其分配null的原始数据类型,而java.lang.Integer是int的包装类,可以接受null 因此,如果pwd\u retry\u count列可
<property name="pwdRetryCount" type="java.lang.Integer">
<column name="pwd_retry_count" />
</property>
及
它们只有在处理空值时才有明显的区别 这是因为
int
是不能为其分配null的原始数据类型,而java.lang.Integer
是int
的包装类,可以接受null
因此,如果
pwd\u retry\u count
列可为null,并且您使用int
映射实体对象,对于pwd\u retry\u count
为null的记录,会发生错误,因为int
无法存储null。非常有意义。谢谢
<property name="pwdRetryCount" type="int">
<column name="pwd_retry_count" />
</property>