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!
- [Wicket-user] EJB3/Hibernate Lazy fetching... Vincent Jenks
- Re: [Wicket-user] EJB3/Hibernate Lazy fetching... Igor Vaynberg
- Re: [Wicket-user] EJB3/Hibernate Lazy fetching... Vincent Jenks
- Re: [Wicket-user] EJB3/Hibernate Lazy fetching.... Igor Vaynberg
- Re: [Wicket-user] EJB3/Hibernate Lazy fetch... Igor Vaynberg
- Re: [Wicket-user] EJB3/Hibernate Lazy fetch... Vincent Jenks
- Re: [Wicket-user] EJB3/Hibernate Lazy ... Igor Vaynberg
- Re: [Wicket-user] EJB3/Hibernate L... Vincent Jenks
- Re: [Wicket-user] EJB3/Hiberna... Igor Vaynberg
- Re: [Wicket-user] EJB3/Hiberna... Andrew Berman
- Re: [Wicket-user] EJB3/Hiberna... Vincent Jenks
