Sunday, September 16, 2007

em.clear()

Using the entity manager directly in unit tests can give strange results. I spent about half hour trying to figure out one of my tests was failing .. it was relying on a class which was supposed to pull out a lazily-loaded collection that should have been pulled out when being converted to a value object. It didn't work even though I could see the relationship was valid and present in the database. In the end, it's because I took away the em.clear() statement in my test setup method.

No comments: