Re: [Lift] JPA and eager fetch
Hi Chris On further reflection, I think the problem was due to improper handling of the RequestVar lifecycle on my part. I am guessing I was not properly re-attaching the variable to the JPA session. I cleaned up my variable handling - and all seems to be well (but I confess the RequestVar stuff is still a bit of black magic for me) Thanks all for all of the tips - much appreciated Warren On Sun, Nov 22, 2009 at 4:25 PM, Chris Lewis wrote: > No, CascadeType.ALL should work as expected. By chance does replacing > the use of Model.persist with Model.mergeAndFlush work as you'd expected? > > Warren Strange wrote: >> OK, I think I fixed my problem >> >> I did not call Model.persist on my linked child object. I thought the >> cascade = ALL would take care of that, but apparently not? It seems >> to work fine now. >> >> Thanks >> >> Warren >> >> >> On Fri, Nov 20, 2009 at 2:36 PM, Warren Strange >> wrote: >>> OK - just a quick follow up. >>> >>> I got a chance this afternoon to test the simple demo app that >>> Jean-Luc suggested. I changed the mapping on "books" to be >>> fetch=EAGER. and put a debug statement on the list method in >>> authorOps. Of course it works just fine :-) - so the problem lies >>> somewhere else in my code. >>> >>> I'll keep digging. >>> >>> Warren >>> >>> >>> >>> On Fri, Nov 20, 2009 at 12:48 PM, Warren Strange >>> wrote: >>>> Jim and Jean-Luc - thanks so much for your offer of assistance. >>>> >>>> It might take me a while to put together a buildable sample. I'm just >>>> learning lift and scala right now. This is not a critical problem for >>>> me, and I can work around it. When I have something I will post a >>>> follow up. >>>> >>>> Warren >>>> >>>> >>>> >>>> On Fri, Nov 20, 2009 at 12:26 PM, Jean-Luc wrote: >>>>> Your mapping looks like normal. >>>>> If you provide a buildable project, either tgz or link to github.com, I >>>>> may >>>>> be able to reproduce your problem and help you identify the issue. >>>>> >>>>> Jean-Luc >>>>> >>>>> PS : If you need a git project to fork, I just prepared >>>>> http://github.com/jlcanela/scalajpademo (based on the maven scalajpa >>>>> archetype) >>>>> >>>>> >>>>> 2009/11/20 wstrange >>>>>> >>>>>> Newbie Lift / JPA alert! >>>>>> >>>>>> I am sure I am doing something dumb here, but I can't quite figure it >>>>>> out. I have a JPA project (modelled after the lift JPA demo app). >>>>>> >>>>>> I have an object with a one-to-many association, and I want to eager >>>>>> fetch the collection. It is declared like : >>>>>> >>>>>> �...@onetomany(){ val targetEntity = classOf[OpenIdUser], val cascade = >>>>>> Array(CascadeType.ALL), val fetch=FetchType.EAGER} >>>>>> var openIds : _root_.java.util.Set[OpenIdUser] = new >>>>>> _root_.java.util.HashSet[OpenIdUser]() >>>>>> >>>>>> >>>>>> In my spa persistence unit, eager fetching works fine from the unit >>>>>> test. The unit test uses plain old emf factory instances. >>>>>> >>>>>> However, from my web application (run with jetty:run) and using >>>>>> Model.createNamedQuery, or Model.find, only the parent object is >>>>>> fetched. The collection is not. >>>>>> >>>>>> >>>>>> I gather this has something to do with the way that Model works? Or >>>>>> are my annotations being ignored when they are packed in a .jar file? >>>>>> >>>>>> Clues would be appreciated. >>>>>> >>>>>> Thanks >>>>>> >>>>>> Warren >>>>>> >>>>>> -- >>>>>> >>>>>> You received this message because you are subscribed to the Google Groups >>>>>> "Lift" group. >>>>>> To post to this group, send email to lift...@googlegroups.com. >>>>>> To unsubscribe from this group, send email to >>>>>> liftweb+unsubscr...@googlegroups.com. >>
Re: [Lift] JPA and eager fetch
Jim and Jean-Luc - thanks so much for your offer of assistance. It might take me a while to put together a buildable sample. I'm just learning lift and scala right now. This is not a critical problem for me, and I can work around it. When I have something I will post a follow up. Warren On Fri, Nov 20, 2009 at 12:26 PM, Jean-Luc wrote: > Your mapping looks like normal. > If you provide a buildable project, either tgz or link to github.com, I may > be able to reproduce your problem and help you identify the issue. > > Jean-Luc > > PS : If you need a git project to fork, I just prepared > http://github.com/jlcanela/scalajpademo (based on the maven scalajpa > archetype) > > > 2009/11/20 wstrange >> >> >> Newbie Lift / JPA alert! >> >> I am sure I am doing something dumb here, but I can't quite figure it >> out. I have a JPA project (modelled after the lift JPA demo app). >> >> I have an object with a one-to-many association, and I want to eager >> fetch the collection. It is declared like : >> >> �...@onetomany(){ val targetEntity = classOf[OpenIdUser], val cascade = >> Array(CascadeType.ALL), val fetch=FetchType.EAGER} >> var openIds : _root_.java.util.Set[OpenIdUser] = new >> _root_.java.util.HashSet[OpenIdUser]() >> >> >> In my spa persistence unit, eager fetching works fine from the unit >> test. The unit test uses plain old emf factory instances. >> >> However, from my web application (run with jetty:run) and using >> Model.createNamedQuery, or Model.find, only the parent object is >> fetched. The collection is not. >> >> >> I gather this has something to do with the way that Model works? Or >> are my annotations being ignored when they are packed in a .jar file? >> >> Clues would be appreciated. >> >> Thanks >> >> Warren >> >> -- >> >> You received this message because you are subscribed to the Google Groups >> "Lift" group. >> To post to this group, send email to lift...@googlegroups.com. >> To unsubscribe from this group, send email to >> liftweb+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/liftweb?hl=. >> >> > > > > -- > Jean-Luc Canela > jlcane...@gmail.com > > -- > > You received this message because you are subscribed to the Google Groups > "Lift" group. > To post to this group, send email to lift...@googlegroups.com. > To unsubscribe from this group, send email to > liftweb+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/liftweb?hl=. > -- You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/liftweb?hl=.
Re: [Lift] JPA and eager fetch
OK, I think I fixed my problem I did not call Model.persist on my linked child object. I thought the cascade = ALL would take care of that, but apparently not? It seems to work fine now. Thanks Warren On Fri, Nov 20, 2009 at 2:36 PM, Warren Strange wrote: > OK - just a quick follow up. > > I got a chance this afternoon to test the simple demo app that > Jean-Luc suggested. I changed the mapping on "books" to be > fetch=EAGER. and put a debug statement on the list method in > authorOps. Of course it works just fine :-) - so the problem lies > somewhere else in my code. > > I'll keep digging. > > Warren > > > > On Fri, Nov 20, 2009 at 12:48 PM, Warren Strange > wrote: >> Jim and Jean-Luc - thanks so much for your offer of assistance. >> >> It might take me a while to put together a buildable sample. I'm just >> learning lift and scala right now. This is not a critical problem for >> me, and I can work around it. When I have something I will post a >> follow up. >> >> Warren >> >> >> >> On Fri, Nov 20, 2009 at 12:26 PM, Jean-Luc wrote: >>> Your mapping looks like normal. >>> If you provide a buildable project, either tgz or link to github.com, I may >>> be able to reproduce your problem and help you identify the issue. >>> >>> Jean-Luc >>> >>> PS : If you need a git project to fork, I just prepared >>> http://github.com/jlcanela/scalajpademo (based on the maven scalajpa >>> archetype) >>> >>> >>> 2009/11/20 wstrange >>>> >>>> >>>> Newbie Lift / JPA alert! >>>> >>>> I am sure I am doing something dumb here, but I can't quite figure it >>>> out. I have a JPA project (modelled after the lift JPA demo app). >>>> >>>> I have an object with a one-to-many association, and I want to eager >>>> fetch the collection. It is declared like : >>>> >>>> �...@onetomany(){ val targetEntity = classOf[OpenIdUser], val cascade = >>>> Array(CascadeType.ALL), val fetch=FetchType.EAGER} >>>> var openIds : _root_.java.util.Set[OpenIdUser] = new >>>> _root_.java.util.HashSet[OpenIdUser]() >>>> >>>> >>>> In my spa persistence unit, eager fetching works fine from the unit >>>> test. The unit test uses plain old emf factory instances. >>>> >>>> However, from my web application (run with jetty:run) and using >>>> Model.createNamedQuery, or Model.find, only the parent object is >>>> fetched. The collection is not. >>>> >>>> >>>> I gather this has something to do with the way that Model works? Or >>>> are my annotations being ignored when they are packed in a .jar file? >>>> >>>> Clues would be appreciated. >>>> >>>> Thanks >>>> >>>> Warren >>>> >>>> -- >>>> >>>> You received this message because you are subscribed to the Google Groups >>>> "Lift" group. >>>> To post to this group, send email to lift...@googlegroups.com. >>>> To unsubscribe from this group, send email to >>>> liftweb+unsubscr...@googlegroups.com. >>>> For more options, visit this group at >>>> http://groups.google.com/group/liftweb?hl=. >>>> >>>> >>> >>> >>> >>> -- >>> Jean-Luc Canela >>> jlcane...@gmail.com >>> >>> -- >>> >>> You received this message because you are subscribed to the Google Groups >>> "Lift" group. >>> To post to this group, send email to lift...@googlegroups.com. >>> To unsubscribe from this group, send email to >>> liftweb+unsubscr...@googlegroups.com. >>> For more options, visit this group at >>> http://groups.google.com/group/liftweb?hl=. >>> >> > -- You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/liftweb?hl=.
Re: [Lift] JPA and eager fetch
OK - just a quick follow up. I got a chance this afternoon to test the simple demo app that Jean-Luc suggested. I changed the mapping on "books" to be fetch=EAGER. and put a debug statement on the list method in authorOps. Of course it works just fine :-) - so the problem lies somewhere else in my code. I'll keep digging. Warren On Fri, Nov 20, 2009 at 12:48 PM, Warren Strange wrote: > Jim and Jean-Luc - thanks so much for your offer of assistance. > > It might take me a while to put together a buildable sample. I'm just > learning lift and scala right now. This is not a critical problem for > me, and I can work around it. When I have something I will post a > follow up. > > Warren > > > > On Fri, Nov 20, 2009 at 12:26 PM, Jean-Luc wrote: >> Your mapping looks like normal. >> If you provide a buildable project, either tgz or link to github.com, I may >> be able to reproduce your problem and help you identify the issue. >> >> Jean-Luc >> >> PS : If you need a git project to fork, I just prepared >> http://github.com/jlcanela/scalajpademo (based on the maven scalajpa >> archetype) >> >> >> 2009/11/20 wstrange >>> >>> >>> Newbie Lift / JPA alert! >>> >>> I am sure I am doing something dumb here, but I can't quite figure it >>> out. I have a JPA project (modelled after the lift JPA demo app). >>> >>> I have an object with a one-to-many association, and I want to eager >>> fetch the collection. It is declared like : >>> >>> �...@onetomany(){ val targetEntity = classOf[OpenIdUser], val cascade = >>> Array(CascadeType.ALL), val fetch=FetchType.EAGER} >>> var openIds : _root_.java.util.Set[OpenIdUser] = new >>> _root_.java.util.HashSet[OpenIdUser]() >>> >>> >>> In my spa persistence unit, eager fetching works fine from the unit >>> test. The unit test uses plain old emf factory instances. >>> >>> However, from my web application (run with jetty:run) and using >>> Model.createNamedQuery, or Model.find, only the parent object is >>> fetched. The collection is not. >>> >>> >>> I gather this has something to do with the way that Model works? Or >>> are my annotations being ignored when they are packed in a .jar file? >>> >>> Clues would be appreciated. >>> >>> Thanks >>> >>> Warren >>> >>> -- >>> >>> You received this message because you are subscribed to the Google Groups >>> "Lift" group. >>> To post to this group, send email to lift...@googlegroups.com. >>> To unsubscribe from this group, send email to >>> liftweb+unsubscr...@googlegroups.com. >>> For more options, visit this group at >>> http://groups.google.com/group/liftweb?hl=. >>> >>> >> >> >> >> -- >> Jean-Luc Canela >> jlcane...@gmail.com >> >> -- >> >> You received this message because you are subscribed to the Google Groups >> "Lift" group. >> To post to this group, send email to lift...@googlegroups.com. >> To unsubscribe from this group, send email to >> liftweb+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/liftweb?hl=. >> > -- You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/liftweb?hl=.