-->
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: Multiple load() or list() calls don't always populate data
PostPosted: Wed Apr 15, 2009 12:29 pm 
Newbie

Joined: Wed Apr 15, 2009 9:57 am
Posts: 2
Hibernate Version 3.3.1.GA

I can reproduce this error in or out of a J2EE container and with various database implementations (Intersystems Cache, Oracle, or Derby), so I don't think they are associated with the problem.

The issue is while under the same Session, we call session.load() or crtieria.list() for the same entities multiple times. In other words, we load the same entity multiple times or we execute multiple criteria that return the same entity multiple times.

The first few (we haven't found pattern, though it seems the first two) load()/list() calls work fine and return fully populated entities. Later calls to load()/list() return partially populated entities (i.e., some attributes are null that have values in the database).

Subsequent calls to session.refresh() can force the data to be retrieved.

The problem happens most often with two-level deep associations (many-to-many relationships with an association table).

For example, if I were to make these calls, where 'id' remains the same and I use the same session instance:

Object one = session.load(id);
Object two = session.load(id);
Object three = session.load(id);

The first two objects return fully populated, but the third is partially populated. If I set cascade="refresh" for the attributes in question or default-cascade="refresh" in the mapping files, and then make a call:

session.refresh(three);

Then the third gets fully populated. But why wouldn't it be fully populated in the first place?

I've tried changing the outer join and max_fetch_depth properties, but that doesn't seem to solve anything. Though I didn't really expect it to because the first two loads work fine.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 15, 2009 12:53 pm 
Newbie

Joined: Wed Apr 15, 2009 9:57 am
Posts: 2
I also tried setting the session's cache mode:

session.setCacheMode(CacheMode.IGNORE);

and later

session.setCacheMode(CacheMode.REFRESH);

But neither had an impact on the third retrieval.


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.