2017-05-20 5 views
0

Ich erhalte diesen Fehlerorg.hibernate.LazyInitializationException: failed träge, um eine Sammlung von Rolle zu initialisieren:

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

wenn ein Hashset <> Convet versucht < zur Liste>

dies die Funktion

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é")); 
    } 

ich den Fehler immer exactyly an:

liste_produits= new ArrayList<Produit>(liste); 

dies ist die Zuordnungsdatei

<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> 

können Sie dieses Problem lösen? Danke.

+0

Mögliche Duplikat [org.hibernate.LazyInitializationException - konnte nicht Proxy initialisiert werden - keine Session] (http://stackoverflow.com/questions/21574236/org-hibernate-lazyinitializationexception-could-not-initialize -proxy-no-sess) –

Antwort

Verwandte Themen