Hibernate父子关系类父类列出子集时出错,帮忙看下!
---- ProductInfo类----
public class ProductInfo implements java.io.Serializable {
// Fields
private Integer piid;
private ProductTypeInfo productTypeInfo;
private byte[] piphoto;
// Constructors
/** default constructor */
public ProductInfo() {
}
/** full constructor */
public ProductInfo(ProductTypeInfo productTypeInfo, byte[] piphoto) {
this.productTypeInfo = productTypeInfo;
this.piphoto = piphoto;
}
// Property accessors
public Integer getPiid() {
return this.piid;
}
public void setPiid(Integer piid) {
this.piid = piid;
}
public ProductTypeInfo getProductTypeInfo() {
return this.productTypeInfo;
}
public void setProductTypeInfo(ProductTypeInfo productTypeInfo) {
this.productTypeInfo = productTypeInfo;
}
public byte[] getPiphoto() {
return this.piphoto;
}
public void setPiphoto(byte[] piphoto) {
this.piphoto = piphoto;
}
}
---- ProductInfo.hbm.xml---
<?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 - Hibernate Tools
-->
<hibernate-mapping>
<class name="org.bean.ProductInfo" table="productInfo" schema="dbo" catalog="ShengDian">
<id name="piid" type="integer">
<column name="PIid" />
<generator class="increment" />
</id>
<many-to-one name="productTypeInfo" class="org.bean.ProductTypeInfo" fetch="select">
<column name="PTid" not-null="true" />
</many-to-one>
<property name="piphoto" type="binary">
<column name="PIphoto" not-null="true" />
</property>
</class>
</hibernate-mapping>
------ProductTypeInfo 类----
public class ProductTypeInfo implements java.io.Serializable {
// Fields
private Integer ptid;
private String ptname;
private byte[] ptpartphoto;
private byte[] ptplanephoto;
private Integer ptgermproof;
private Integer ptheating;
private Set productRecommends = new HashSet(0);
private Set productInfos = new HashSet(0);
// Constructors
/** default constructor */
public ProductTypeInfo() {
}
/** minimal constructor */
public ProductTypeInfo(String ptname, byte[] ptpartphoto, byte[] ptplanephoto, Integer ptgermproof, Integer ptheating) {
this.ptname = ptname;
this.ptpartphoto = ptpartphoto;
this.ptplanephoto = ptplanephoto;
this.ptgermproof = ptgermproof;
this.ptheating = ptheating;
}
/** full constructor */
public ProductTypeInfo(String ptname, byte[] ptpartphoto, byte[] ptplanephoto, Integer ptgermproof, Integer ptheating, Set productRecommends, Set productInfos) {
this.ptname = ptname;
this.ptpartphoto = ptpartphoto;
this.ptplanephoto = ptplanephoto;
this.ptgermproof = ptgermproof;
this.ptheating = ptheating;
this.productRecommends = productRecommends;
this.productInfos = productInfos;
}
// Property accessors
public Integer getPtid() {
return this.ptid;
}
public void setPtid(Integer ptid) {
this.ptid = ptid;
}
public String getPtname() {
return this.ptname;
}
public void setPtname(String ptname) {
this.ptname = ptname;
}
public byte[] getPtpartphoto() {
return this.ptpartphoto;
}
public void setPtpartphoto(byte[] ptpartphoto) {
this.ptpartphoto = ptpartphoto;
}
public byte[] getPtplanephoto() {
return this.ptplanephoto;
}
public void setPtplanephoto(byte[] ptplanephoto) {
this.ptplanephoto = ptplanephoto;
}
public Integer getPtgermproof() {
return this.ptgermproof;
}
public void setPtgermproof(Integer ptgermproof) {
this.ptgermproof = ptgermproof;
}
public Integer getPtheating() {
return this.ptheating;
}
public void setPtheating(Integer ptheating) {
this.ptheating = ptheating;
}
public Set getProductRecommends() {
return this.productRecommends;
}
public void setProductRecommends(Set productRecommends) {
this.productRecommends = productRecommends;
}
public Set getProductInfos() {
return this.productInfos;
}
public void setProductInfos(Set productInfos) {
this.productInfos = productInfos;
}
}
------ProductTypeInfo.hbm.xml---------
<?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 - Hibernate Tools
-->
<hibernate-mapping>
<class name="org.bean.ProductTypeInfo" table="productTypeInfo"
schema="dbo">
<id name="ptid" type="integer">
<column name="PTid" />
<generator class="increment" />
</id>
<property name="ptname" type="string">
<column name="PTname" length="50" not-null="true" />
</property>
<property name="ptpartphoto" type="binary">
<column name="PTpartphoto" not-null="true" />
</property>
<property name="ptplanephoto" type="binary">
<column name="PTplanephoto" not-null="true" />
</property>
<property name="ptgermproof" type="integer">
<column name="PTgermproof" not-null="true" />
</property>
<property name="ptheating" type="integer">
<column name="PTheating" not-null="true" />
</property>
<set name="productInfos" inverse="true" ">
<key>
<column name="PTid" not-null="true" />
</key>
<one-to-many class="org.bean.ProductInfo" />
</set>
</class>
</hibernate-mapping>
---------出错位置----------
ProductTypeInfo pti = (ProductTypeInfo) session.load(ProductTypeInfo.class,new Integer(1));
Set set = pti.getProductInfos();//这个位置总是出错
麻烦知道的帮忙指点一下!谢谢!