Re: RequestFactory Issue 6115
On Monday, June 17, 2013 10:47:56 AM UTC+2, Nermin wrote: > > > > Am Sonntag, 16. Juni 2013 23:52:08 UTC+2 schrieb Thomas Broyer: >> >> >> I'll see if I can improve the documentation. Feel free to propose patches >> yourself though: http://www.gwtproject.org/makinggwtbetter.html#webpage >> > > Thank you for your reply and the link, which is one of the best GWT > references I have see so far on the net. ... GREAT WORK! > Er, gwtproject.org is the *official* documentation for the GWT project; it's been initialized as a copy of developers.google.com/web-toolkit as the project transitions from Google to the Steering Committee. -- 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. For more options, visit https://groups.google.com/groups/opt_out.
Re: RequestFactory Issue 6115
Am Sonntag, 16. Juni 2013 23:52:08 UTC+2 schrieb Thomas Broyer: > > > > On Friday, June 14, 2013 5:55:03 PM UTC+2, Nermin wrote: >> >> Hello Thomas, >> >> Open Session In View is the right approach to go for. Thank you for this >> advice! >> I have implemented it and it works fine now. >> >> However, I have one question regarding OSIV-Pattern: >> In the Hybernate example (see link below) they *begin transaction*before >> doFilter() and >> *commit on transaction* after it. >> https://community.jboss.org/wiki/OpenSessionInView >> >> I am using standard GWT setting with DataNucleus. For some reason it does >> not let me call em.getTransaction().begin(); and >> em.getTransaction().commit(); within the filter. >> In my current implementation I can *create EntityManager* before >> doFilter() and *close it* afterwards (this works), but cannot commit >> nor rollback transaction >> > > You *should* do that (create EntityManager and close it in filter; > begin/commit transactions in each service method) > > I'll see if I can improve the documentation. Feel free to propose patches > yourself though: http://www.gwtproject.org/makinggwtbetter.html#webpage > Thank you for your reply and the link, which is one of the best GWT references I have see so far on the net. ... GREAT WORK! My code works fine now thanks to OSIV-pattern. -- 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. For more options, visit https://groups.google.com/groups/opt_out.
Re: RequestFactory Issue 6115
On Friday, June 14, 2013 5:55:03 PM UTC+2, Nermin wrote: > > Hello Thomas, > > Open Session In View is the right approach to go for. Thank you for this > advice! > I have implemented it and it works fine now. > > However, I have one question regarding OSIV-Pattern: > In the Hybernate example (see link below) they *begin transaction* before > doFilter() and *commit on transaction* after it. > https://community.jboss.org/wiki/OpenSessionInView > > I am using standard GWT setting with DataNucleus. For some reason it does > not let me call em.getTransaction().begin(); and > em.getTransaction().commit(); within the filter. > In my current implementation I can *create EntityManager* before > doFilter() and *close it* afterwards (this works), but cannot commit nor > rollback transaction > You *should* do that (create EntityManager and close it in filter; begin/commit transactions in each service method) I'll see if I can improve the documentation. Feel free to propose patches yourself though: http://www.gwtproject.org/makinggwtbetter.html#webpage -- 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. For more options, visit https://groups.google.com/groups/opt_out.
Re: RequestFactory Issue 6115
Hello Thomas, Open Session In View is the right approach to go for. Thank you for this advice! I have implemented it and it works fine now. However, I have one question regarding OSIV-Pattern: In the Hybernate example (see link below) they *begin transaction* before doFilter() and *commit on transaction* after it. https://community.jboss.org/wiki/OpenSessionInView I am using standard GWT setting with DataNucleus. For some reason it does not let me call em.getTransaction().begin(); and em.getTransaction().commit(); within the filter. In my current implementation I can *create EntityManager* before doFilter() and *close it* afterwards (this works), but cannot commit nor rollback transaction Here is the error which I get when trying to open and commit the transaction: org.datanucleus.exceptions.NucleusFatalUserException: Illegal argument Caused by: java.lang.IllegalArgumentException: cross-group transaction need to be explicitly specified, see TransactionOptions.Builder.withXGfound both Element { type: "JobCategory" id: 1 } and Element { type: "JobCategory" id: 13 } Do you have any Idea what might be the reason? It must probably have something to do with my persistence.xml settings: ... some Entities true Thank you in advance: Nermin Am Donnerstag, 13. Juni 2013 15:05:56 UTC+2 schrieb Thomas Broyer: > > > > 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(); >> @ManyToOne >> private *JobCategory *mainCategory; >> >> ... Getters / Setters >> >> public static List findAllJobCategories() { >> EntityManager em = EMFService.get().createEntityManager(); >> try { >> Query query = em.createQuery("SELECT e FROM "+ >> JobCategory.class.getSimpleName() + " e ORDER BY i18nKey"); >> return (List) query.getResultList(); >> } catch (Exception e) { >> e.printStackTrace(); >> } finally { >> em.close(); >> } >> return new ArrayList(); // Return empty list. >> } >> } >> >> >> When I call: >> JobCategoryRequest jobCategoryReq = >> this.requestFactory.jobCategoryRequest(); >> Request> 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. For more options, visit https://groups.google.com/groups/opt_out.
Re: RequestFactory Issue 6115
Hello Thomas, yes the caller gets called, but the subcategories HashSet is empty??? The select "findAllJobCategories()" returns entities with populated ancestors. However, when getSubCategories() method gets called, all ancestors are empty. Any idea what could be the reason? Is there an working example available on the net? Thank you in advance: Nermin Am Donnerstag, 13. Juni 2013 15:05:56 UTC+2 schrieb Thomas Broyer: > > > > 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(); >> @ManyToOne >> private *JobCategory *mainCategory; >> >> ... Getters / Setters >> >> public static List findAllJobCategories() { >> EntityManager em = EMFService.get().createEntityManager(); >> try { >> Query query = em.createQuery("SELECT e FROM "+ >> JobCategory.class.getSimpleName() + " e ORDER BY i18nKey"); >> return (List) query.getResultList(); >> } catch (Exception e) { >> e.printStackTrace(); >> } finally { >> em.close(); >> } >> return new ArrayList(); // Return empty list. >> } >> } >> >> >> When I call: >> JobCategoryRequest jobCategoryReq = >> this.requestFactory.jobCategoryRequest(); >> Request> 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.
Re: RequestFactory Issue 6115
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(); > @ManyToOne > private *JobCategory *mainCategory; > > ... Getters / Setters > > public static List findAllJobCategories() { > EntityManager em = EMFService.get().createEntityManager(); > try { > Query query = em.createQuery("SELECT e FROM "+ > JobCategory.class.getSimpleName() + " e ORDER BY i18nKey"); > return (List) query.getResultList(); > } catch (Exception e) { > e.printStackTrace(); > } finally { > em.close(); > } > return new ArrayList(); // Return empty list. > } > } > > > When I call: > JobCategoryRequest jobCategoryReq = > this.requestFactory.jobCategoryRequest(); > Request> 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.
RequestFactory Issue 6115
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(); @ManyToOne private *JobCategory *mainCategory; ... Getters / Setters public static List findAllJobCategories() { EntityManager em = EMFService.get().createEntityManager(); try { Query query = em.createQuery("SELECT e FROM "+ JobCategory.class.getSimpleName() + " e ORDER BY i18nKey"); return (List) query.getResultList(); } catch (Exception e) { e.printStackTrace(); } finally { em.close(); } return new ArrayList(); // Return empty list. } } When I call: JobCategoryRequest jobCategoryReq = this.requestFactory.jobCategoryRequest(); Request> 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? Thank you in advance: Nermin -- 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.