Announcement Announcement Module
No announcement yet.
Retriving object graph for list of VOs for display at client Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Retriving object graph for list of VOs for display at client


    for some time now, i'm been trying to come up with the most optimal strategry for retrieving a list of objects for display at remote client side.

    in the course of using spring and hibernate, usually we will put all one-to-one and one-to-many or many-to-one associations as lazy loaded.

    in this way retrieving a list of objects will have better performance.

    e.g. HQL "select vo from Customer as vo"

    as such only the object vo will be hydrated.

    however, while displaying we may need to access associated objects at the client side (e.g. vo.getOffice.getAddress())

    in this case, hibernate will complain that its session has already closed.

    this is a common problem and has appeared in many posts and is well known.

    the obvious solution would be to retrieve the graph of objects for each vo retrieved.

    however, if the user is retrieving 10000 or more vos then we are in big trouble in terms of performance.

    hence what we are doing is to use "select," to retrived just the fields required for display at the client side.

    obviously this works better in terms of performance, but we lose some in terms of maintainability. since the complier cannot check that we are referencing the correct fields or have error in the HQL. since we are using recordAry[0], recordAry[1] to refernce the files.

    after any changes the only way to discover any breakage would be to run a dbunit test.

    i have also come across solutions that make use of interceptors and facade to hydrate just the required path in the object graph for each search type.

    this is better in terms of maintainability and still lacks the performance of just retrieving the required files.

    just like to hear if anyone else is facing this type of constraint and if you have any creative idea to contribute.