Hi,
here's the context :
we are currently writing an application which is web based (flex front end). The server side is implemented with Java, using hibernate for ORM. Well, I'm not wrong with the forum I write to.
The specificity of this application is that it implements a conversation with the user. That means that the user is opening a conversation and before it decides to save (or cancel) the conversation, it performs many operations on objects which are mapped as hibernate entities.
For instance :
- open a conversation
- create an object A
- save it in the session
- query it
- update it
- etc...
- save the conversation
and then another conversation cycle starts.
We chose naturally the session-per-conversation pattern to implement this way to work.
Let me remind you the principle : the hibernate session is created once when the user decides to start a conversation, its flush mode being set to MANUAL, and from now it is disconnected between each transaction until the user decide to end the conversation which is the only time when we explicitly flush the session (and so write the data from session to DB).
We had no problem at all until we want to query some unflushed entities! Because if we want to use this kind of conversation, that's because we want to be in a state of "simulation' until we explicitly flush the session.
But it appears that unflushed entities cannot be loaded using hibernate criterias or HQL except if a flush() is performed on the session which leads to loose all benefit from the session-per-conversation pattern...
So my question is :
Can we configure this behaviour? (ie can we enable querying the session cache event if the session is not flushed?)
As it seems that the answer is no (any contradictor will be welcome!), 2nd question :
Is there a smart way to make it on my own without perverting the probably intelligent and considered hibernate's way of doing?
Hoping that my english is understandable, I thank you all by advance.
Ben