Hi,
I have specified that my maps utilise Echaching, which they do very nicely. But I have noticed while looking in the logs that the database is hit everytime a request is made to return a list (shown in the code below). How can I Echache the result of a List request so that the database is not hit everytime?
regards
Uzo
Hibernate version:
Code:
Jboss 4.0.0
Mapping documents:Code:
<class name="Artist" table="artisttbl">
<cache usage="read-write"/>
<id name="ID" column="artist_id">
<generator class="assigned"/>
</id>
<version name="Version" column="version" type="integer"/>
<property name="ArtistName" column="artist_name" type="string" not-null="true"/>
<property name="ArtistInfo" column="artist_info" type="string" not-null="true"/>
<property name="TrackLocation" column="track_location" type="string"/>
<property name="TrackInfo" column="track_info" type="string"/>
<property name="StockID" column="stock_id" type="string"/>
<set name="ArtistImages" inverse="true" lazy="true" cascade="all-delete-orphan">
<cache usage="read-write"/>
<key column="artist_id"/>
<one-to-many class="ArtistImages"/>
</set>
</class>
Return List:Making a request this way does not chache the result.
Code:
//Get Artist details
query = session.createQuery("from test.Artist");
artists = query.list();
Return Map:Making a request this way chaches the result.
Code:
//Get Artist details
artist = (Artist)session.load(Artist.class, artist_id);
Name and version of the database you are using:Code:
PostgreSQL 8.0