Inheritance and entity beans?


EJB design: Inheritance and entity beans?

  1. Inheritance and entity beans? (2 messages)

    I am currently researching EJB as the architecture on which to build the next phase of our product. Unfortunately, our product makes great use of inheritance for extending entities; not a strong point of EJB's from what I have seen so far.

    In particular there are issues with inheriting home interfaces (can't overload the findByPrimaryKey method if you want to use the same PK class for all entities - as the return types will be the same), and attempting to cast remote references that have been returned to a more specific type. With the latter, we have explored the possibility of some method on our base entity bean, called 'getRemoteReferenceToMostDerivedClass()' which would use some component of the primary key to find out the deepest class name of the entity bean, from which the home interface could be derived. findByPrimaryKey() could then be invoked and a more specific remote reference returned. The transaction and locking issues that could result boggle the mind however.

    I'm keen in discussing this matter further!
  2. Inheritance and entity beans?[ Go to top ]

    The EJB specification is not very clear about EJB inheritance.So it might be upto the vendor,to what extent,the inheritance is supported for EJB.The best EJB inheritance support,I have found is provided in VisualAge/Websphere.

    First,your inheritance of entity beans must strictly conform to the database schema that already exists(or will be defined).For this you can follow a top-down approach(Database schema being generated from attributes present in EJB) or a bottom up approach(EJBs generated from tables in the database schema).

    Note that you can define provide inheritance for remote interfaces as well as implementation classes,but session beans cannot inherit from entity beans and vice versa.Moreover,you cannot mix and match stateless and stateful session beans.

    As regards implementing inheritance of home interfaces is concerned,the finders on the homes in the inheritance hierarhies should return a collection of root EJB class.The root home will implement its finders with queries over the tables of its subclasses.
  3. Inheritance and entity beans?[ Go to top ]

    I am currently researching O/R Mapping market and O/R tools applicability to real life enterprise system development. I would like to revive the discussion of last summer with the question:

    Which design concept (top-down or bottom-up) is preferable, why and in what situation?

    As explained in previous message, the top-down design requires data schema to be built from object/EJB model, while bottop-up design calls for generation of objects/EJBs based on existing/projected data schema.

    Any feedback is greatly appreciated.