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.  [ 4 posts ] 
Author Message
 Post subject: Write-through Secondary Cache using EHCache?
PostPosted: Tue Dec 02, 2008 2:53 pm 
Newbie

Joined: Tue Dec 02, 2008 2:44 pm
Posts: 3
Hey all,

I searched around this forum, and also Googled, but I couldn't find anything related to enabling a write-through secondary cache using EHCache for Hibernate. Is that because it cannot do so? Search with Google led me to GigaSpaces caching system, and I'm wondering if I have to step away for EHCache if I want the write-through behavior.

I tried read-write cache using EHCache, but that doesn't seem to be doing a write-through caching, and I couldn't find anything associated with enabling that feature (which leads me to believe that I cannot do that via EHCache).

Another thought is that perhaps it is doing a write-through caching, but it's not invalidating the cached object, resulting in the look-up finding the old data.

Thanks for your help!
Koichi


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 03, 2008 1:53 pm 
Newbie

Joined: Tue Dec 02, 2008 2:44 pm
Posts: 3
Please ignore this one...did it twice by a mistake.


Last edited by ichikoo on Wed Dec 03, 2008 1:59 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 03, 2008 1:54 pm 
Newbie

Joined: Tue Dec 02, 2008 2:44 pm
Posts: 3
Actually, it seems like I have a different issue than what I thought.

The problem seems to be that the cached child is not getting updated with the parent's info when it gets saved.

Here's a part of the mapping file that I have:

Code:
    <class name="Parent" table="Parents">
        <id name="id" length="32">
            <generator class="UUIDIdentifierGenerator"/>
        </id>

        <many-to-one name="firstChild" column="firstChildId" unique="true" cascade="save-update,delete"/>

        <bag name="children" cascade="save-update,delete" order-by="createdDate asc">
            <key column="parentId"/>
            <one-to-many class="Child"/>
        </bag>
    </class>

    <class name="Child" table="Children">
        <cache usage="read-write"/>

        <id name="id">
            <generator class="assigned"/>
        </id>

        <many-to-one name="parent" column="parentId" not-null="true" insert="false" update="false"/>
    </class>


What I do is the following:
- Create a Parent.
- Create a child, add it as the firstChild, and also as part of the children's list.
- Save the Parent.

What seems to happen is the following:
- Saves the Child
- Saves the Parent.
- Updates the child with the parent ID
- Child gets cached

When I retrieve the Child then, it lacks the information about the parent. At the Java Object level, the parent is null when the child is retrieved from the cache.

I'm wondering what setting am I missing that prevents the cache from getting the newest data.

Any help is appreciated.
Thanks!
Koichi


Top
 Profile  
 
 Post subject: GigaSpaces for Hibernate ORM Users
PostPosted: Thu Dec 04, 2008 7:17 pm 
Newbie

Joined: Thu May 13, 2004 6:32 am
Posts: 4
Location: USA
Koichi,
Using GigaSpaces with Hibernate is fully described here:
http://www.gigaspaces.com/wiki/display/ ... +ORM+Users

The best way to use GiagSpaces together with Hibernate is to allow GigaSpaces to load your data from the database once it is started (via our build in Hibernate External Data Source) and write the data into the database using write behind approach (we call this async-persistency-Mirror). This piece is also using the Hibernate External Data Source. To allow GigaSpaces Hibernate External Data Source to work properly you simply need to configure the Data Grid and the Mirror to use your POJO (and their hbm files in case you do not use annotations).

With GigaSpaces , you do not need to use lazy load , but load all the data into the data grid once started. This provides maximum performance when you query your data or update it when accessing the data. In any case, the database would not impact the application performance. You could cache your data within the data grid or locally within the application JVM (we call this local cache).

If you need help on this let me know: shay@gigaspaces.com

Shay


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

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.