Hi Myles,
> From: A mailing list for Enterprise JavaBeans development
> [mailto:[EMAIL PROTECTED]]On Behalf Of News Groups
> A problem with CMP is that it is an all or nothing approach regarding
> data access from the database. Ie. If you want to process a series of
> single fields from a selection of CMP entity beans you have no choice
> but to query for them and let the container load in all their data -
> even though you are interested in only the one field per entity bean.
>
> The spec should introduce data containers (I suppose 'value objects')
> that are views of a CMP entity bean. When defining a finder method,
> rather than it always returning a single CMP bean or a collection of CMP
> beans you can elect to return one of your data containers instead. The
> data container will simply be a subset of the fields of your CMP entity
> bean.
I agree that this might be sometimes useful, but you don't need to amend the
specification to do that. What stops you from putting the intelligence
regarding these "view fields" into a Stateless Session Bean that would issue
the queries and pack the results into a value object before returning them
to you?
> Examples of possible XML definitions for data containers might be like
> this (all the fields must have been previously defined for the CMP EJB
> otherwise the compiler will reject it):
>
> <view-object>
> <view-name>accountBalance</view-name>
> <view-field>
> <field-name>accountId</field-name>
> </view-field>
> <view-field>
> <field-name>balance</field-name>
> </view-field>
> </view-object>
I suppose this definition is incomplete since a view-object would probably
gather CMP fields from various EJB's. Maybe you meant something like:
<view-object>
<view-name>View1</view-name>
<view-field>
<ejb-name>Account</ejb-name>
<cmp-field>accountId</cmp-field>
</view-field>
<view-field>
<ejb-name>Employee</ejb-name>
<cmp-field>lastName</cmp-field>
</view-field> </view-field>
</view-object>
If you absolutely want to define your model with XML, you could imagine a
tool that would generate a Stateless Session Bean based on this model from
this XML description.
> Obviously the view data returned would be read-only in nature and the
> actual CMP entity bean would have to be looked up in order to operate on
> it. But from the point of view of just arbitrarily looking up subsets
> of data for a CMP entity bean they would be ideal.
Making the view read-only limits the interest of this technique. You could
easily generate a method on your StatelessSession Bean that takes the view
object as a parameter and updates the underlying entity beans.
--
Cedric
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".