I would like to create unit tests for the persistence tier of my project to ensure that entities are being loaded lazily. I am using hibernate with springsource. What is a basic unit test that can guarantee that I can create an Assertion to check that? The challenge here for me at least is that while in the transaction I cannot tell if the entities are being fetched lazily and loaded upon demand or eagerly fetched.
Thanks
If you have a detached object, when you try to access the property, hibernate will throw a LazyInitializationException.
You can also use Hibernate.isInitialized