well, this is a basic requirement and should be part of the ejb spec somewhere.

-Igor


On 4/11/06, Vincent Jenks < [EMAIL PROTECTED]> wrote:
Yes...if I were using plain Hibernate and not EJB3...like I explained
in my first post.  I need another way of making this work (as Igor
said...a way to keep the session open somehow in the container) - a
way that wouldn't require any Hibernate-specific coding...

I've built several plain Hibernate (Hibernate + Servlets + EJB) where
the DAOs would open the transaction and a filter would close the
session...but that doesn't apply so much here, if I'm not mistaken.

On 4/11/06, Andrew Berman <[EMAIL PROTECTED] > wrote:
> You need Open Session In View -->
> http://www.hibernate.org/43.html
>
>
> On 4/11/06, Igor Vaynberg < [EMAIL PROTECTED]> wrote:
> >
> > in that case your container's persistence mechanism is closing the
> underlying hibernate session after the end of the invocation? this is a
> container specific problem not a wicket one. you need to figure out how to
> tell your container to keep the underlying entity manager session open so
> that lazy collections can be fetched even outside the session/stateless
> bean's method invocation.
> >
> >
> > -Igor
> >
> >
> >
> > On 4/11/06, Vincent Jenks < [EMAIL PROTECTED]> wrote:
> > > I changed the param to look like yours:
> > >
> > > new PropertyModel(blogModel, "categories")
> > >
> > > ...and I get the same exception...no luck!
> > >
> > > On 4/11/06, Igor Vaynberg < [EMAIL PROTECTED]> wrote:
> > > > you are still not using a model for the listview, you are binding the
> > > > listview to hibernate's lazy initializable set instead in this line:
> > > >
> > > >
> > > > add(new ListView("categoriesView", ((Blog)getModelObject())
> > > >  .getCategories())
> > > >
> > > > try changing that to:
> > > >
> > > > add(new ListView("categoriesView", new PropertyModel(blogModel,
> > > > "categories"));
> > > >
> > > > or create a simple wrapper around blogmodel directly if you dont want
> to use
> > > > "soft binding" and reflection.
> > > >
> > > > -Igor
> > > >
> > > >
> > > >
> > > >
> > > > On 4/11/06, Vincent Jenks < [EMAIL PROTECTED]> wrote:
> > > > >
> > > >  OK, this doesn't appear to work.  I finally got around to testing
> this
> > > > and I still get a
> > > > LazyInitializationException.
> > > >
> > > > I passed the model around and it's barfing.
> > > >
> > > > "main" page (ViewBlog.class):
> > > >
> > > >                 //get object graph in detachable model
> > > >                 IModel blogModel = new LoadableDetachableModel()
> > > >                 {
> > > >                         protected Object load()
> > > >                         {
> > > >                                 //get blog & entries
> > > >                                 Blog blog =
> > > > BlogProxy.getDefault ();
> > > >                                 return blog;
> > > >                         }
> > > >                 };
> > > >
> > > >                 //set as page model
> > > >                 setModel(blogModel);
> > > >
> > > >                 //add panel components
> > > >                 add(new TopicsPanel("topicsPanel", blogModel));
> > > >
> > > > In the TopicsPanel class:
> > > >
> > > > public class TopicsPanel extends Panel
> > > > {
> > > >         public TopicsPanel(String id, IModel blogModel)
> > > >         {
> > > >                 super(id, blogModel);
> > > >
> > > >                 //get model object
> > > >                 Blog blog = (Blog)getModelObject();
> > > >
> > > >                 //add list view repeater
> > > >                 add(new ListView("categoriesView",
> > > > ((Blog)getModelObject()).getCategories())
> > > >                 {
> > > >                         protected void
> > > > populateItem(ListItem item)
> > > >                         {
> > > >                                 //get row model
> > > >                                 final Category
> category =
> > > > (Category)item.getModelObject();
> > > >
> > > >                                 //create link
> > > >                                 Link categoryLink =
> new
> > > > PageLink("categoryLink", ViewBlog.class)
> > > >                                 {
> > > >                                         public void
> > > > onClick()
> > > >                                         {
> > > >
> > > > info("booyah!");
> > > >                                         }
> > > >                                 };
> > > >
> > > >                                 //add category name
> label
> > > >                                 categoryLink.add(new
> > > > Label("topic", category.getName ()));
> > > >
> > > >                                 //add link
> > > >
> item.add(categoryLink);
> > > >                         }
> > > >                 });
> > > >         }
> > > > }
> > > >
> > > > Where I'm trying to retrive the lazy collection in the ListView the
> > > > session has still been lost.
> > > >
> > > > What have I done wrong?  How can I get the lazily loaded collection
> > > > and not have to resort to eager fetching?
> > > >
> > > > Remember, I'm not using Hibernate directly...I'm using JBoss EJB3 in
> > > > JBoss 4.0.4RC1...I don't have a lot of control over Hibernate...no do
> > > > I want to if I want to keep my project container-independent.
> > > >
> > > > Thanks!
> > > >
> > > > On 3/20/06, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
> > > > >
> > > > > or pass the same model :)
> > > > >
> > > > >
> > > > > -Igor
> > > > >
> > > > >
> > > >  >
> > > > > On 3/20/06, Vincent Jenks <[EMAIL PROTECTED] > wrote:
> > > > > >
> > > > > > Well, in the previous page which passes the Product into this
> page...the
> > > > object was wrapped in a detachable model...not just called
> directly...so I
> > > > should try and wrap it again in the current page?
> > > > > >
> > > > > >
> > > > > >
> > > > > >  On 3/20/06, Igor Vaynberg < [EMAIL PROTECTED]> wrote:
> > > > > > >
> > > > > > > instead of using the product object directly, use a detachable
> model.
> > > > > > >
> > > > > > > you might also need to use an open session in view interceptor
> in case
> > > > jboss closes the hibernate session after your bean's method is
> finished
> > > > executing. if it does this, then by the time wicket code runs the
> object is
> > > > already disconnected from its session and thus cant load any child
> > > > collections.
> > > > > > >
> > > > > > >
> > > > > > > -Igor
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > On 3/20/06,  Vincent Jenks < [EMAIL PROTECTED] > wrote:
> > > > > > > >
> > > > > > > > OK, so I'm in a bit of a quagmire.
> > > > > > > >
> > > > > > > > I'm using Wicket + EJB3 (JBoss 4.0.4RC1) which uses Hibernate
> as the
> > > > persistence behind EJB3.
> > > > > > > >
> > > > > > > > Unless I set all of my parent/child object relationship
> annotations
> > > > to EAGER fetching...I get this error:
> > > > > > > >
> > > > > > > > "org.hibernate.LazyInitializationException :
> failed
> > > > to lazily initialize a collection of role:...."
> > > > > > > >
> > > > > > > > ...when I try to access the child collection of the parent
> object.
> > > > In my case, for example, I am passing an object to a form in Wicket
> using
> > > > the constructor:
> > > > > > > >
> > > > > > > > public class ProductDetail extends WebPage
> > > > > > > > {
> > > > > > > >     public ProductDetail()
> > > > > > > >     {
> > > > > > > >         this(null);
> > > > > > > >     }
> > > > > > > >
> > > > > > > >     public ProductDetail(Product product)
> > > > > > > >     {
> > > > > > > >         add(new
> > > > ProductDetailForm("productDetailForm", product));
> > > > > > > > ...
> > > > > > > >
> > > > > > > > The parent object being "Product" and the child being
> > > > Product.getConfigurations()....which is a List<Configuration>.
> > > > > > > >
> > > > > > > > This same ProductDetail page has a form (see above where I
> passed
> > > > the Product into the form)...and I need to access the child collection
> > > > inside the form:
> > > > > > > >
> > > > > > > >             add(new ListView("configs",
> product.getConfigurations())
> > > > > > > >             {
> > > > > > > >                 protected void populateItem(ListItem item)
> > > > > > > >                 {
> > > > > > > >                     final Configuration config =
> > > > (Configuration)item.getModelObject();
> > > > > > > >
> > > > > > > >                     item.add(new Label("quantity",
> > > > String.valueOf(config.getQuantity())));
> > > > > > > >                     item.add(new Label("name",
> config.getName()));
> > > > > > > >                       item.add(new Label("weight",
> > > > config.getWeight()));
> > > > > > > >                     item.add(new Label("price",
> String.valueOf(
> > > > config.getPrice())));
> > > > > > > >                 }
> > > > > > > >             });
> > > > > > > >
> > > > > > > > badda-bing...here's when the exception occurs.  Now...I
> *could* fix
> > > > it by setting the collection to EAGER fetching...but this could
> eventually
> > > > cause me some severe performance problems....especially once the
> collections
> > > > begin to grow in size...I just have to be able to do LAZY fetching.
> > > > > > > >
> > > > > > > > Since I'm using EJB3 CMP I don't have control over the
> hibernate
> > > > session - the container does...so my flexibility there is limited.  Is
> there
> > > > something I could do to work around this?
> > > > > > > >
> > > > > > > > Thanks!
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > > >
> -------------------------------------------------------
> > > > This SF.Net email is sponsored by xPML, a groundbreaking scripting
> language
> > > > that extends applications into web and mobile media. Attend the live
> webcast
> > > > and join the prime developer group breaking into this new coding
> territory!
> > > >
> http://sel.as-us.falkag.net/sel?cmdlnk&kid0944&bid$1720&dat1642
> > > > _______________________________________________
> > > > Wicket-user mailing list
> > > > Wicket-user@lists.sourceforge.net
> > > >
> https://lists.sourceforge.net/lists/listinfo/wicket-user
> > > >
> > > >
> > >
> > >
> > > -------------------------------------------------------
> > > This SF.Net email is sponsored by xPML, a groundbreaking scripting
> language
> > > that extends applications into web and mobile media. Attend the live
> webcast
> > > and join the prime developer group breaking into this new coding
> territory!
> > >
> http://sel.as-us.falkag.net/sel?cmdlnk&kid0944&bid$1720&dat1642
> > > _______________________________________________
> > > Wicket-user mailing list
> > > Wicket-user@lists.sourceforge.net
> > >
> https://lists.sourceforge.net/lists/listinfo/wicket-user
> > >
> >
> >
>
>


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmdlnk&kid0944&bid$1720&dat1642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to