can CMP return many records at once? 2003-07-02 - By Milen Dyankov
Back 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) and include in the body of the message "signoff J2EE-INTEREST". For general help, send email to listserv@(protected) and include in the body of the message "help".
|
|