Enterprise Java Development@TOPIC@

Chapter 98. Managed Entities and Remote Interfaces

98.1. Provider Proxy Classes
98.2. Cleansed DTOs
98.3. Lazy Load Exception
98.4. Load thru "Touching" Object Tree in Remote Facade
98.5. Load thru Fetching Object Tree in Query
98.6. Abstract Remote Interface View with DTO
98.7. Summary

  • Room has mandatory reference to Floor and option reference to Guest

  • fetch=LAZY references most likely will be proxies implemented by JPA provider classes


  • Room entities returned from query are passed to client


  • Room returned with proxy class (Floor_$$_jvst9a8_0)between Room and Floor

  • Requires client to have hibernate-core in classpath


  • EJB Remote facade creating new instances of @Entity classes


  • Client now gets Room.floor without provider proxy class in between


  • Rooms fetch=LAZY

  • Rooms must be fetched within same DB session when using that collection


  • Floor being marshaled directly back to client without addressing LAZY fetches


  • Floor can be accessed

  • Floor.room access causes Lazy-load exception of collection


  • Server-side code, within the DB session boundary stimulates references to be loaded prior to marshaling back to client





  • Join fetch used to EAGER-ly load child rows

  • Less trips to DB for fatch=LAZY mappings


  • Still have to know "when is enough -- enough"


  • More information than the client wants/needs

  • More information than what client should have

  • But that is how out server-side model is designed...


  • Client only needed to know if room was occupied -- not by who


  • Room DTO class is only expressing that room is occupied


  • Similar to @Entity cleansing since DTO classes aren't managed

  • Can indirectly solve LAZY-load issue because @Entity is walked on server-side

  • Must still pay attention to DB access for performance reasons


  • Client no longer has access to who is in each room -- but server-side does