DAO中get类型为set的属性时报session关闭异常的处理办法!

废话不再多说,直接给一个配置实例,一目了然!

<?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.huangyz.entity.Users" table="USERS" schema="REPORT">
        <id name="id" type="java.lang.String">
            <column name="ID" length="20" />
            <generator class="native" />
        </id>
        <property name="name" type="java.lang.String">
            <column name="NAME" length="20" />
        </property>
        <property name="password" type="java.lang.String">
            <column name="PASSWORD" length="8" not-null="true" />
        </property>
        <set name="grades" table="GRADES" lazy="false"><!--HiberanteTemplate 默认的是懒加载,即lazy=true -->
            <key column="STU_ID" ></key><!-- 该表中的外键字段 -->
            <one-to-many  class="com.huangyz.entity.Grades" ></one-to-many>
        </set>
    </class>
</hibernate-mapping>

你可能感兴趣的:(DAO,session,MyEclipse,Class,generator,encoding)