Tuesday, June 11, 2013

Re: [LazyInitializationException] failed to lazily initialize a collection of role



2013/6/11 Sahli Sabrina <sahli.sabrina@gmail.com>
Thank you a lot , can you explain me please how it works and how to use it? because  i don"nt use gin so i can't make the difference in code


Le mardi 11 juin 2013 14:57:31 UTC, Juan Pablo Gardella a écrit :


2013/6/11 Sahli Sabrina <sahli....@gmail.com>

i  did'nt find the filter in your code . can you explain me please how did you do?

thank you

Le mardi 11 juin 2013 13:31:05 UTC, Juan Pablo Gardella a écrit :
If you don't want use DTO pattern to transfer objects to UI, check this thread. I've implemented a filter that you can use to put null lazy relationships.

The problem is very common in Hibernate, check in google. It happens when you serialize the object with GWT-RPC.


2013/6/11 Sahli Sabrina <sahli....@gmail.com>
Hi everyOne,
when i try to get a list of object in "Societe" class 


i'm getting this exception
 

LazyInitializationException] failed to lazily initialize a collection of role: com.protid.prosa.shared.model.bo.Commune.soumission, no session or session was closed
[INFO] org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.protid.prosa.shared.model.bo.Commune.soumission, no session or session was closed


Notice that the class Societe have an attribute of type Adresse. the adresse has an attribute Commune . A set of "Soumission" are declared in Commune class by the annotation OneToMany like this

@OneToMany(fetch = FetchType.LAZY, mappedBy="commune",targetEntity=com.protid.prosa.shared.model.bo.Soumission.class)
@Cascade(value = {CascadeType.ALL })
private Set<Soumission> soumission =new HashSet<Soumission>();

public Set<Soumission> getSoumission(){
    return soumission;
}
 
}


i don't get where is the problem because i'm not looking  for the "soumission " objects in the Commune class !!!


here is my rpc cal function



private void getCompany(){
       
        SocieteServiceAsync rpc=clientFactory.getSocieteservicerpc();
          
 
        AsyncCallback<List<Societe>> callback = new AsyncCallback<List<Societe>>() {           
            public void onFailure(Throwable caught) {
                       
                       }
                     
                     
                    public void onSuccess(List<Societe> result) {
                         
                          if(result!=null){
                              societe=result.get(0);
                               result.get(0).getNomsociete();
                       
                          }
                    
                    }
                    };
                   
                rpc.list(callback);
 
                    
    }


Please help,

Thank you

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-we...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-we...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment