我想做什么?在加载我的项目时,我遇到了一个奇怪的异常:
rezg.admin.server.objects.common.pojo.EmailLogDetails,属性的setter方法:id
我将使用 postgres 将对象(持久化)保存到数据库中。环境是 Jboss 4 环境中的 Java 6、Hibernate 3。包含“EmailLogDetails”的 jar 位于 Jboss lib 文件夹中。
预期类型:java.lang.Integer,实际值:java.lang.Integer IllegalArgumentException 在类中:rezg.admin.server.objects.common.pojo.EmailLogDetails,属性的设置方法:id
org.hibernate.PropertyAccessException:在 org.hibernate 的 org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:104) 调用 rezg.admin.server.objects.common.pojo.EmailLogDetails.Id 的设置器时发生 IllegalArgumentException .tuple.AbstractEntityTuplizer.setIdentifier(AbstractEntityTuplizer.java:204) 在 org.hibernate.persister.entity.AbstractEntityPersister.setIdentifier(AbstractEntityPersister.java:3261) 在 org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:157) ) 在 org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:114).....
原因:java.lang.IllegalArgumentException:对象不是在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 在 sun.reflect.DelegatingMethodAccessorImpl 的 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 声明类的实例.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:42) ... 还有 74 个
电子邮件日志详细信息:
public class EmailLogDetails implements java.io.Serializable {
private static final long serialVersionUID = 1L;
private java.lang.Integer id;
private String reservationNo;
private String mailSubject;
private String fromAddress;
public String getFromAddress() {
return fromAddress;
}
public void setFromAddress(String fromAddress) {
this.fromAddress = fromAddress;
}
public java.lang.Integer getId() {
return id;
}
public void setId(java.lang.Integer id) {
this.id = id;
}
public String getMailSubject() {
return mailSubject;
}
public void setMailSubject(String mailSubject) {
this.mailSubject = mailSubject;
}
public String getMailType() {
return mailType;
}
}
XML
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"../server/default/conf/hibernate-mapping-3.0.dtd">
<hibernate-mapping auto-import="false" schema="@@portalname@@_admin">
<class name="rezg.admin.server.objects.common.pojo.EmailLogDetails" table="emaillogdetails">
<id name="Id" column="id" type="java.lang.Integer">
<generator class="sequence">
<param name="sequence">@@portalname@@_admin.seq_emaillogdetails</param>
</generator>
</id>
<property name="reservationNo" type="java.lang.String" >
<column name="reservationno" length="20" not-null="false" sql-type="varchar" />
</property>
<property name="mailSubject" type="java.lang.String" >
<column name="mailsubject" length="500" not-null="false" sql-type="varchar" />
</property>