Java Mailing List Archive

http://www.junlu.com/

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

Re: can CMP return many records at once?

Prasanna Kumar AG.

2003-07-02


The finder methods in CMP or BMP whose return type is collection, will
return you collection of objects implementing Entity Bean's Remote/Local
interfaces. Not Collection of Primary Keys. In case of BMP, though you
return a collection of primary keys in the implementation, the container in
turn would create the Entity Bean objects and return them to you.

HTH,
Prasanna Kumar

-----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)".

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



©2008 junlu.com - Jax Systems, LLC, U.S.A.