Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » J2EE Interest »

Re: can CMP return many records at once?

Rangarajan , Suresh ( Cognizant )

2003-07-02

Replies:

Hi,
You've missed something in the spec. :D
Read more about the ejbSelect<> methods.
but select methods are not visible to the clients...



-----Original Message-----
From: Milen Dyankov [mailto:mdyankov@(protected)]
Sent: Wednesday, July 02, 2003 3:53 PM
To: J2EE-INTEREST@(protected)
Subject: can CMP return many records at once?


Hi,
I'm relatively new to J2EE.
I have read the specs and docs and there is something I don't really
understand.

As far as I understood all CMP's finder methods with return type
Collection, simply return collection of primary keys. Then one need to
create a new instance of this CMP to obtain the specific data.

Lets say I have DB table called "UserHistory":

userid | datetime       | action
-------+-------------------+----------------
1    | 2003-03-03 13:25 | something
2    | 2003-03-03 14:27 | something else
1    | 2003-03-03 18:42 | something new

with PRIMARY KEY (userid, datetime)

Now if I'm writing J2EE application it would be helpful to have
"UserHistoryCMP" as long as I'm using it for "what USER have done on
DATE at TIME". But what if I would like to display a chart containing
user's history.

Doing "findAllByUserId(String user)" and then instantiating
UserHistoryCMP for every record in the table, does not seems to be the
right way of doing this. Or, is it?

Or may be I should go for BMP in this case and simply write
"getFullHistoryForUser (String user)" method in addition to default
getters and setters? If so, does this mean that CMPs are only usable for
getting single record and one should go for BMP any time when a large
amount of records (returned at once) is required?


Regards,
    Milen

===========================================================================
To unsubscribe, send email to listserv@(protected)
of the message "signoff J2EE-INTEREST". For general help, send email to
listserv@(protected)".

This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information.
If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.
Any unauthorised review, use, disclosure, dissemination, forwarding, printing or copying of this email or any action taken in reliance on this e-mail is strictly
prohibited and may be unlawful.

          Visit us at http://www.cognizant.com
©2008 junlu.com - Jax Systems, LLC, U.S.A.