Entity beans not being cached in same TX?
aparaapara Oct 4, 2003 6:53 AMAt one point in my code I noticed that I was executing findByPrimaryKey on an EJB a little too much. This resulted in a SELECT ... FROM .... WHERE ID=? type of query to be generated often. To fix the problem, I thought that executing a finder that would bring all those objects into memory (at least during the same TX) would "pre-cache" the objects and avoid a SELECT .. FROM .. WHERE ID = ? from being executed too many times. So I did that, [findByProfile] in the next trace, but I still see a lot of [findByPrimaryKey] being executed.
I verified that TX exists it's state is 0 (active) and it's the same TX when a do my "pre-cache" fetch and later when I am doing findByPrimaryKey calls.
Why is the "pre-cache" NOT caching my objects for the duration of the TX? (JBOSS 3.2.2RC3)
06:15:33,339 INFO [STDOUT] org.jboss.tm.usertx.client.ServerVMClientUserTransaction@c57f88, 0
06:15:33,347 INFO [STDOUT] org.jboss.tm.usertx.client.ServerVMClientUserTransaction@c57f88, 0
06:15:33,351 DEBUG [findByProfile] Executing SQL: SELECT t0_pv.id, t0_pv.componentid FROM picturevalue t0_pv, profilecomponent t3_pc, profile t1_pc_profile, component t2_pc_component WHERE ((t1_pc_profile.id=?) AND t2_pc_component.componentValueId = t0_pv.id) AND (t3_pc.profileid=t1_pc_profile.id AND t3_pc.componentid=t2_pc_component.id)
06:15:33,365 DEBUG [findByPrimaryKey] Executing SQL: SELECT id, componentid FROM picturevalue WHERE id=?
06:15:33,389 DEBUG [findByPrimaryKey] Executing SQL: SELECT id, componentid FROM picturevalue WHERE id=?
06:15:33,400 DEBUG [findByPrimaryKey] Executing SQL: SELECT id, componentid FROM picturevalue WHERE id=?
06:15:33,428 DEBUG [findByPrimaryKey] Executing SQL: SELECT id, componentid FROM picturevalue WHERE id=?
06:15:33,439 DEBUG [findByPrimaryKey] Executing SQL: SELECT id, componentid FROM picturevalue WHERE id=?
06:15:33,451 DEBUG [findByPrimaryKey] Executing SQL: SELECT id, componentid FROM picturevalue WHERE id=?
06:15:33,470 DEBUG [findByPrimaryKey] Executing SQL: SELECT id, componentid FROM picturevalue WHERE id=?
Thanks.
-AP_