Entity Beans versus Session Beans in a multiple schema scenario.


EJB design: Entity Beans versus Session Beans in a multiple schema scenario.

  1. I am having a bit of a dilemma between entity beans and session beans in a multiple schema context.
    We have an application where different users need to talk to diffenet databases. This database selection is done based on groups of userids.. i.e., user1 in group1 will use schema1, user1 in group2 will use schema2 and so forth.

    We could use a BMP Entity bean based mechanism which would work in this kind of scenario.. However, to my mind it seems to be a confusing approach.. Because of the logical model that one associates with Entity beans.. that they are an object representation of the database. And that they maintain state in the database.

    On the other hand, we could model this as a Session Bean. The session bean is going to be an enforced object representation of the database. The working of this is very clear as there are no ejbLoad/ejbStore and PK issues that can confusion here..

    Please reply with your thoughts..
  2. If you are a big advocate of OOP, the BMP Enitity bean approach would probably be your best approach. If performance is a bigger issue for you, I would pursue your last approach with session beans. If you wanted, I guess you could have a stateless session bean to represent each table but I prefer to be more coarse grained and have a session bean for each schema. I took this approach on my last project and was very successful with it.

    Good luck,