Hello everybody
I am Bert and I am part of the team of weewar.com a turn based strategy game.
In advance: Hibernate is great. I want to thank the developers and the open source community for creating such a great product.
My problem concerns a cached collections. I am using a second level cache (ehcache). All essential mapping documents can be found below.
Here is my problem:
My application loads an object of class "EventCollection" that contains a cached collection that consists of objects of class "Event". The contents of this collection is loaded using the fetch="join" attribute once the EventCollection is loaded. Hence all this is done with one single sql query.
I can now access the EventCollection and the containing Events as I like and no futher sql queryies are made.
Everything works fine until Events expire from the second level cache. If I access the events after that each Event is loaded with one sql statement.
Thanks a lot
Bert
Hibernate version: 3.1.3
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping package="com.weewar.model">
<class
name="EventCollection"
table="EventCollection"
>
<meta attribute="sync-DAO">true</meta>
<cache usage="read-write"/>
<id
name="Id"
type="integer"
column="collection_id"
>
<generator class="native"/>
</id>
<list name="events" fetch="join" lazy="false">
<key column="collection_id" />
<list-index column="position" />
<one-to-many class="Event" />
</list>
</class>
<class
name="Event"
table="Event"
batch-size="300"
>
<meta attribute="sync-DAO">true</meta>
<cache usage="read-write"/>
<id
name="Id"
type="integer"
column="event_id"
>
<generator class="native"/>
</id>
<property
name="timestamp"
column="timestamp"
type="timestamp"
/>
<property
name="position"
column="position"
type="int"
length="11"
/>
<many-to-one
name="eventCollection"
column="collection_id"
class="EventCollection"
/>
<many-to-one
name="player"
column="player_id"
class="Player"
/>
<!-- ommitted lots of properties here -->
</class>
</hibernate-mapping>
hibernate.cfg.xml contains the following entry:
<collection-cache collection="com.weewar.model.EventCollection.events" usage="read-write"/>
Name and version of the database you are using:
MySql 5.0
Read this:
http://hibernate.org/42.html