entity bean question


EJB design: entity bean question

  1. entity bean question (2 messages)

    how can an entity bean be reused by multiple clients?
    If the data stored in its fields are specific to a client than how do i decide that the entity bean is not needed by this client and is ready for use by another client?
    If it is the case that entity beans can't in fact be reused than it seems stateless session beans provide more advantages than entity beans in terms of efficiency, with only a small amount of jdbc code added??
    am i right, way off the mark??

    Threaded Messages (2)

  2. entity bean question[ Go to top ]

    Just to make sure I understand what you're asking for, I want to clarify one point. The word 'entity bean' is overused and may mean different things in different contexts. It could mean:

    * An object instance of an entity bean class
    * An instance of data in a database, such as a row
    * An entity bean class

    There is reuse of all 3 of the above.

    * An application server can reuse an object instance of an entity bean class. The idea is to save on garbage collection time and reuse an object to represent a different primary key. This occurs when the entity bean instance is transitioned to-and-from the ready state and pooled state. The EJB specification's entity bean component contract has a diagram that illustrates this.

    * An instance of data in the database, such as a row, can be reused by multiple clients simultaneously by setting the proper transaction isolation level.

    * An entity bean class is easily reused by multiple clients because the class can be instantiated many times. Each instance could represent a different row in the database, or could represent the same row. Concurrency and locking is achieved through either the database via transactions that occur during ejbStore() and ejbLoad(), or via an in-memory distributed shared object cache that performs locking at the object level.

    Hope that helps,
  3. entity bean question[ Go to top ]

    Entity beans generally represent a row in a table. As you may not want different users to access/modify the same row in a table. Depending on how much safe you want your data to be you set isolation levels- Read commited, Repeatable Read etc..

    Now this determines whether more than 1 clients can access the same row of the table.
    In short 'whether or not a row is needed or not by a client' is decided by the transaction it is in.
    Hope this helps.
    Ram Cherote