2 Replies Latest reply on Dec 9, 2002 7:15 PM by jboynes

    CMR and select methods

    jmntn2000

      Hi,

      I have a bidirectional one to many CMR with two entities say A and B (A 1 --- * B) and can navigate the relationship just fine. Howerver I now want to just return a subset of B entities that relate to a given A.

      My question is, if I create a select method in A that returns a collection of B's (ie getBswithconditionX()), can I use the resultant collection in the same was as I would the default collection that is returned from a.getBs()? In other words is the collection managed by the container? If so, how do I tell JBoss that the result of the select is the child entities B?

      James

        • 1. Re: CMR and select methods
          dsundstrom

          No the collection returned from a CMR field is live (i.e., you can add and remove objects from the relationship using the collection directly). The collection returned from a query is (or should be) unmodifiable.

          • 2. Re: CMR and select methods
            jboynes

            A select method is more like a finder than a cmr-field get().

            The container creates the Collection but does not "manage" it as it does not correspond to a relationship; this is just like the result returned by a finder.

            The type returned is determined by the field or OBJECT cast in the select_clause of the EJB-QL query.