8 Replies Latest reply on Mar 25, 2004 10:54 PM by pearl81

    CMP vs. BMP

    rais

      I need to know what is the fastest cmp or bmp. I read in article below, that you should always use CMP.

      http://www.fawcette.com/javapro/2001_12/magazine/features/kkothapalli/default_pf.aspx
      Chapter 6

      Whenever possible, use container-managed persistence (CMP) rather than bean-managed persistence (BMP) In BMP, the bean provider codes database access calls using JDBC, SQLJ, and so on in bean methods. In CMP, the container provider tools generate database access calls at the enterprise bean's deployment time. The bean provider must specify, in the deployment descriptor, the list of instance fields for which container provider tools must generate access calls. CMP has the advantage that the bean class can be independent of the data source. Another advantage is that application vendors generate optimized code for CMP to improve database access performance.


        • 1. Re: CMP vs. BMP

          So what is wrong with that answer?

          • 2. Re: CMP vs. BMP
            rais

            I just want to here what other peoples opinion.
            is that true, that you should always use CMP?
            What is fastest and why???

            • 3. Re: CMP vs. BMP
              aloubyansky

              JBoss CMP is all you need.

              • 4. Re: CMP vs. BMP
                larry054

                Sorry Loubyansky, I don't quite agree. CMP is fast, but there are times when I can't make CMP do what I want. Some applications require the flexibility of BMP.

                Larry

                • 5. Re: CMP vs. BMP

                  But you did not ask which was most flexible, you asked which was fastest, and for a number of reasons, CMP is nearly always faster than BMP.

                  JBossCMP is also very flexible. I was able to make it support a series of unusual constructs.

                  • 6. Re: CMP vs. BMP
                    larry054

                    You're quite right Nickman. I didn't mean to change the subject. I was responding to "CMP is all you need to know" post.

                    • 7. Re: CMP vs. BMP
                      ahardy66

                      The optimisation is basically just the caching that the container does.

                      So if you have an application which uses lots of the same data over and over, yes it will be faster.

                      But if you have an app that uses all sorts of different data without much re-use, then there will be no difference. Anyone disagree? The datasource is the same - database & JDBC - so actually the CMP is probably going to be slower, since CMP often makes more calls than you personally would program for any given situation when doing a BMP.

                      Adam

                      • 8. Re: CMP vs. BMP
                        pearl81

                        So what do you guys think of CMR? Is that advisable or should we keep relationships out of the container?