Caching of Entity beans and their related Entity beans improves performance by reducing the number of JOIN queries that have to be executed. In our earlier example, we had three types of relationships:
The <relationship-caching> tag of weblogic-cmp-rdbms.xml is used to specify caching of these relationships. Listing 22.17 is an excerpt from a weblogic-cmp-rdbms.xml file showing the caching of relationships.
<relationship-caching> <caching-name>cacheMoreBeans</caching-name> <caching-element> <cmr-field>assistantName</cmr-field> <group-name>assistants</group-name> </caching-element> <caching-element <cmr-field>patientName</cmr-field> <group-name>patients</group-name> </caching-element> <caching-element> <cmr-field>hospitalName</cmr-field> <group-name>hospitals</group-name> </caching-element> </relationship-caching> |
It's important to note that relationship caching is not supported for many-to-many relationships. This is obviously because it can lead to deadlocks.