I think it's exactly the other way around to that - the session (also called first-level) cache stores references to objects so that if you load the same object twice by key in two different queries or calls to session.load, session.get etc you will get two references to the same object. This means that:-
Code:
PersistentClass a = session.load(23, PersistentClass.class);
PersistentClass b = session.load(23, PersistentClass.class);
return a==b;
should return true. The second level cache just stores persistend property values, so that an object that isn't in the first level cache can be loaded without hitting the database. The session level cache is (as its name implies) scoped to a session, so
Code:
PersistentClass a = session.load(23, PersistentClass.class);
session = sessionFactory.openSession();
PersistentClass b = session.load(23, PersistentClass.class);
return a==b;
will return false. Is this what you are seeing?