Hi,
I use a Criteria to find an object and when I use the list() methode I have an Exception :
object references an unsaved transient instance - save the transient instance before flushing B
But this B object is never use in this Criteria.
I find the problem because in fact just before my Criteria I use a transient object B (I just put the Criteria before)
Why this Criteria try to flush the object B ??
When you lock at the java code, the list() methode call autoFlushIfRequired()
Code:
AutoFlushEvent event = new AutoFlushEvent([b]querySpaces[/b], this);
AutoFlushEventListener[] autoFlushEventListener = listeners.getAutoFlushEventListeners();
for ( int i = 0; i < autoFlushEventListener.length; i++ ) {
autoFlushEventListener[i].onAutoFlush(event);
}
In event object, I retrieve all objects that my Criteria use. So object B is not in event.
But autoFlushEventListener call flushEverythingToExecutions() and this methode call flushEntities() that flush all objects including B.
Why hibernate flush all objects for a simple Criteria ?
May I find an option to change this behaviour ?