URGENT !!! - Enumeration query ...


EJB design: URGENT !!! - Enumeration query ...

  1. URGENT !!! - Enumeration query ... (2 messages)

    Hi !

    Here are my doubts.

    I use stateless session bean as a client for the BMP entity bean. I use a business method in session bean which looks up entity bean bean and applies finder method to get the enumeration of remote interface. This enumeration is passed from entity bean to session bean and finally to the JSP client. In JSP client, the nextElement() method of enumeration, returns the remote interface of entity bean, so I have to use the entity bean directly. But the architecture of the system is JSP client talking to session bean which inturn talks to entity bean and finally to database. The retrieval is vice-versa.

    1. How should I get each element of enumeration without specifying entity bean directly from JSP client.

    2. Should I include any entry in deployment descriptor about the helper class the I use for getters and setters. And how to use the helper class for setting from client.


  2. URGENT !!! - Enumeration query ...[ Go to top ]

    You might consider not allowing your entity bean interface outside your session bean wrapper...

    If you create a set of 'value' classes (simple classes containing only data elements), your session bean can call the entity bean and get the enumeration, then it can iterate through the enumeration putting the bean data into an array of these value classes. This data in this array can then be passed back to the JSP client, either as a whole array (for smaller result sets), or via an iteration API provided by the session bean, perhaps something like this:

    class MySessionBean .... {
      private Vector detailVector; // for value classes
      private Enumeration elements;
      private EntityDetails currentDetails;
      void makeQuery(...) { /* fill vector from entity bean, & reset */ }
      void reset() { elements = detailVector.elements(); }
      int count() { return detailVector.size(); }
      boolean next() {
        if (elements.hasMoreElements()) {
           currentDetails = elements.nextElement();
           return true;
        else {
           currentDetails = null;
           return false;
      EntityDetails getEntityDetails() { return currentDetails; }
      // also can return individual fields if required
    This reduces the use of the entity bean(s) to a minimum, and ensures that only the data is passed around the server and to the client.

  3. URGENT !!! - Enumeration query ...[ Go to top ]


    I am thinking 'next()' is your business method in session bean. With this solution, you have to use stateful session bean instead of stateless bean. Beacuse between different calls from JSP to stateless bean it is not guarenteed that you are getting service from same instance of bean.