0 Replies Latest reply on Jul 18, 2006 7:40 PM by jeff plummer

    entities, clients, eager vs lazy fetch (ejb3)

    jeff plummer Newbie

      I have a newbie question that is probably so common there is probably a "pattern" that answers it.

      I am building an app where the client code will allow the operator to display/edit an object's data. In order to do that the client must have access somehow to all the object's data, atleast depending on the "view" the client is displaying.

      I can setup relationships to be "eager", but that seems like hitting a finishing nail with a sledge hammer. A client view really only needs acess to a subset of all the data associated with an object.

      I can have several session bean methods that provide different "fetch-join" combinations - one for each client view. But this also seems inefficient.

      What I really want is the session bean gets a subset of the data (entity and some of the related objects) and returns it to the client. Then somehow, whenever the client needs more data (i.e. calls entity.getWidgets(), when related widgets were not pre-fetched) it goes back to the database and gets those widgets.

      Whats the proper way to do this?