On Thursday, June 13, 2013 2:57:02 PM UTC+2, Nermin wrote:
>
> Hello group,
>
> Is the issue 6115 Fixed in GWT 2.5 or not??
> http://code.google.com/p/google-web-toolkit/issues/detail?id=6115
>
> My problem is that on a entity with recursive relation the ancestors are 
> not loaded when calling with(ancestors).
>
> Here is my code:
>
> @Entity
> public class *JobCategory *{
>     // -- Recursive Relation mainCategory - SubCategories
>     @*OneToMany*(mappedBy = "mainCategory", cascade = CascadeType.ALL)
>     private Set<*JobCategory*> *subCategories *= new 
> HashSet<JobCategory>();
>     @ManyToOne
>     private *JobCategory *mainCategory;
>
> ... Getters / Setters 
>
>     public static List<JobCategory> findAllJobCategories() {
>         EntityManager em = EMFService.get().createEntityManager();
>         try {
>             Query query = em.createQuery("SELECT e FROM "+ 
> JobCategory.class.getSimpleName() + " e ORDER BY i18nKey");
>             return (List<JobCategory>) query.getResultList();
>         } catch (Exception e) {
>             e.printStackTrace();
>         } finally {
>             em.close();
>         }
>         return new ArrayList<JobCategory>(); // Return empty list.
>     }
> }
>
>
> When I call: 
> JobCategoryRequest jobCategoryReq = 
> this.requestFactory.jobCategoryRequest();
> Request<List<JobCategoryProxy>> req = 
> jobCategoryReq.findAllJobCategories().with("*subCategories*");
> req.fire(receiver);
>
> ... The call will return categories but without subcatgeories. (The list 
> is always empty).
> I checked the DB, it is all fine there.
>
> Can it be that the Bug 6115 has not been fixed, even though its status 
> says so, or am I doing something wrong here?
>

Have you checked whether the caller is called? if it is, does it return a 
populated set?

You're supposed to use an open-session-in-view (aka session-per-request) 
pattern with RequestFactory, rather than creating/closing an EntityManager 
in each service method. In this simple example (a single service method 
call in the RequestContext, with no shared object between the request 
–arguments– and the response), it shouldn't cause any harm *except* if you 
lazy-load your linked entities.

-- 
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+unsubscr...@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.


Reply via email to