LazyInitializationException in XXManagerTestCase

4 messages Options
Embed this post
Permalink
ayan

LazyInitializationException in XXManagerTestCase

Reply Threaded More More options
Print post
Permalink
Hi,

We have tried to rewrite the built-in UserManager of appfuse, and came up with our own UserManager. For the test case of our UserManager, given a code which accesses a collection field, it returns LazyInitializationException, i.e. user.getAccounts().get(0).

The collection field is configured as FetchType.LAZY. Did I miss something here??

At the DAO test case, it works fine, (got some readings on AbstractTransactionalDataSourceSpringContext, and it seems like, this one solves the Lazy loading problem on the DAO test case), but when it comes to the Service test case, it fails, found out that BaseManagerTestCase extends the AbstractDependencyInjectionSpringContext and not the class DAO base test case uses. Does it matter? How come?

Thanks.
mraible

Re: LazyInitializationException in XXManagerTestCase

Reply Threaded More More options
Print post
Permalink
On 5/3/07, ayan <[hidden email]> wrote:

>
> Hi,
>
> We have tried to rewrite the built-in UserManager of appfuse, and came up
> with our own UserManager. For the test case of our UserManager, given a code
> which accesses a collection field, it returns LazyInitializationException,
> i.e. user.getAccounts().get(0).
>
> The collection field is configured as FetchType.LAZY. Did I miss something
> here??
>
> At the DAO test case, it works fine, (got some readings on
> AbstractTransactionalDataSourceSpringContext, and it seems like, this one
> solves the Lazy loading problem on the DAO test case), but when it comes to
> the Service test case, it fails, found out that BaseManagerTestCase extends
> the AbstractDependencyInjectionSpringContext and not the class DAO base test
> case uses. Does it matter? How come?

If I said the reason BaseManagerTestCase extends
AbstractDependencyInjectionSpringContextTests instead of
AbstractTransactionalDataSourceSpringContextTests was to show possible
lazy-loading issues, would you believe me? ;-)

If you're going to expose any of your service-layer objects through
web services, you should probably initialize all the lazy collections
in your DAO or Service layer.  In the most recent version of AppFuse,
we've removed the OpenSessionInViewFilter from web.xml.  We did it to
make it easier to use the same web.xml for any type of persistence
framework. With that being said, I don't see a problem with using
lazy-loading, so if you'd like us to change BaseManagerTestCase,
please enter an issue in JIRA.

We could also change it to extend
AbstractAnnotationAwareTransactionalTests, which allows you to use
annotations to indicate transactional methods.

http://tinyurl.com/298vaw

Matt

>
> Thanks.
> --
> View this message in context: http://www.nabble.com/LazyInitializationException-in-XXManagerTestCase-tf3684711s2369.html#a10299277
> Sent from the AppFuse - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


--
http://raibledesigns.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

ayan

Re: LazyInitializationException in XXManagerTestCase

Reply Threaded More More options
Print post
Permalink
Great input Sir.

I haven't got deeper on the appfuse and spring, If I had time to look on those Spring Test classes, I'll try. ;-)

My archi just decided to load the collection from the DAO and use it on Service layer test case, as you have suggest, we leave it out temporarily those mappings we have already created on our entities which lazy loads its collection.

cheers, ayan

mraible wrote:
If I said the reason BaseManagerTestCase extends
AbstractDependencyInjectionSpringContextTests instead of
AbstractTransactionalDataSourceSpringContextTests was to show possible
lazy-loading issues, would you believe me? ;-)

If you're going to expose any of your service-layer objects through
web services, you should probably initialize all the lazy collections
in your DAO or Service layer.  In the most recent version of AppFuse,
we've removed the OpenSessionInViewFilter from web.xml.  We did it to
make it easier to use the same web.xml for any type of persistence
framework. With that being said, I don't see a problem with using
lazy-loading, so if you'd like us to change BaseManagerTestCase,
please enter an issue in JIRA.

We could also change it to extend
AbstractAnnotationAwareTransactionalTests, which allows you to use
annotations to indicate transactional methods.

http://tinyurl.com/298vaw

Matt
>
> Thanks.
> --
> View this message in context: http://www.nabble.com/LazyInitializationException-in-XXManagerTestCase-tf3684711s2369.html#a10299277
> Sent from the AppFuse - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@appfuse.dev.java.net
> For additional commands, e-mail: users-help@appfuse.dev.java.net
>
>


--
http://raibledesigns.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@appfuse.dev.java.net
For additional commands, e-mail: users-help@appfuse.dev.java.net
Ealden Escañan

Re: LazyInitializationException in XXManagerTestCase

Reply Threaded More More options
Print post
Permalink
In reply to this post by mraible
Hi, Matt

On 5/3/07, Matt Raible <[hidden email]> wrote:
>
> If I said the reason BaseManagerTestCase extends
> AbstractDependencyInjectionSpringContextTests instead of
> AbstractTransactionalDataSourceSpringContextTests was to show possible
> lazy-loading issues, would you believe me? ;-)
>

I ran across this when I bumped into another bug[1].  Showing possible
lazy-loading issues kinda makes sense, though I'm using this class for
something other than web services.  Filed as APF-849.

[1] http://issues.appfuse.org/browse/APF-848
[2] http://issues.appfuse.org/browse/APF-849

--
Ealden Esto E. Escañan
http://ealden.net

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]