You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Matt Schmidt <ms...@gmail.com> on 2010/09/29 23:53:05 UTC
Lazy load exception with LoadableDetachableModel
I am using LoadableDetachableModel's to load my persisted objects from the
database, but I am still getting a lazy load exception when accessing a
property that is a Set.
For example: take persistent POJO Product that has this property, where
ProductType is another persistent POJO:
private Set<ProductType> productTypes;
I get the lazy load when trying to access this property from the LDM:
Collection<ProductType> x = ((Product) model.getObject()).getProductTypes();
for(ProductType pt : x) { //lazy load here
.....
What am I missing?
Thanks,
Matt
Re: Lazy load exception with LoadableDetachableModel
Posted by Matt Schmidt <ms...@gmail.com>.
Ok after further review, my problem was because I was getting this model
from a DataProvider where I was feeding the DataProvider a List AFTER
retrieving from the persistence layer, instead of doing it IN the
DataProvider. Thanks for the help!
On Wed, Sep 29, 2010 at 6:02 PM, James Carman <ja...@carmanconsulting.com>wrote:
> Are you detaching your model? If not, it could be returning a Product
> object that was obtained during a different Hibernate session.
>
> On Wed, Sep 29, 2010 at 5:53 PM, Matt Schmidt <ms...@gmail.com>
> wrote:
> > I am using LoadableDetachableModel's to load my persisted objects from
> the
> > database, but I am still getting a lazy load exception when accessing a
> > property that is a Set.
> >
> > For example: take persistent POJO Product that has this property, where
> > ProductType is another persistent POJO:
> >
> > private Set<ProductType> productTypes;
> >
> >
> > I get the lazy load when trying to access this property from the LDM:
> >
> > Collection<ProductType> x = ((Product)
> model.getObject()).getProductTypes();
> >
> > for(ProductType pt : x) { //lazy load here
> >
> > .....
> >
> >
> > What am I missing?
> >
> > Thanks,
> > Matt
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Re: Lazy load exception with LoadableDetachableModel
Posted by James Carman <ja...@carmanconsulting.com>.
Are you detaching your model? If not, it could be returning a Product
object that was obtained during a different Hibernate session.
On Wed, Sep 29, 2010 at 5:53 PM, Matt Schmidt <ms...@gmail.com> wrote:
> I am using LoadableDetachableModel's to load my persisted objects from the
> database, but I am still getting a lazy load exception when accessing a
> property that is a Set.
>
> For example: take persistent POJO Product that has this property, where
> ProductType is another persistent POJO:
>
> private Set<ProductType> productTypes;
>
>
> I get the lazy load when trying to access this property from the LDM:
>
> Collection<ProductType> x = ((Product) model.getObject()).getProductTypes();
>
> for(ProductType pt : x) { //lazy load here
>
> .....
>
>
> What am I missing?
>
> Thanks,
> Matt
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Lazy load exception with LoadableDetachableModel
Posted by Jeremy Thomerson <je...@wickettraining.com>.
On Wed, Sep 29, 2010 at 4:53 PM, Matt Schmidt <ms...@gmail.com> wrote:
> I am using LoadableDetachableModel's to load my persisted objects from the
> database, but I am still getting a lazy load exception when accessing a
> property that is a Set.
>
> For example: take persistent POJO Product that has this property, where
> ProductType is another persistent POJO:
>
> private Set<ProductType> productTypes;
>
>
> I get the lazy load when trying to access this property from the LDM:
>
> Collection<ProductType> x = ((Product)
> model.getObject()).getProductTypes();
>
> for(ProductType pt : x) { //lazy load here
>
> .....
>
>
> What am I missing?
>
Well, it's impossible for us to tell you. You are obviously making this
call in LDM#load() after your transaction manager has closed the Hibernate
session. What are you using to do transaction / session management, etc?
--
Jeremy Thomerson
http://www.wickettraining.com
Re: Lazy load exception with LoadableDetachableModel
Posted by Igor Vaynberg <ig...@gmail.com>.
you need open-session-in-view filter
-igor
On Wed, Sep 29, 2010 at 2:53 PM, Matt Schmidt <ms...@gmail.com> wrote:
> I am using LoadableDetachableModel's to load my persisted objects from the
> database, but I am still getting a lazy load exception when accessing a
> property that is a Set.
>
> For example: take persistent POJO Product that has this property, where
> ProductType is another persistent POJO:
>
> private Set<ProductType> productTypes;
>
>
> I get the lazy load when trying to access this property from the LDM:
>
> Collection<ProductType> x = ((Product) model.getObject()).getProductTypes();
>
> for(ProductType pt : x) { //lazy load here
>
> .....
>
>
> What am I missing?
>
> Thanks,
> Matt
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org