this usecase will be much better when we release 2.0

EditProductPage(IModel) is not nearly as nice as EditProductPage(IModel<Product>)

-Igor


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!




Reply via email to