Thanks Gavin, using the lifecycle interface does cause my transient problem to go away.
I have a follow-up question related to caching of objects. I have a class OrganizationRole that has 3 one-to-many collections that are NOT lazy loaded. When I get a cache hit for an OrganizationRole object, hibernate still seems to be executing queries against the database to retrieve the collections. I have these collections configured to use caching as well. Shouldn't it be getting the collections from the cache as well?
---------------------------------------------------------------------
Here is my mapping for OrganizationRole:
Quote:
<class name="org.ets.k12.generic.domain.OrganizationRole" table="ORG_RLE">
<jcs-cache usage="nonstrict-read-write"/>
<composite-id unsaved-value="any">
<key-many-to-one name="organization" column name="ORG_ID_NO" class="org.ets.k12.generic.domain.Organization"/>
<key-many-to-one name="orgRoleType" column="ORG_RLE_TYP_CDE" class="org.ets.k12.generic.domain.OrganizationRoleType"/>
</composite-id>
<many-to-one name="aiType" column="AI_TYP_CDE" class="org.ets.k12.generic.domain.AIType"/>
<many-to-one name="orgExtType" column="ORG_EXTRNL_TYP_CDE" class="org.ets.k12.generic.domain.OrganizationExternalType"/>
<property name="lastUpdated" column="UPDT_DTE_TM" type="java.sql.Timestamp"/>
<property name="lastUpdatedBy" column="UPDT_USR_LGN_CDE" type="java.lang.String"/>
<set name="orgRoleTestAdmins" lazy="false" inverse="true" cascade="all">
<jcs-cache usage="nonstrict-read-write"/>
<key>
<column name="ORG_ID_NO"/>
<column name="ORG_RLE_TYP_CDE"/>
</key>
<one-to-many class="org.ets.k12.generic.domain.OrganizationRoleTestAdministration"/>
</set>
<set name="orgRoleAddresses" lazy="false" inverse="true" cascade="all">
<jcs-cache usage="nonstrict-read-write"/>
<key>
<column name="ORG_ID_NO"/>
<column name="ORG_RLE_TYP_CDE"/>
</key>
<one-to-many class="org.ets.k12.generic.domain.OrganizationRoleAddress"/>
</set>
<set name="aiGradeLevel" lazy="false" inverse="true" cascade="all">
<jcs-cache usage="nonstrict-read-write"/>
<key>
<column name="ORG_ID_NO"/>
<column name="ORG_RLE_TYP_CDE"/>
</key>
<one-to-many class="org.ets.k12.generic.domain.AIGradeLevel"/>
</set>
</class>
---------------------------------------------------------------------
Here's the output I see when I have debugging turned on for the hibernate.cache package.
Quote:
[9/5/03 11:32:59:660 EDT] 6608851f SystemOut U 2003-09-05 11:32:59,539 DEBUG [Thread-12] cache.NonstrictReadWriteCache:22 - Cache hit: 20000
[9/5/03 11:29:41:244 EDT] 6608851f SystemOut U 2003-09-05 11:29:41,184 DEBUG [Thread-12] cache.ReadOnlyCache:22 - Cache hit: CT
[9/5/03 11:29:41:304 EDT] 6608851f SystemOut U 2003-09-05 11:29:41,244 DEBUG [Thread-12] cache.NonstrictReadWriteCache:22 - Cache hit: org.ets.k12.generic.domain.OrganizationRole@89ca917b
[9/5/03 11:29:41:304 EDT] 6608851f SystemOut U Hibernate: select org_rle_0_.TST_ADM_MO_NO as TST_ADM_1___, org_rle_0_.TST_ADM_YR_NO as TST_ADM_2___, org_rle_0_.ORG_ID_NO as ORG_ID_NO__, org_rle_0_.ORG_RLE_TYP_CDE as ORG_RLE_4___, organiza1_.ORG_EXTRNL_TYP_CDE as ORG_EXTRNL_TYP_CDE0_, organiza1_.ORG_EXTRNL_TYP_DESC as ORG_EXTR2_0_, org_rle_0_.TST_ADM_MO_NO as TST_ADM_MO_NO1_, org_rle_0_.TST_ADM_YR_NO as TST_ADM_YR_NO1_, org_rle_0_.ORG_ID_NO as ORG_ID_NO1_, org_rle_0_.ORG_RLE_TYP_CDE as ORG_RLE_TYP_CDE1_, org_rle_0_.ORG_EXTRNL_TYP_CDE as ORG_EXTR5_1_, org_rle_0_.INDPNT_CHTR_SCHL_FLG as INDPNT_C6_1_, org_rle_0_.ORG_RLE_TST_ADM_AFDVT_FLG as ORG_RLE_7_1_, org_rle_0_.ORG_RLE_TST_ADM_LT_TST_FLG as ORG_RLE_8_1_, org_rle_0_.ORG_RLE_TST_ADM_PO_NO as ORG_RLE_9_1_, org_rle_0_.UPDT_DTE_TM as UPDT_DT10_1_, org_rle_0_.UPDT_USR_LGN_CDE as UPDT_US11_1_ from ORG_RLE_TST_ADM org_rle_0_, ORG_EXTRNL_TYP organiza1_ where org_rle_0_.ORG_ID_NO=? and org_rle_0_.ORG_RLE_TYP_CDE=? and org_rle_0_.ORG_EXTRNL_TYP_CDE=organiza1_.ORG_EXTRNL_TYP_CDE(+)
[9/5/03 11:29:41:384 EDT] 6608851f SystemOut U 2003-09-05 11:29:41,324 DEBUG [Thread-12] cache.NonstrictReadWriteCache:46 - Caching invalidated: org.ets.k12.generic.domain.OrganizationRole@89ca917b
[9/5/03 11:29:41:384 EDT] 6608851f SystemOut U Hibernate: select org_rle_0_.ORG_ID_NO as ORG_ID_NO__, org_rle_0_.ORG_RLE_TYP_CDE as ORG_RLE_2___, org_rle_0_.ADR_ID_NO as ADR_ID_NO__, addressp1_.ADR_TYP_ID_NO as ADR_TYP_ID_NO0_, addressp1_.ADR_PRPS_TYP_ID_NO as ADR_PRPS_TYP_ID_NO0_, addressp1_.ADR_PRPS_TYP_DESC as ADR_PRPS3_0_, org_rle_0_.ORG_ID_NO as ORG_ID_NO1_, org_rle_0_.ORG_RLE_TYP_CDE as ORG_RLE_TYP_CDE1_, org_rle_0_.ADR_ID_NO as ADR_ID_NO1_, org_rle_0_.ADR_TYP_ID_NO as ADR_TYP_4_1_, org_rle_0_.ADR_PRPS_TYP_ID_NO as ADR_PRPS5_1_, org_rle_0_.UPDT_DTE_TM as UPDT_DTE6_1_, org_rle_0_.UPDT_USR_LGN_CDE as UPDT_USR7_1_, org_rle_0_.ORG_RLE_ADR_EFF_DTE as ORG_RLE_8_1_, org_rle_0_.ORG_RLE_ADR_EXPRTN_DTE as ORG_RLE_9_1_ from ORG_RLE_ADR org_rle_0_, ADR_PRPS_TYP addressp1_ where org_rle_0_.ORG_ID_NO=? and org_rle_0_.ORG_RLE_TYP_CDE=? and org_rle_0_.ADR_TYP_ID_NO=addressp1_.ADR_TYP_ID_NO(+) and org_rle_0_.ADR_PRPS_TYP_ID_NO=addressp1_.ADR_PRPS_TYP_ID_NO(+)
[9/5/03 11:29:41:464 EDT] 6608851f SystemOut U 2003-09-05 11:29:41,404 DEBUG [Thread-12] cache.NonstrictReadWriteCache:46 - Caching invalidated: org.ets.k12.generic.domain.OrganizationRole@89ca917b
[9/5/03 11:29:41:464 EDT] 6608851f SystemOut U Hibernate: select ai_grd_l0_.ORG_ID_NO as ORG_ID_NO__, ai_grd_l0_.ORG_RLE_TYP_CDE as ORG_RLE_2___, ai_grd_l0_.GRD_LVL_TYP_CDE as GRD_LVL_3___, ai_grd_l0_.ORG_ID_NO as ORG_ID_NO, ai_grd_l0_.ORG_RLE_TYP_CDE as ORG_RLE_TYP_CDE, ai_grd_l0_.GRD_LVL_TYP_CDE as GRD_LVL_TYP_CDE, ai_grd_l0_.AI_GRD_LVL_EFF_DTE as AI_GRD_L4_, ai_grd_l0_.AI_GRD_LVL_EXPRTN_DTE as AI_GRD_L5_, ai_grd_l0_.UPDT_DTE_TM as UPDT_DTE6_, ai_grd_l0_.UPDT_USR_LGN_CDE as UPDT_USR7_ from AI_GRD_LVL ai_grd_l0_ where ai_grd_l0_.ORG_ID_NO=? and ai_grd_l0_.ORG_RLE_TYP_CDE=?
[9/5/03 11:29:41:545 EDT] 6608851f SystemOut U 2003-09-05 11:29:41,474 DEBUG [Thread-12] cache.NonstrictReadWriteCache:46 - Caching invalidated: org.ets.k12.generic.domain.OrganizationRole@89ca917b
The cache hit of "20000" is for Organization and the cache hit of "CT" is for OrganizationRoleType.
One other thing I notice, is that I get "Caching invalidated ..." and "Invalidating ..." debug statements for the OrganizationRole cached objects. I don't get those messages for other objects that are cached. Can you explain this?
Thanks alot!
Sarah