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.
|