Hibernate报java.lang.IllegalArgumentException异常:
我有个CarT.hbm.xml的配置文件
<class name= "domain.CarT " table= "CarT " dynamic-update= "true " dynamic-insert= "true ">
<id name= "cId ">
<generator class= "increment "/>
</id>
<property name= "cFac " type= "string "/>
<property name= "cName " type= "string "/> <property name= "sYear " type= "long "/>
<property name= "eYear " type= "long "/>
……(其他关联信息配置等)
</class>
CarT.java 文件
public class CarT {
……
private long eYear = 0;
……
public long getEYear() {
return eYear;
}
public void setEYear(long year) {
eYear = year;
}
}
数据库导入大批数据后,系统出错,异常提示:java.lang.IllegalArgumentException,已经发现就是由于eYear为long的时候,数据表里eYear很多记录为空,这个原因引起的,现在也允许数据库存在为空的eYear,改eYear为String那就太麻烦了,想通过修改配置或改domain里的CarT类的东东,如何实现呢?还有别的好方法吗?
------解决方法--------------------------------------------------------
参数类型不对,把你所有的参数println出来,是否有参数null了?
------解决方法--------------------------------------------------------
try
<property name= "eYear " type= "long " default= "0 "/>