2017-05-20 1 views
0

나는이 오류 org.hibernate.LazyInitializationException가 : 게으르게 역할의 컬렉션을 초기화하지 못했습니다

org.hibernate.LazyInitializationException: 
failed to lazily initialize a collection of role: com.InventoryProject.Entity.Decharge.produits, 
could not initialize proxy - no Session 

HashSet의 <을 convet하려고지고 있어요>를이 <>

입니다 목록으로 기능 난에 exactyly 오류를 받고 있어요

public void SaveToPrint() throws Exception{ 


     int id_decharge = ServiceFactory.getDechargeservice().derniereDecharge(); 
     Decharge decharge = ServiceFactory.getDechargeservice().FindDecharge(id_decharge); 
     decharge.setObservations(obsrv); 
     ServiceFactory.getDechargeservice().ModifierDecharge(decharge); 

     Set<Produit> liste = new HashSet<Produit>(); 
     liste = ServiceFactory.getDechargeservice().getDechargeById(id_decharge).getProduits(); 

     liste_produits= new ArrayList<Produit>(liste); 

     ServiceFactory.getProduitservice().supprimerConsomable(); 

     FacesContext.getCurrentInstance().addMessage(null, 
       new FacesMessage(FacesMessage.SEVERITY_INFO, "Info", "Opération terminé")); 
    } 

:

,
liste_produits= new ArrayList<Produit>(liste); 

이것은 당신이이 문제를 해결 할 수있는 매핑 파일

<hibernate-mapping> 
    <class name="com.InventoryProject.Entity.Decharge" table="DECHARGE"> 
     <meta attribute="class-description"> 
     This class contains the product detail. 
     </meta> 
     <id name="id" type="int" column="ID_DECHARGE"> 
     <generator class="native"/> 
     </id> 
     <property name="beneficiaire" column="BENEFICIAIRE" type="string"/> 
     <property name="observations" column="OBSERVATIONS" type="string"/> 
     <property name="type" column="TYPE" type="string"/> 
     <property name="prix" column="PRIX" type="int"/> 
     <property name="date" column="DATE" type="string"/> 

     <set name="produits" table="PR_DECHARGE"> 
     <key column="ID_DECHARGE"></key> 
     <many-to-many class="com.InventoryProject.Entity.Produit" column="ID_PRODUIT"></many-to-many> 
     </set> 
    </class> 
</hibernate-mapping> 

입니까? 고맙습니다.

+0

(http://stackoverflow.com/questions/21574236/org-hibernate-lazyinitializationexception-could-not-initialize [org.hibernate.LazyInitializationException는 - 아니 세션 - 프록시를 초기화 할 수 없습니다] -proxy-no-sess) –

답변

관련 문제