在数据库中有一个表是双主键,在保存时出现了org.hibernate.PropertyNotFoundException: Could not find a getter for id in class com.kjs.ww.domain.QwWarnE错误。在网看了一些方案,还是不行,希望各位多指教。谢谢!!!
package com.kjs.ww.domain;/**
 * QwWarnE entity.
 * 
 * @author MyEclipse Persistence Tools
 */public class QwWarnE implements java.io.Serializable { // Fields private QwWarnEId id;
private String dtcd;
private String wnlv;
private Float mul;
private String ;
private String oper; // Constructors /** default constructor */
public QwWarnE() {
} /** minimal constructor */
public QwWarnE(QwWarnEId id) {
this.id = id;
} /** full constructor */
public QwWarnE(QwWarnEId id, String dtcd, String wnlv, Float mul,
String , String oper) {
this.id = id;
this.dtcd = dtcd;
this.wnlv = wnlv;
this.mul = mul;
this. = ;
this.oper = oper;
} // Property accessors public QwWarnEId getId() {
return this.id;
} public void setId(QwWarnEId id) {
this.id = id;
} public String getDtcd() {
return this.dtcd;
} public void setDtcd(String dtcd) {
this.dtcd = dtcd;
} public String getWnlv() {
return this.wnlv;
} public void setWnlv(String wnlv) {
this.wnlv = wnlv;
} public Float getMul() {
return this.mul;
} public void setMul(Float mul) {
this.mul = mul;
} public String getMark() {
return this.;
} public void setMark(String ) {
this. = ;
} public String getOper() {
return this.oper;
} public void setOper(String oper) {
this.oper = oper;
}}
package com.kjs.ww.domain;import java.util.Date;/**
 * QwWarnEId entity.
 * 
 * @author MyEclipse Persistence Tools
 */public class QwWarnEId implements java.io.Serializable { // Fields private String stcd;
private Date ymdhm; // Constructors /** default constructor */
public QwWarnEId() {
} /** full constructor */
public QwWarnEId(String stcd, Date ymdhm) {
this.stcd = stcd;
this.ymdhm = ymdhm;
} // Property accessors public String getStcd() {
return this.stcd;
} public void setStcd(String stcd) {
this.stcd = stcd;
} public Date getYmdhm() {
return this.ymdhm;
} public void setYmdhm(Date ymdhm) {
this.ymdhm = ymdhm;
} public boolean equals(Object other) {
if ((this == other))
return true;
if ((other == null))
return false;
if (!(other instanceof QwWarnEId))
return false;
QwWarnEId castOther = (QwWarnEId) other; return ((this.getStcd() == castOther.getStcd()) || (this.getStcd() != null
&& castOther.getStcd() != null && this.getStcd().equals(
castOther.getStcd())))
&& ((this.getYmdhm() == castOther.getYmdhm()) || (this
.getYmdhm() != null
&& castOther.getYmdhm() != null && this.getYmdhm()
.equals(castOther.getYmdhm())));
} public int hashCode() {
int result = 17; result = 37 * result
+ (getStcd() == null ? 0 : this.getStcd().hashCode());
result = 37 * result
+ (getYmdhm() == null ? 0 : this.getYmdhm().hashCode());
return result;
}}<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- 
Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
<class name="com.kjs.ww.domain.QwWarnE" table="QW_WARN_E"
schema="dbo" catalog="waterwarning">
<composite-id name="id" class="com.kjs.ww.domain.QwWarnEId">
<meta attribute="field-description" inherit="false">
@hibernate.id    generator-class="assigned"   
</meta> <key-property name="stcd" type="java.lang.String">
<meta attribute="field-description">
@hibernate.property column="STCD" length="0"
</meta> </key-property> <key-property name="ymdhm" type="java.util.Date">
<meta attribute="field-description">
@hibernate.property column="YMDHM" length="0"
</meta>
</key-property>
</composite-id> <property name="dtcd" type="java.lang.String">
<column name="DTCD" length="5" />
</property>
<property name="wnlv" type="java.lang.String">
<column name="WNLV" length="1" />
</property>
<property name="mul" type="java.lang.Float">
<column name="MUL" precision="24" scale="0" />
</property>
<property name="" type="java.lang.String">
<column name="MARK" length="256" />
</property>
<property name="oper" type="java.lang.String">
<column name="OPER" length="10" />
</property>
</class>
</hibernate-mapping>

解决方案 »

  1.   

    org.hibernate.PropertyNotFoundException: Could not find a getter for id in class com.kjs.ww.domain.QwWarnE你在get set 的时候  有没弄错  这里是在domain里面ID属性找不到  你在仔细看看
      

  2.   

      我对hibernate不熟哟,但是这种问题我可是经常在struts中遇到呀,你看一下你的myeclipse自动发布了没哦!