gpt4 book ai didi

java - 在 session 中保存对象时会在类 XXXX 中抛出非法参数异常

转载 作者:行者123 更新时间:2023-12-01 13:47:53 25 4
gpt4 key购买 nike

我正在尝试将 session 中的对象保存为session.save(object),但它引发了非法参数异常,并且还引发了预期类型:java.lang.Long,实际值: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

评估BaseData.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 版本

最佳答案

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

public AssessmentBaseData(){}

关于java - 在 session 中保存对象时会在类 XXXX 中抛出非法参数异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20213814/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com