-->
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.  [ 2 posts ] 
Author Message
 Post subject: StaleObjectStateException when second level cache is enabled
PostPosted: Fri Jul 21, 2006 4:18 pm 
Newbie

Joined: Fri Jul 21, 2006 3:48 pm
Posts: 1
Hello,

I have a simpe POJO that i am using hibernate to persist to my DB. Everything works fine, but when I enable 2nd level cacheing (ehcache), I get a StaleObjectStateException on the flush after updates.

Here's my mapping:

Code:
<hibernate-mapping>
    <class name="ContentList" table="LIST" lazy="false"
                dynamic-update="true"
                dynamic-insert="true"
            select-before-update="true">
        <cache usage="nonstrict-read-write"/>
        <id name="tkey" column="LIST_KEY">
            <generator class="KeyGenerator">
                <param name="sequence">LIST_KEY_SEQ</param>
                <param name="class">java.lang.String</param>
            </generator>
        </id>

        <timestamp name="lastChangedDate" access="field" column="LAST_CHANGED_DATE"/>
        <property name="lastChangedBy" access="field" column="LAST_CHANGED_BY" not-null="true"/>

        <property name="title" access="field"/>
.
.
.
</hibernate-mapping>


Here's my ehcache config (works when I set maxElementsInMemory="0"):

Code:
    <cache name="ContentList"
           maxElementsInMemory="500"
           eternal="false"/>


And this is the offending code:

Code:
@Test(groups = {"content-list"})
    public void createContentList()
    {

        ContentList list = new ContentList();

        list.setTitle(LIST_TITLE);

        listService.saveContentList(list);

        key = list.getKey();
        assert(key != null);
    }

    @Test(groups = {"content-list"}, dependsOnMethods = {"createContentList"})
    public void findContentList()
    {
        ContentList list = listService.getContentListByTitle(LIST_TITLE);

        assert (list != null);
        assert(list.getTitle().equals(LIST_TITLE));
    }

    @Test(groups = {"content-list"}, dependsOnMethods = {"findContentList"})
    public void updateContentList()
    {
        ContentList list = listService.getContentList(key);

        assert (list != null);
        assert(list.getTitle().equals(LIST_TITLE));

        list.setTitle(LIST_TITLE_MODIFIED);

        listService.saveContentList(list);

        //Get list back from DB
        list = listService.getContentList(tkey);
        assert(list.getTitle().equals(LIST_TITLE_MODIFIED));
    }



Is this a cache configuration? Do i need to evict this item from the cache? If so, how so?

Thanks in advance for you help,
Matt


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 14, 2006 5:05 am 
Newbie

Joined: Fri Nov 12, 2004 1:40 am
Posts: 7
we changed "version" type from "date" in oracle to timestamp(6) and this error disapeared.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.