Java Mailing List Archive

http://www.junlu.com/

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

Re: can CMP return many records at once?

Sameer Sadanand Menon

2003-07-02


Milen,
findbyprimaryKey() does not give you Primary key..
It gives you a remote refernce to a bean haveing that primary key.
The bean is an abstraction of te under lying row in the table.
you can invoke the getter and setter methods defined in the CMP Bean to
retrieve or put data.
I hope I have explained what you required.

Regards,
Sameer Menon

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