5 Replies Latest reply on May 3, 2003 7:09 PM by Darryl A. J. Staflund

    CMP with multiple tables.

    vkaladhar Newbie

      Hi can u send an example on CMP using multiple tables.
      How the jaws.xml, ejb-jar.xml will look for the above.
      Pls if u respond quickly it will be a great help for me.

      bye
      -kaladhar

        • 1. Re: CMP with multiple tables.
          Tobias Frech Apprentice

          As far as I know with CMP from EJB 1.1 this is not possible. The idea of CMP is that you keep it simple and let the server do the persistence stuff. That also means one CMP bean = one table.
          I am not aware how the situation is with CMP 2.0. I think it is the same. There will show up a brand new CMP 2.0 Howto in the manual in the next hours. Keep checking the manual ...

          • 2. Re: CMP with multiple tables.
            Tobias Frech Apprentice

            I forgot:
            If you HAVE to use separte tables or you have the tables already and need to make EJBs on top of them your way to go is BMP. That's what BMP is there for.

            Cheers,
            Tobias

            • 3. Re: CMP with multiple tables.
              David Jencks Master

              One thing you can do with multiple tables and cmp is have a finder that uses criteria from several tables, as long as the data all comes from one table. IIRC you use a where clause looking like this

              , table2 t2 where c1 = t2.c1 and t2.c2 = {0}

              resulting in sql like
              select * from table1, table2 t2 where c1 = t2.c1 and t2.c2 = {0}

              There might be an alias for table1 also, I don't remember.

              You may also be able to do something with updatable views depending on your database.

              • 4. Re: CMP with multiple tables.
                Alexander Rabinowitz Newbie

                Is it now possible to have CMP 2.x with multiple tables for an entity bean "Standard CMP 2.x EntityBean" in JBoss 3.0.6?

                Actually, I am particular interested in having CMP with just two tables.
                It looks like I cannot make it work and I have to do BMP with one table and CMP with another one. Am I correct?
                If I am wrong, is there an example how to do it?

                • 5. Re: CMP with multiple tables.
                  Darryl A. J. Staflund Newbie

                  Hi there,

                  If you are asking whether it is possible to create a CMP entity bean that spans several database tables, an older thread in this discussion group stated that this was a feature planned for JBoss 4.0 but will only be developed on a consulting basis for individuals who want it before then.

                  You do have an option though:

                  1. Create database views for each entity bean that spans multiple tables and then complement it with insert/update/delete triggers that intercept SQL queries run against the view and then mapps them to the appropriate table fields. You can then define your CMP entity bean to run off the view instead of the various tables. This should work in theory if your database supports it but I don't know when the performance it would be.

                  Hope this helps.

                  Darryl Staflund