I have a question about the behavior of the second level cache and collections. I am using JBossCache 1.2.
I am testing the caching of collections. The parent object is not cached during this test.
When the object is saved to the database I am seeing this error message in the JBoss Log after the parent and collection rows have been saved:
node //com/teradata/tap/system/persistence/TestSimpleCollectionParent/children/22 not found
Then the test loops to read back the object 5 times. I inserted a sleep after the write of the object.
The first read issues a query and goes to get the object, because the collection was not cached. The subsequent 4 reads get a hit in the cache and no queries go to the database.
When I tested the same scenario with a cached class (vs. collection), the save of the object put the object in the cache. All subsequent reads were resolved by the cache.
Should the save of the collection cause the collection to be cached? I do not have any regions defined in my treecache.xml file, do I need to have one to avoid the node not found message?
Hibernate version: 2.1.3
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.teradata.tap.system.persistence.TestSimpleCollectionParent" table="PM_TEST_COLLECTION_PARENT">
<id name="id" column="Test_Id" type="long">
<generator class="com.teradata.tap.system.persistence.hibernate.SessionBeanSequenceGenerator"/>
</id>
<property name="name" column="Name"/>
<list name="children" lazy="false" table="PM_TEST_COLLECTION_CHILD">
<cache usage="transactional"/>
<key column="Parent_Id"/>
<index column="ChildNum"/>
<composite-element class="com.teradata.tap.system.persistence.TestSimpleCollectionChild">
<property name="name" column="Name"/>
</composite-element>
</list>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
pesistence is done in EJB tier, using Session.save(), Session.load().
Full stack trace of any exception that occurs:
16:32:00,674 ERROR [TreeCache] node //com/teradata/tap/system/persistence/TestSi
mpleCollectionParent/children/22 not found
Name and version of the database you are using:
Teradata V2R5.1
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
|