I've run into a situation where the Hibernate object passed back from the query is unreliable.
Consider the following code:
MyClass myClass = myDAO.get(id);
myClass.getId(); //This works
myClass.getName(); //This returns null sometimes, and works sometimes
Here's my get Method:
@SuppressWarnings("unchecked")
public T get(ID id)
{
Session s = getSession();
T entity = (T) s.load(getPersistentClass(), id);
s.disconnect();
return entity;
}
Now, I understand that this object is a proxy, and will be lazy loaded, but I would expect it to either always work, or never work. Am I doing something wrong here?