2 Replies Latest reply on Apr 7, 2004 10:49 AM by richardzheng

    CMP/BMP or JDO/hibernate

    Paulo Neves Newbie

      Hi,
      I want to create an Intranet application for an enterprise with 50 employees.
      I work in java for a long but it's my first time that I will do anything with EJBs.
      Well, I do my study work, and I learn a bit about Ejb ( session beans, stateless beans, cmp beans and bmp beans ).
      I consider CMP very strange ( because I like db sql power, and not simulate with ejb container, it's a little strange do that ), and I think that CMP could limit my work, but it was only my assumptions because I work with jdbc for a long time.

      I'd readed some foruns, and now I'm very confuse because some say that persistence CMP is good, other says that CMP is very bad, and the best is to use JDO or hibernate.

      I think thats depend.

      I want a begginer help ( could be your opinion, url to some explanation ) to design my intranet. I don't want a solution for big machines, because I only have a Pentium IV, 2.4G and 1Gb ram.

      And so, I have some questions to do.

      1. It's EJB proper for me ?
      If not, I can I use J2EE server like JBOSS ? With what tecnologies ?

      2. Can I use Session/stateless EJBs with JDO or Hibernate persistence ?
      If so, It will be scalable ? Can I have transations with this ?

      3. JDO or Hibernate ?

      4. What's your solution ?

      thanks,
      Paulo

        • 1. Re: CMP/BMP or JDO/hibernate
          Jeff Beal Newbie

          I'm pretty new to the EJB arena, too, but I'll try to throw out a couple of responses to your questions.

          1) Is EJB right for you? Who knows. A lot of people have accused EJB of being "overkill" for most applications. That may be so, but a good development tool (such as XDoclet) can go a long way to removing the development-time complexities of EJB while a good application server can achieve excellent performance with EJB's, so I really don't see this as a problem. Besides, applications grow over time. What is overkill when you first launch an application may be exactly what you need further down the road. Right now, in the applications that I've been developing, I have not been using many of the features of EJB (declarative security and transactions, remote access). But, the applications I'm developing are still in their infancy, and will probably need those eventually.
          If you decide not to use EJB's, you can still use JBoss.

          2) Can you use stateless / session beans with JDO or Hibernate? Just to clarify, here's an explanation of the difference between session beans and entity beans from Monson-Haefel's "Enterprise JavaBeans" (A great book from O'Reilly that I've found very useful in learning EJB.): "an entity bean has persistent state; session and message-driven beans ... do not have persistent state". So, regardless of the persistence mechanism you use, you should make your persistent beans entity beans. I've found the CMP mechanisms adequate for my needs so far, except for the limitations of EJB-QL, which I've been able to circumvent using a resource reference to my database and a few quick JDBC calls. If you want more control over the persistence, create a bean-managed persistence entity bean. (I haven't looked into JDO or Hibernate, but I assume that you could use either of them as the bean-managed persistence mechanism without a problem.) The great thing is that, since entity beans are nicely encapsulated objects, you can always start with one approach and change it later as needed, and your client application will never care.

          • 2. Re: CMP/BMP or JDO/hibernate
            richardzheng Newbie

            We can use Session Bean with JDO or Hibernate O/R mapping instead of with CMP or BMP. It is said that CMP or BMP has poor performance. I am not sure that JDO or Hibernate O/R mapping has the same advantages as Entity Bean such as security and transaction.

            The homepage of JBoss.org shows that Hibernate O/R mapping is the most popular O/R mapping solution.

            Richard