If I don't use entity bean , how do I achieve the caching?
Also, given a primary key, is there any way to check whether an entity bean
exists in container. Exists means the enity bean is already loaded but may
be its passivated.
Ben
-----Original Message-----
From: Chaganthi, Madhusudan R. [mailto:[EMAIL PROTECTED]]
Sent: Monday, September 18, 2000 11:50 AM
To: [EMAIL PROTECTED]
Subject: Re: Entity bean design question
You are better off using straight jdbc calls from stateless session beans.
Your finders can be more efficient for this read only situation if you DONT
use entity beans.
Use "data objects" to send data to the client.
-----Original Message-----
From: Franklin, Benjamine [mailto:[EMAIL PROTECTED]]
Sent: Monday, September 18, 2000 11:23 AM
To: [EMAIL PROTECTED]
Subject: Entity bean design question
Hi ,
I may be totally insane. Please correct me wherever I go wrong.
This is my situation. In our web application, users enter tickers like IBM,
MSFT etc and ask for all the documents about those companies.
My database table looks like
doc_id ticker document_name
1 IBM jhgfg
2 IBM kjfhgdkf
1 MSFT jhgfg
combination of doc_id and ticker is the primary key
I'm planning to use Entity beans. The main thing and the only thing I expect
from the Container is caching, so that if one user requests documents for
IBM and once the IBM entity bean is created, for the next user it should not
go back to database, it should get from cache . I don't do any transaction.
My entity beans are readonly, I'm not using "create" in entity bean (since
this is done directly to database by some other process), the primary use of
my bean is for listing (in html pages).
Let say I define
DocumentEntityBean
{
int doc_id;
String ticker;
String document_name;
findByTicker(Vector tickers)
{
sql = "select * from doc where ticker in (..)"
//creating primary key from the data returned from database
}
}
and Primarkey is DocKey(int doc_id, String Ticker)
If I use CMP, I think the default behaviour is ,
when I call findByTicker(tickerVector), for finding the primary key a query
is executed , and then for each returned primary key, lets say there is 50
primary keys returned, then another 50 queries are fired to the database, if
the entity beans for those primary keys are not available in cache.
The above is my understanding, but I'm a beginner, may be I'm wrong, if
wrong please correct me.
If the above is correct , then I want to optimize this
My idea is
Primarkey is DocKey(String Ticker)
the reason why I choose this is user needs document only based on tickers,
rather than doc_id, ticker
Also instead of creating an entity bean for each document, I have only one
entity bean for a ticker which has a vector of documents
DocumentEntityBean
{
String ticker;
Vector Documents; //contains vector of Document object
findByPrimaryKey(pk)
{
sql = "select * from doc where ticker = pk.ticker"
//execute sql
//set ticket= pk.ticker
//from result set create the Vector of Documents
while(result.next())
{
Documents.addElement(new
Document(result.getString(1),result.getString(2) ));
}
}
findByTicker(Vector tickers)
{
//without doing a query ,
//create primary keys from from vector of tickers
//in this way one query is avoided
// like
Vector result = new Vector;
for(int i=0; i< tickers.size(); i++)
{
result.addElement(new Dockey(tickers.elementAt(i)));
}
return result;
}
}
the above method reduces the number of queries to number of tickers. I feel
this is much better since it reduces number of queries from 50 to 3or4
I want to still optimize this, I want to make only one query even if there
is multiple tickers
so I want to change the findByTicker() as below
findByTicker(Vector tickers)
{
//First check whether the entity beans for this tickers are
available in cache
//I don't know whether there is EJB standard method to do this
//then separate out all the tickers which are not in cache
// do sql = "select * from doc where ticker in ( not in cache
tickers )"
//get data from the result and load data into individual ejb beans
//so now the beans which are not available in cache are now
available
//return the primary keys created from vector of tickers , doing
like this will make the container not going back to database
}
In the above method , I feel whatever the case only one query is fired. and
if the bean is in cache no query is fired.
Am I going insane anywhere, or missing something, can you guys tell me what
will be the problems in this approach?
Thanks
Ben
This message is for the named person's use only. It may contain
confidential, proprietary or legally privileged information. No
confidentiality or privilege is waived or lost by any mistransmission.
If you receive this message in error, please immediately delete it and all
copies of it from your system, destroy any hard copies of it and notify the
sender. You must not, directly or indirectly, use, disclose, distribute,
print, or copy any part of this message if you are not the intended
recipient. CREDIT SUISSE GROUP and each of its subsidiaries each reserve
the right to monitor all e-mail communications through its networks. Any
views expressed in this message are those of the individual sender, except
where the message states otherwise and the sender is authorised to state
them to be the views of any such entity.
Unless otherwise stated, any pricing information given in this message is
indicative only, is subject to change and does not constitute an offer to
deal at any price quoted.
Any reference to the terms of executed transactions should be treated as
preliminary only and subject to our formal written confirmation.
===========================================================================
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".
===========================================================================
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".
[INFO] -- Content Manager:
This message is for the named person's use only. It may contain
confidential, proprietary or legally privileged information. No
confidentiality or privilege is waived or lost by any mistransmission.
If you receive this message in error, please immediately delete it and all
copies of it from your system, destroy any hard copies of it and notify the
sender. You must not, directly or indirectly, use, disclose, distribute,
print, or copy any part of this message if you are not the intended
recipient. CREDIT SUISSE GROUP and each of its subsidiaries each reserve
the right to monitor all e-mail communications through its networks. Any
views expressed in this message are those of the individual sender, except
where the message states otherwise and the sender is authorised to state
them to be the views of any such entity.
Unless otherwise stated, any pricing information given in this message is
indicative only, is subject to change and does not constitute an offer to
deal at any price quoted.
Any reference to the terms of executed transactions should be treated as
preliminary only and subject to our formal written confirmation.
===========================================================================
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".