Java and OR Mapping

Bozidar Dangubic

  1. Developing a application using EJB-CMP, automatically does the persistence of data in a RDBMS without the developer writing any JDBC code. In this case, what type of projects should utiltize OR Mapping tools like TopLink, Cocobase etc?
    - TopLink and CocoBase could be used if you want a nice GUI tool to do your mapping. In some instance you may find that the schema your are working with is too complicated to describe as CMP and therefore you may opt for using these tools. Overall, if you do not have a tool to provide OR mapping for you and you want one (you do not want to hand-code) then you decide on using TopLink, CocoBase, etc.
  2. These tools specify they could support EJB-BMP too, what does this mean? In BMP, the developer writes all the JDBC code in the callback methods or executes Stored procedures. Where does these tools fit in here?
    - It means that they should be extensible. You may encounter a database schema that is far to complex to be completely automated. You may have many tables with special and awkward relationship that you can solve neither with CMP nor with any commercial tools. Therefore, any tool should allow you to extend what they generate to provide a more specific persistence using stored procedures for instance or some other persistence rules that cannot be described otherwise.
  3. By using these tools, does it mean development of EJB's are not required at all as they would be generated.
    - Depends on the tool. You may still have to do some legwork to package and deploy.
  4. Does EJB-CMP latest version provide mapping a object to more than one table? If so then why go for such tools??
    - Again, this depends on your situation. Perhaps your development team likes the GUI interface for development and does not want to hand-code the EJBs. Or perhaps EJB-CMP is inadequate to solve all of the persistence issues you may have. At times, you need to represent the beans that not only come from many many tables in the database but have awkward relationships and things like that. At times, you may need to execute a database-specific function to accomplish certain things that you need during persistence. All these issues cannot possibly be solved in CMP although Sun is trying really hard and getting better with each new specification.