我如何强制Hibernate返回一个空值而不是null?
问题描述:
我正在使用Oracle 11GR2,并且当varchar2字段为空时,在空字段上执行 System.out.println
将显示 null
在我的Eclipse控制台上。
I'm using Oracle 11GR2 and when the varchar2 field is empty, doing a System.out.println
on the empty field will display null
on my Eclipse console. How can I have it display the empty string instead?
答
你的getter方法:
your getter method:
public String getVarchar2()
{
if(this.varchar2==null)
return "";
else
return this.varchar2;
}