-->
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: Index field in <list> collections corrupted
PostPosted: Wed Jun 29, 2005 1:18 pm 
Newbie

Joined: Wed Jun 29, 2005 1:16 pm
Posts: 1
We're experiencing a very strange problem in our web application. First, here are the relevant packages we are using:

spring-1.1.4
hibernate-2.1.8
ehcache-1.1

We have several hibernate-enabled domain objects that have a "displayOrder" property, which is used in conjunction with hibernate's <list> collection feature. We have used the override-the-getter trick in the domain object, e.g.:

Code:
public Integer getDisplayOrder() {
    try {
        return new Integer(getParent().getChildren().indexOf(this));
    } catch (Exception e) {
        return super.getDisplayOrder();
    }
}


as mentioned at http://www.hibernate.org/193.html (see the "Does it really work? note at the bottom of that page).

We are using ehcache as the second-level cache, no disk spillover, and the ttl for everything is 1 hour. Both entities and collections are being cached.

Here's the weird problem we are encountering:

Occasionally, <list> collections get corrupted. For example, parent.getChildren() might have 10 elements. But occasionally, parent.getChildren() might contain 100+ elements, only 10 of which are non-null. Looking in the database, the displayOrder column no longer goes from 0..9, it goes 0, 1, 15, 42, 76, ..., 100+.

Has anyone seen anything like this before? We have all sorts of logging in the application, but we have yet to be able to pinpoint the source of this corruption, nor have we been able to reproduce it!

We're wondering if there might be some concurrency issues going on, and I have some questions about that.

None of our manager or domain object methods are synchronized. We are using spring's OpenSessionInViewFilter, so each request handler thread has its own session and first-level cache. Now that we have enabled the second-level cache, we are wondering if we need to go through and mark many methods "synchronized".

I need to look through the Hibernate code, but I am assuming that when the second-level cache is enabled, the parent.getChildren() collection returned by Hibernate could reference the same collection in two separate threads. Is that true? Or, does hibernate clone() things out of the second-level cache?

Thanks for your help,

Peter
Code:


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.