0 Replies Latest reply on Jan 12, 2004 4:41 PM by nic7834

    Entity beans: behind the scenes explanation, please?!

    nic7834

      Hi

      Could someone help me understand so i can do things proper:

      Assume I have a stateless session bean call a finder method that returns a collection of three entity beans representing rows 10, 12 and 15 of table Employees with columns ID, firstname and lastname.

      This is what i thought was happening:
      1) JBoss queries the DB which returns three rows.
      2) JBoss creates or obtains from the pool three instances and populates them with the corresponding table data.
      3) The SLSB receives a collection of three proxies to the bean instances. Calls to read ID, firstname and lastname from a bean proxy just read the data in the corresponding bean instance.
      4) The SLSB should release the proxies as a final step to signal to JBoss that it can release the bean instances back the pool. If this does not happen, the bean instances are returned eventually on a timeout.

      Seems like this is closer to what's happening:
      1) JBoss queries the DB which returns three rows.
      2) JBoss creates or obtains from the pool three instances and populates them with METADATA pointing to the matching three table rows. Three proxies are then generated with the metadata.
      3) The entity bean instances may be cached or returned back to their pool.
      4) The SLSB receives the proxies and calls here to read/write column data result in sql queries on the backend. So 'getting' the columns ID, firstname and lastname means three sql select queries.
      5) JBoss receives the entity bean proxy call with embedded metadata for the corresponding row. If the corresponding bean instance is not in cache, it creates or fetches one from the pool and associates the instance with the row concerned. Calls to access column data then result in sql queries as described in step (4).
      6) The SLSB does not need to take any specific action on the proxies once done. There's no need to call any method to release the bean instances or set the proxies to null.

      Can someone iron out EXACTLY what is happening. I guess it's possible in the latter case to just populate the entity bean with all the columns and not read each column as required. Is their a JBoss/app server setting to determine this behaviour?

      Thanks in advance!