« Return to Thread: LazyInitializationException in XXManagerTestCase

Re: LazyInitializationException in XXManagerTestCase

by mraible :: Rate this Message:

Reply to Author | View in Thread

On 5/3/07, ayan <heeroyuy08@...> 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: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>


--
http://raibledesigns.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...

 « Return to Thread: LazyInitializationException in XXManagerTestCase