RE:
"On the other hand, if
you want to CMP, your simple example will take at least 3 sql calls."

Or: one view and one sql call.

Remember that an entity EJB can be viewed viewed as a *record* in a table (a
collection of length 1) or as a collection of records. So, think of your
view as a read only table and your associated CMP as a read only record.
Then imagine that given the right criteria (the right where clause) your
custom find method can return multiple records (a collection of length n).

The natural next question is how to deal with the n entities in the returned
collection. Well, that depends on the type of collection returned right? And
I'm guessing that it's an array of strings...but I don't know yet.

The where clauses go in the deployment descriptor, the custom find methods
go in the home inteface. Here's a deployment descriptor example from
Weblogic 4.5:

<SNIP>
    (finderDescriptors
      "findAccount(double balanceEqual)" "(= balance $balanceEqual)"
       ; This is converted to a "findAccount" method in
       ; the generated persistent storage class, which returns
       ; returns a bean of this class that satisfies this expression.

      "findBigAccounts(double balanceGreaterThan)" "(> balance
$balanceGreaterThan)"
       ; This is converted to a "findBigAccounts" method
       ; in the generated persistent storage class, which
       ; returns an enumeration of beans of this class
       ; that satisfy this expression.

      "findOrderedBigAccounts(double balanceGreaterThan)" "(orderBy 'id' (>
balance $balanceGreaterThan))"
       ; This is converted to a "findOrderedBigAccounts" method
       ; in the generated persistent storage class, which
       ; returns an enumeration of beans of this class
       ; that satisfy this expression, ordered by the column 'id'.

      "findDescOrderedBigAccounts(double balanceGreaterThan)" "(orderBy 'id
desc' (> balance $balanceGreaterThan))"
       ; This is converted to a "findDescOrderedBigAccounts" method
       ; in the generated persistent storage class, which
       ; returns an enumeration of beans of this class
       ; that satisfy this expression, in descending order by the column
'id'.

      "findNullAccounts()" "(isNull type)"
       ; This is converted to a "findNullAccounts" method
       ; in the generated persistent storage class, which
       ; returns an enumeration of beans of this class
       ; that have a name that is null.

    ); end finderDescriptors
</SNIP>

I'll try to post an example of using the returned Collection (or
enumeration...) tomorrow for those who care.

Anyone got a sample already? One that is deployed in XML/Orion style?

Brian Cunningham


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Dale Bronk
Sent: Tuesday, April 04, 2000 12:05 PM
To: Orion-Interest
Subject: Re: Is CMP is useless?


You need to weigh your points against portability and efficiency.  If you
use ANSI SQL, portability should not be a problem.  On the other hand, if
you want to CMP, your simple example will take at least 3 sql calls.


----- Original Message -----
From: Alex Paransky <[EMAIL PROTECTED]>
To: Orion-Interest <[EMAIL PROTECTED]>
Sent: Tuesday, April 04, 2000 12:10 PM
Subject: RE: Is CMP is useless?


> But using stateless session beans to execute SQL means you have to embed
the
> SQL commands in to your code.  This breaks the model that CMP is trying to
> achieve.  If someone is to move your bean in to a different environment
they
> might not be able to alter the code to make changes to the SQL.
>
> Suppose that someone is trying to adapt your Employee bean to be used in
> their enterprise system.  They follow the CMP procedure with their EJB
> server to map Employee attributes to columns in their own table.  However,
> they are not able to do the same with the session bean which has SQL in
it.
>
> I suppose that the bean's environment can be used to hold the specific
SQL,
> with parameter replacements, however, this seems out of place with the CMP
> model.
>
> -AP_
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of Galina
> Sokolova
> Sent: Tuesday, April 04, 2000 8:40 AM
> To: Orion-Interest
> Subject: RE: Is CMP is useless?
>
>
>
> From my experience stateless session bean is a better choice for complex
> lookups, especially
> if they return enumeration of objects.
>
>
>
>
>
>
> [EMAIL PROTECTED] (Josh Sanderson)@itglink.com> on 04/04/2000
10:49:17
> AM
>
> To:   Orion-Interest <[EMAIL PROTECTED]>
> cc:
>
> Subject:  RE: Is CMP is useless?
>
>
> I don't know....I never thought Employees and sex mixed that well
> anyways....
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of Alex Paransky
> Sent: Monday, April 03, 2000 9:04 PM
> To: Orion-Interest
> Subject: Is CMP is useless?
>
>
> Is it my imagination, but the minute any kind of complex finding is
> required
> on an entity bean, CMP becomes useless.  For example, I have entities
> called
> EMPLOYEE, PERSON, and SEX (M/F/Other you know).
>
> EMPLOYEE is a PERSON with SEX.
>
> I have a function in EmployeeHome, findFemaleEmployees().  How do I
> implement this with CMP?  The query has to do something like:
>
> SELECT EMPLOYEE_ID FROM EMPLOYEE, PERSON, SEX WHERE SEX.TYPE="F" AND
> EMPLOYEE.ID=PERSON.ID AND PERSON.SEX_ID = SEX.ID
>
> Please note that SEX.ID is not the same as SEX.TYPE.
>
> Can this be done with CMP or do I need to use BMP?  If the answer is use
> BMP
> (and this is such a TRIVIAL) example, that it seems CMP is pretty much
> useless.
>
> -AP_
>
>
>
>
>
>
>
>
>
>




Reply via email to