Hello, I am investigation iBatis as an alternative to JPA/OpenJPA. JPA states that the behavior of the provider in the case of accessing unloaded fields on a "detached" object is "unspecified". OpenJPA returns null or throws an exception depending on the configuration. Considering the test case below, it appears that iBatis can lazy load fields outside of the session that instantiated it. Is this true or have I misinterpreted my code? If it can lazy load after the session is closed, that would be AWESOME! That would mean that eager loading is merely an optimization and not a requirement for object manipulation that takes place over multiple "user interactions". If it's true, exactly how does it work? I'm using CGLIB. Does the enhanced class keep a reference to the original DataSource for getting a new connection? Or is there some ThreadLocal work going on? Do I need to extend my test case to spin up another Thread? Thanks.
UserType ut = *new* UserType(); ut.setName("doctor"); UserTypeMapper utm = session.getMapper(UserTypeMapper.*class*); utm.insert(ut); session.commit(); *assertNotNull*(ut.getId()); User user = *new* User(); user.setName("Fred"); user.setUserType(ut); UserMapper um = session.getMapper(UserMapper.*class*); um.insert(user); session.commit(); *assertNotNull*(user.getId()); session.close(); session = factory.openSession(); um = session.getMapper(UserMapper.*class*); user = um.findById(user.getId()); session.close(); *assertEquals*("Fred", user.getName()); *assertNotNull*(user.getUserType()); // lazy loading *assertEquals*("doctor", user.getUserType().getName()); *assertEquals*(ut.getId(), user.getUserType().getId()); -- Daryl Stultz _____________________________________ 6 Degrees Software and Consulting, Inc. http://www.6degrees.com mailto:da...@6degrees.com