obj.getSetupServiceTickets()是一个set吧Set s =(Set)obj.getSetupServiceTickets();

解决方案 »

  1.   

    80%的可能是由于当你设置lazy="true"后在session关闭之后读取数据集合 导致的解决方法两个
    1.laze="false"  这样无法延迟加载了
    2.在mgr.getRequestSetupTicketById这个method中, session close之前  使用Hibernate.initialize()方法来加载集合数据Hope help
      

  2.   

    就是,延迟加载的数据在session关闭后就无法使用了
      

  3.   

    不是session的问题,我是在其关闭前调的get
      

  4.   

    obj.getSetupServiceTickets()是一个set吧Set s =(Set)obj.getSetupServiceTickets();对是set
      

  5.   

    把你getRequestSetupTicketById的代码帖出来看看
      

  6.   

    数据库里有RequestSetupTicket对应的表的数据,但没有setupServiceTickets和中间表REQUEST_TICKET_SETUP_TICKET的数据
    ========================================================
    你自己都说原因拉,数据都没有,怎么能initialize
      

  7.   

    就算没有数据也不会报 
    Failed to lazily initialize 这个异常..
      

  8.   

    问题已经找到,在many-to-many的另外一段的ServiceTicket.hbm.xml的问题,
    这是原来的:
         <joined-subclass name="SetupServiceTicket" table="SETUP_SERVICE_TICKET">
            <key column="SERVICE_TICKET_ID"/>
            
         <set name="requestSetupTickets" table="REQUEST_TICKET_SETUP_TICKET" inverse="true" lazy="true" cascade="none">
             <key column="SERVICE_TICKET_ID"/> 
             <many-to-many column="REQUEST_TICKET_NO" class="RequestSetupTicket" />
         </set>             <set name="setupDevices" table="SETUP_SERVICE_TICKET_DEVICE" cascade="save-update" inverse="true">
            <key column="SETUP_SERVICE_TICKET_ID"/>
            <one-to-many class="SetupServiceTicketDevice"/>
         </set>       
        
           <many-to-one name="saleDept" column="SALE_DEPT_ID" class="Department" not-null="false" cascade="none"/>        
            <property name="setupType" column="SETUP_TYPE" type="string" length="5" not-null="true"/>
            <property name="expectOutDate" column="EXPECT_OUT_DATE" type="date" not-null="true"/>       <property name="sales" column="SALES" type="string" length="20" not-null="false"/>
            <property name="invoiceHeader" column="INVOICE_HEADER" type="string" length="50" not-null="false"/>
            <property name="uniqueInvoiceId" column="UNIQUE_INVOICE_ID" type="string" length="10" not-null="false"/>
            <property name="paymentClause" column="PAYMENT_CLAUSE" type="string" length="5" not-null="true"/>
            <property name="projectId" column="PROJECT_ID" type="string" length="50" not-null="true"/>
            <property name="needToGo" column="NEED_TOGO" type="string" length="5" not-null="true"/>
        </joined-subclass>
      

  9.   

    这是改过后的: <joined-subclass name="SetupServiceTicket" table="SETUP_SERVICE_TICKET" proxy="SetupServiceTicket">
            <key column="SERVICE_TICKET_ID"/>
            
         <set name="requestSetupTickets" table="REQUEST_TICKET_SETUP_TICKET" inverse="false" lazy="true" cascade="save-update">
             <key column="SERVICE_TICKET_ID"/> 
             <many-to-many column="REQUEST_TICKET_NO" class="RequestSetupTicket" />
         </set>             <set name="setupDevices" table="SETUP_SERVICE_TICKET_DEVICE" lazy="true" cascade="save-update" inverse="true">
            <key column="SETUP_SERVICE_TICKET_ID"/>
            <one-to-many class="SetupServiceTicketDevice"/>
         </set>       
        
           <many-to-one name="saleDept" column="SALE_DEPT_ID" class="Department" not-null="false" cascade="none"/>        
            <property name="setupType" column="SETUP_TYPE" type="string" length="5" not-null="true"/>
            <property name="expectOutDate" column="EXPECT_OUT_DATE" type="date" not-null="true"/>       <property name="sales" column="SALES" type="string" length="20" not-null="false"/>
            <property name="invoiceHeader" column="INVOICE_HEADER" type="string" length="50" not-null="false"/>
            <property name="uniqueInvoiceId" column="UNIQUE_INVOICE_ID" type="string" length="10" not-null="false"/>
            <property name="paymentClause" column="PAYMENT_CLAUSE" type="string" length="5" not-null="true"/>
            <property name="projectId" column="PROJECT_ID" type="string" length="50" not-null="true"/>
            <property name="needToGo" column="NEED_TOGO" type="string" length="5" not-null="true"/>
        </joined-subclass>
      

  10.   

    如果有人能给出以上答案的精准的解释,或者给小弟推荐几个好用的hibernator生成工具和wssd里hibernate的插件(包括使用说明),我会把分奖励给他(她)。但鉴于以上诸位的答案并不靠谱,所以本贴只能给出100分,请诸位谅解。
    我还有一贴
    http://community.csdn.net/Expert/topic/3608/3608328.xml?temp=.2402002
    很简单,怎没人去拿分
      

  11.   

    不是session的问题,我是在其关闭前调的get===========================================你在关闭之前就算是调用get方法...也不会加载的...除非你getXXX().size()或者其他的方法访问集合后才可以加载...至于楼主怎么改的我不知道...但是这个异常究竟在什么时候报出..楼主可以查查源码