Why findByPrimaryKey issues ?SELECT pkey from TABLE where pkey=??
We use jboss-4.0.0 in 2 node cluster configuration with ?Standard CMP 2.x EntityBean with cache invalidation?, commit option A.
Whenever our application invokes ?findByPrimaryKey? on CMPs, JBOSS issues ?SELECT pkey from TABLE where pkey=??. This ?SELECT? makes sense when entity is loaded for first time, I am not sure why ?findByPrimaryKey? issues ?SELECT pkey from TABLE where pkey=?? on subsequent request for the same entity(for same primary key) instead of getting it from cache.
We are trying to optimize DB access by cutting down on the number of ?SELECT? queries issued.
Is it possible to avoid the ?SELECT? issued by findByPrimaryKey on subsequent invocation on already loaded entity? If yes, please provide me some pointers on how to do this.
Are you sure you are actually retrieving something from the database. ie is there some data that matches your primary key? Also, are you accessing the retrieved data ? the AS only puts data into the cache when it is accessed ( not when you do the findByPrimaryKey ).