We have two entity beans that are accessed via their findByPrimaryKey methods. Both beans have the same container configuration and are executed 10 times within a single transaction.
By turning on CMP tracing we can see that for the first bean one line of sql is executed against the database (ie the container is caching - as expected) for the second bean 10 lines are executed ?, what could cause this ? ie how does the container decide when not to cache an entity bean that is looked up by pk ?
This was due to the fact that the AS only caches data when its accessed, not when findByPrimaryKey is called. One of the tests printed out the returned entity (and hence it was cached) and the other didnt (and hence it wasnt cached).