Hi,
I am using the default EHCache for my 2nd layer cache with read-only, and it is not working as I expected. On the first transaction it does a join for the session.get() operation (I don't know why it does a join a get() operation),.and a join on the root.getSsDataTreeNodes() (gets the many in a one-to-many relationship).
On the second iteration, the SQL's that are generated are no longer joins, but simple select statements -- which implies that the cache is working on some level. However, I would think that the second iteration, there would be *no* SQL's generated since all the data is living in the cache.
Let me know if my question is unclear. Any help would be appreciated.
Thanks,
Derrill
Hibernate version:2.1.7c
Mapping documents: <class name="amazon.platform.D3S.D3SDataModel.SsDataTreeNode" table="SS_DATA_TREE_NODES" >
<meta attribute="class-description" inherit="false"> @hibernate.class table="SS_DATA_TREE_NODES" </meta> <cache usage="read-only" /> <id name="dataTreeNodeId" type="java.math.BigDecimal" column="DATA_TREE_NODE_ID" > <meta attribute="field-description"> @hibernate.id generator-class="assigned" type="java.math.BigDecimal" column="DATA_TREE_NODE_ID"
</meta> <generator class="assigned" /> </id>
<set name="ssDataTreeNodes" lazy="true" inverse="true" cascade="none" >
<meta attribute="field-description"> @hibernate.set lazy="true" inverse="true" cascade="none"
@hibernate.collection-key column="PARENT_INDEX"
@hibernate.collection-one-to-many class="amazon.platform.D3S.D3SDataModel.SsDataTreeNode" </meta> <cache usage="read-only" /> <key> <column name="PARENT_INDEX" /> </key> <one-to-many class="amazon.platform.D3S.D3SDataModel.SsDataTreeNode" /> </set>
Code between sessionFactory.openSession() and session.close(): SsDataTreeNode root = (SsDataTreeNode)s.get(SsDataTreeNode.class, new BigDecimal(0)); // get single row root.getSsDataTreeNodes() ; // get set relationship
Full stack trace of any exception that occurs: No exceptions
Name and version of the database you are using: oracle 8
The generated SQL (show_sql=true): Transaction 1: Hibernate: select ssdatatree0_.DATA_TREE_NODE_ID as DATA_TRE1_1_, ssdatatree0_.SHORT_NAME as SHORT_NAME1_, ssdatatree0_.LONG_NAME as LONG_NAME1_, ssdatatree0_.DESCRIPTION as DESCRIPT4_1_, ssdatatree0_.BASE_WEBSITE_ID as BASE_WEB5_1_, ssdatatree0_.LAST_UPDATED as LAST_UPD6_1_, ssdatatree0_.RECORD_VERSION_NUMBER as RECORD_V7_1_, ssdatatree0_.NODE_TYPE_ID as NODE_TYP8_1_, ssdatatree0_.PARENT_INDEX as PARENT_I9_1_, ssnodetype1_.NODE_TYPE_ID as NODE_TYP1_0_, ssnodetype1_.SHORT_NAME as SHORT_NAME0_, ssnodetype1_.LONG_NAME as LONG_NAME0_, ssnodetype1_.DESCRIPTION as DESCRIPT4_0_, ssnodetype1_.LAST_UPDATED as LAST_UPD5_0_, ssnodetype1_.RECORD_VERSION_NUMBER as RECORD_V6_0_ from SS_DATA_TREE_NODES ssdatatree0_, SS_NODE_TYPES ssnodetype1_ where ssdatatree0_.DATA_TREE_NODE_ID=? and ssdatatree0_.NODE_TYPE_ID=ssnodetype1_.NODE_TYPE_ID(+) Hibernate: select ssdatatree0_.PARENT_INDEX as PARENT_I9___, ssdatatree0_.DATA_TREE_NODE_ID as DATA_TRE1___, ssdatatree0_.DATA_TREE_NODE_ID as DATA_TRE1_1_, ssdatatree0_.SHORT_NAME as SHORT_NAME1_, ssdatatree0_.LONG_NAME as LONG_NAME1_, ssdatatree0_.DESCRIPTION as DESCRIPT4_1_, ssdatatree0_.BASE_WEBSITE_ID as BASE_WEB5_1_, ssdatatree0_.LAST_UPDATED as LAST_UPD6_1_, ssdatatree0_.RECORD_VERSION_NUMBER as RECORD_V7_1_, ssdatatree0_.NODE_TYPE_ID as NODE_TYP8_1_, ssdatatree0_.PARENT_INDEX as PARENT_I9_1_, ssnodetype1_.NODE_TYPE_ID as NODE_TYP1_0_, ssnodetype1_.SHORT_NAME as SHORT_NAME0_, ssnodetype1_.LONG_NAME as LONG_NAME0_, ssnodetype1_.DESCRIPTION as DESCRIPT4_0_, ssnodetype1_.LAST_UPDATED as LAST_UPD5_0_, ssnodetype1_.RECORD_VERSION_NUMBER as RECORD_V6_0_ from SS_DATA_TREE_NODES ssdatatree0_, SS_NODE_TYPES ssnodetype1_ where ssdatatree0_.PARENT_INDEX=? and ssdatatree0_.NODE_TYPE_ID=ssnodetype1_.NODE_TYPE_ID(+)
Transaction 2: Hibernate: select ssnodetype0_.NODE_TYPE_ID as NODE_TYP1_0_, ssnodetype0_.SHORT_NAME as SHORT_NAME0_, ssnodetype0_.LONG_NAME as LONG_NAME0_, ssnodetype0_.DESCRIPTION as DESCRIPT4_0_, ssnodetype0_.LAST_UPDATED as LAST_UPD5_0_, ssnodetype0_.RECORD_VERSION_NUMBER as RECORD_V6_0_ from SS_NODE_TYPES ssnodetype0_ where ssnodetype0_.NODE_TYPE_ID=? Hibernate: select ssnodetype0_.NODE_TYPE_ID as NODE_TYP1_0_, ssnodetype0_.SHORT_NAME as SHORT_NAME0_, ssnodetype0_.LONG_NAME as LONG_NAME0_, ssnodetype0_.DESCRIPTION as DESCRIPT4_0_, ssnodetype0_.LAST_UPDATED as LAST_UPD5_0_, ssnodetype0_.RECORD_VERSION_NUMBER as RECORD_V6_0_ from SS_NODE_TYPES ssnodetype0_ where ssnodetype0_.NODE_TYPE_ID=?
Debug level Hibernate log excerpt:
|