This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
How about trying with lazy="true". It will load the records lazily upon request.
SCJP,SCWCD,SCBCD,SCEA Part I
Joined: Apr 20, 2005
Using lazy feature will only make sure that the associated classes will be loaded only when it's needed.
My question still remains same. Let's say that a record is lazily loded. Web service updates the record. You query for the record, the stale record will show up because Hibernate is not aware that some other system has changed the record behind-the-scene.
Normally you'd open a new Session for each application transaction. Since each Session starts empty, Hibernate would hit the database again. Of course, if you're using a second level cache, you'd still need to address that. If you want to reuse the Session, you could evict() the object before loading it. I'm not sure if this affects the second level cache, though.
subject: Hibernate should hit db every single time