3 Replies Latest reply on Sep 30, 2002 5:23 PM by juha

    Why no data query abstraction in EJB?

    davout

      As a EJB newcomer I was amazed to find that there is no EJB container based mechanism that addresses data queries.

      I can see the real advantages of using CMP to handle transactions and persistence. This along with CMP's abstraction of the underlying data sources does provide some significant advantages.

      However, when it comes to querying data to return lists of entities - a pretty standard requirement for any application - it seems that you have to fall back to using JDBC. There doesn't even seem to be anyway
      of storing the context of these queries in some underlying configuration structure.

      I've been examining this thru JBoss R3, am I missing something here or what?

      (polite answers only please!)

        • 1. Re: Why no data query abstraction in EJB?

          so how come finder methods aren't sufficient for returning lists of entities?

          • 2. Re: Why no data query abstraction in EJB?
            davout

            Take a situation where I want to run a query against a customer database. Something like....

            select customerID, customerName from customers

            It does'nt make any sense to retrieve the entire Customer object. Also what happens if the customer object is a composite of things like...

            Customer
            |--- Customer Address Info
            |--- Customer Order Info
            |--- Customer Contacts

            A finder would bring back huge amounts of data that simply isn't relevant.

            I was sort of expecting EJB to include some of logical entity to data source mapping structure for all aspexcts of the data model - not just entity CRUD.

            The few books I've read suggest using a DAO pattern for masking JDBC calls. Again this seems detached from the container based persistence.


            • 3. Re: Why no data query abstraction in EJB?

              See CMP2 spec and Dain's CMP2 docu, should answer your questions, e.g. how to configure the CMP engine to fetch just the information you require.

              Also try the CMP forum, Dain will most likely explain how the persistence works in detail.

              In short, no you don't have to fetch huge amounts of data as you describe.