package com.secn.add.present.vo;import java.util.Set;public abstract class Present { /**
 * 编号a
 */
public Integer p_id;
/**
 * 名称
 */
public String p_name;
/**
 * 价值
 */
public String p_value;
/**
 * 描述
 */
public String p_description;
/**
 * 备注
 */
public String p_res;
/**
 * 批次
 */
public Set<Batch> batch;

public Integer getP_id() {
return p_id;
} public void setP_id(Integer p_id) {
this.p_id = p_id;
} public String getP_name() {
return p_name;
} public void setP_name(String p_name) {
this.p_name = p_name;
} public String getP_value() {
return p_value;
} public void setP_value(String p_value) {
this.p_value = p_value;
} public String getP_description() {
return p_description;
} public void setP_description(String p_description) {
this.p_description = p_description;
} public String getP_res() {
return p_res;
} public void setP_res(String p_res) {
this.p_res = p_res;
} public Set<Batch> getBatch() {
return batch;
} public void setBatch(Set<Batch> batch) {
this.batch = batch;
}
}
package com.secn.add.present.vo;import java.util.Date;public class Batch {

private Integer batch_id;
private Date product_date;
private Date shelf_date;
private Present present;

public Present getPresent() {
return present;
} public void setPresent(Present present) {
this.present = present;
} public Integer getBatch_id() {
return batch_id;
} public void setBatch_id(Integer batch_id) {
this.batch_id = batch_id;
} public Date getProduct_date() {
return product_date;
} public void setProduct_date(Date product_date) {
this.product_date = product_date;
} public Date getShelf_date() {
return shelf_date;
} public void setShelf_date(Date shelf_date) {
this.shelf_date = shelf_date;
}
}persent.htm.xml<class name="com.secn.add.present.vo.Present" table="_persent"> <id name="p_id" column="p_id" type="java.lang.Integer">
<generator class="native" />
</id> <property name="p_name" type="java.lang.String" column="p_name" />
<property name="p_value" type="java.lang.String" column="p_value" />
<property name="p_description" type="java.lang.String" column="p_description" />
<property name="p_res" type="java.lang.String" column="p_res" />

<set name="batch" cascade="none" inverse="true">
        <key column="present_id"></key>
         <one-to-many class="com.secn.add.present.vo.Batch"/>
        </set>
</class>Batch.hbm.xml <class name="com.secn.add.present.vo.Batch" table="_batch"> <id name="batch_id" column="batch_id" type="java.lang.Integer">
<generator class="native"/>
</id> <property name="product_date" type="java.util.Date" column="product_date" />
<property name="shelf_date" type="java.util.Date" column="shelf_date" /> <many-to-one name="present" class="com.secn.add.present.vo.Present" column="present_id"></many-to-one>

</class>
错误:Could not parse mapping document from _persent.hbm.xml

解决方案 »

  1.   

    后台配置
     <set name="batch" cascade="none" inverse="true">
                   <key column="present_id"></key>
                <one-to-many class="com.secn.add.present.vo.Batch"/>
            </set>
    java类需要这样写
    private Set batch = new HashSet(0);
      

  2.   

    persent.hbm.xml 映射的时候出错了。 你一下个加,不要一上来就全部做映射,慢慢调试
    另外:变量改为private