The problem is that the none of the data retrieved by the SP is cached at the JVM level. All calls result in a round trip to the database even if the same search is executed twice in a row and brings back the same data each time. This kills performance. I have read some of the posts describing how stored procedures can be called from EJBs i.e stateful beans but it is not clear if the EJB will cache the results of a stored procedure if the search parameters are the same.
why do you expect any caching when using stored procedures? Usually stored procedures just give you the possibility to save some complex queries (maybe consisting of more than one client command) on the server side. This often speeds up executing the stored procedure again but it doesn't avoid a real round-trip to the database server. And I think that there's no big difference with session beans executing a stored procedure.
I guess to solve the performance problems you'll have to use some additional caching framework or create your own caching mechanism (if it's even possible or reasonable to do caching!).
It sounds like you are confused about the WebSphere prepared statement cache. That just caches the "compiled" statement itself, not the results of executing the statement. If you can't move to JPA right now, look into caches like EHCache or Coherence.
Independent Consultant — Author, EJB 3 in Action — Expert Group Member, Java EE 6 and EJB 3.1
Joined: Mar 05, 2002
I am not referring to the WAS prepared statement cache.
Data returned by EJBs is cached in the JVM memory. Works like the Hibernate Level 1/Level 2 cache. So the data returned by a stored procedure called by an EJB would be cached in memory. That's the performance gain.
If you want to cache individual rows, that's what Entity EJBs are for. In essence, an entity bean is a JavaBean that's effectively managed as though it was a member of a hash whose keys are the primary keys of the EJBs.
Entity EJBs can back the results of a stored procedure execution, although just for the record, I don't recommend stored procedures unless there is a compelling reason to use them. I've experienced some of their liabilities firsthand recently.
Customer surveys are for companies who didn't pay proper attention to begin with.
Joined: Mar 05, 2002
Got a reply from IBM and there are no extensions in WAS that explicitly Stored Procedures so we are going to experiment with CMP EJBs. We may check out Hibernate as well.