用HIBERNATE时form ,po包中 double和Double如何选

来源:百度知道 编辑:UC知道 时间:2024/09/25 23:21:57
package com.test.po.company;
/**
*CusInfoUnitGeneralgeneratedbyMyEclipse-HibernateTools
*/
publicclassCusInfoUnitGeneralimplementsjava.io.Serializable{

privateLongrowId;
`````;
privateStringloancardCode;
privateDoublebuyStockMoney;
privateStringourbankCreditLevel;
/**defaultconstructor*/
publicCusInfoUnitGeneral(){
}

publicCusInfoUnitGeneral(LongrowId){
this.rowId=rowId;
}
publicCusInfoUnitGeneral(``Integermans,StringloanCardState,DoublebuyStockMoney,```,StringlastDate){
this.rowId=rowId;
this.customerId=customerId;
····this.loanCardState=loanCardState;
this.loancardCode=loancardCode;
this.buyStockMoney=buyStockMoney;
}
publicStringgetCustomerId(){
returnthis.customerId;
}

publicvoidsetCustomerId(StringcustomerId){
this.customerId=customerId;
}
````
publicvoidsetRowId(LongrowId){
this.rowId=rowId;
}
····

int 默认值是0,Integer是null,用Integer
我的选择是包装类好!原因如下:
1。所有的sql使用的默认类型都是null,如果你把POJO中的映射属性类型写为基本类型,当查找不到记录的时候,返回null赋给基本类型就会出错
2。包装类型都可以相应的转化为基本类型,如果你设置为基本类型比如int的话,它默认初始化为0,但0本身就代表着一种含义,如果为null的话,既好理解,也可以方便开发人员转化!而且很多xml配置中默认都是null。

一个是原始类型 一个是对象类型 如果你选择对象类型的话 你就得注意给该对象初始化 (原始类型没这个必要 但是偶不喜欢原始类型)

Double 和 double在功能上是差不多的

看你用什么版本的jdk,如果使用最新的jdk,你写double和Double都无所谓,因为系统会自动转换。