在会话中保存对象时会在类XXXX中抛出illegalArgumentException

时间:2013-11-26 10:01:44

标签: java hibernate session oracle10g

我正在尝试将会话中的对象保存为 session.save(object),但它会引发非法参数异常,并且还会提升为期望类型:java.lang.Long,actual value:java.lang.Long

在什么情况下这些类型的异常会引发?请帮帮我,我搜索了很多,但我找不到解决方案

堆栈追踪:

2013-11-26 14:51:59,646 ERROR http-8081-4 org.hibernate.property.BasicPropertyAccessor - IllegalArgumentException in class: org.sakaiproject.tool.assessment.data.dao.assessment.AssessmentBaseData, setter method of property: assessmentBaseId
2013-11-26 14:51:59,661 ERROR http-8081-4 org.hibernate.property.BasicPropertyAccessor - expected type: java.lang.Long, actual value: java.lang.Long

AssessmentBaseData.java

public class AssessmentBaseData
    implements java.io.Serializable,
               org.sakaiproject.tool.assessment.data.ifc.assessment.AssessmentBaseIfc
{

 private Long assessmentBaseId;
 private String title;

public AssessmentBaseData(Long assessmentBaseId, String title){
    this.assessmentBaseId = assessmentBaseId;
    this.title = title;

}

public String getTitle() {
    return this.title;
  }

  public void setTitle(String title) {
    this.title = title;
  }

public Long getAssessmentBaseId() {
    return this.assessmentBaseId;
  }

  public void setAssessmentBaseId(Long assessmentBaseId) {


    this.assessmentBaseId = assessmentBaseId;
  }
  }
}

hbm文件的一部分

<hibernate-mapping default-lazy="false">
  <class name="org.sakaiproject.tool.assessment.data.dao.assessment.AssessmentBaseData"
    table="SAM_ASSESSMENTBASE_T">
    <id name="assessmentBaseId" column="ID" type="java.lang.Long" unsaved-value="0">
      <generator class="native">
        <param name="sequence">SAM_ASSESSMENTBASE_ID_S</param>
      </generator>
    </id>

我正在使用Oracle 10g数据库,Tomcat 6应用服务器,hibernate 3.0版本

1 个答案:

答案 0 :(得分:1)

您应该为AssessmentBaseData.class提供默认构造函数

public AssessmentBaseData(){}