-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Level 2 Cache Question
PostPosted: Wed Apr 08, 2009 2:53 pm 
Newbie

Joined: Sat Nov 29, 2008 10:56 am
Posts: 8
I have several tables with basic lookup data in them (cd,description). I would like to be able to use the level 2 cache to cache the values as they are requested.

Basically I have several entity objects that hava a <many-to-one definition defined for the lookup value on that entity.

How do I get hibernate to use the cached values from the level 2 cache whenever a lookup value is referenced from a entity that has a reference to that lookup value?

I have EhCache implemented within my current app and I can get get the lookup values to be cached (I viewed the cache statistics) but the main entity (which is not cached) still issues a db select statement instead of pulling the lookup entity from the level 2 cache.

Here is a snippet of my hibernate mapping files:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping default-lazy="false">
    <class name="com.foo.MainEntity" table="main_table" batch-size="30">
        <id name="id" column="main_id" type="long">
            <generator class="sequence">
                <param name="sequence">main_id_seq</param>
            </generator>
        </id>
        <many-to-one name="lookupType" class="com.foo.LookupEntity" column="le_id" not-null="true" lazy="proxy"/>
    </class>
   
    <class name="com.foo.LookupEntity" table="lookup_table" batch-size="30">
        <cache usage="read-only"/>
        <id name="id" column="le_id" type="long">
            <generator class="sequence">
                <param name="sequence">lookup_id_seq</param>
            </generator>
        </id>
        <property name="name" column="name" not-null="true"/>
        <property name="description" column="description" not-null="true"/>
    </class>
   
</hibernate-mapping>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.