4 Replies Latest reply on Sep 17, 2002 2:34 PM by Dain Sundstrom

    ejbSelect methods vs CMR

    Son To Newbie

      Is there an advantage of using CMR over using ejbSelect for building relationships?

        • 1. Re: ejbSelect methods vs CMR
          richlin Newbie

          i dont know if no CMR can we use EJB-QL(or JBoss-QL)
          like :
          "SELECT detail WHERE detail.master.company.code=?"
          nest Object call...


          Rich

          • 2. Re: ejbSelect methods vs CMR
            Dain Sundstrom Master

            > Is there an advantage of using CMR over using
            > ejbSelect for building relationships?

            What do you mean? I strongly suggest you use ejbSelects instead of walking the relationship graph as a walk requires a loading all the intermediate objects and an ejbSelect basically jumps there. Is that what you mean?

            • 3. Re: ejbSelect methods vs CMR
              Son To Newbie

              > What do you mean? I strongly suggest you use
              > ejbSelects instead of walking the relationship graph
              > as a walk requires a loading all the intermediate
              > objects and an ejbSelect basically jumps there. Is
              > that what you mean?

              For example, suppose customer can have one address.
              We can use CMR or Customer can have an

              public AddressLocal getAddress()
              {
              return ejbSelectAddress(getCustomerId());
              }

              public AddressLocal ejbSelectAddress(long customerId)

              the EJB-QL for the ejbSelectAddress would be like
              select Object(a) from Address a where a.customerId=?1

              so my question is is it better to build relationships this way using ejbSelect methods or using CMR? The ejbSelect method would be the most flexible. If there are no FK relationship between tables then CMR would not work.

              • 4. Re: ejbSelect methods vs CMR
                Dain Sundstrom Master

                If you are only going one (or maybe two) level(s) deep use a CMR otherwise use an ejbSelect.