Discussions

EJB design: How to process mass result set query by EJB ?

  1. How to process mass result set query by EJB ? (2 messages)

    There are two ways I can reach.
    (1)Access Entity EJB details object through Session Bean. Session Bean may be deployed in the same application server as the entity bean.

    (2)Access database directly with Session Bean, but there are two way to access the same table.

    How I can do it? Or another way suitable to it.
    Expect your answer urgently.
  2. Hi,

    if your client is a JSP page, then one option would be to create a java bean that scrolls through your resultset(jdbc or xml) returned from a session ejb. In other words, the java bean would ensure that only a subset of the resultset is returned at any given time. You could add methods that allow for retrieving the first, previous, next, or last subset of the resultset. Just a thought....

    Comments?
  3. Ideally, you should create a stateless session EJB which is used to control access to all entity EJBs. If you are returning a large result set, then you should define the API in your stateless session bean such that it can limit the amount of data returned.

    For example, if you build an OrderController stateless session bean, you might implement the API: Order[] getOrders(int startRow, int rowCount). This method will return an array of order objects that are limited based on the starting row and row count. Ultimately, within your database, you can use constructs like "rownum" to limit the amount of data that is actually returned by your database. This will result in the least amount of network traffic, database work, etc.

    Russ