According to the JavaDoc on Session.refresh(Object):
Code:
/**
* Re-read the state of the given instance from the underlying database. It is
* inadvisable to use this to implement long-running sessions that span many
* business tasks. This method is, however, useful in certain special circumstances.
* For example
* <ul>
* <li>where a database trigger alters the object state upon insert or update
* <li>after executing direct SQL (eg. a mass update) in the same session
* <li>after inserting a <tt>Blob</tt> or <tt>Clob</tt>
* </ul>
it should
re-read the "state" of the given instance from the underlying database. Particularly, this should be useful
after executing direct SQL (eg. a mass update) in the same session.
Now here's my question, if I opened a new session and used it to run a stored procedure which inserted a lot of records, then flushed and closed that session, then afterwards used a ThreadLocal session from a Filter to refresh an object which should contain the new records as part of a collection should I expect to see the new records or not? At present I do not and I am guessing this is because the ThreadLocal session does not see the changes, is this correct? In order for the Session.refresh to be able to see the inserted records I would need to have used the same session to perform the call to the stored procedure is that correct?
Thanks,
David