Can anyone advise why the OpenEntityManagerInViewFilter does not allow for a session per transaction (singleSession = false) as for the OpenSessionInViewFilter?
As far as I can see there is also no mechanism to control the Flush Mode.
I am trying to ascertain what the behaviour should be in the following case under the default configuration of OEMIV Filter:
[1] Controller loads an existing entity in a transaction marked as readOnly and auto-binds user input.
[2] Controller queries the database in a transaction marked as readOnly to determine if some fileld related to the entity is unique.
The behaviour I am seeing in that before the query is executed in T2, Hibernate attempts to flush the state of the entity loaded in T1 and modified outside of a transaction. I can see why it might do that as both transactions are associated with the same session.
Is this what should be happening however?
I was under the impression that the readOnly flag would set the FlushMode to NEVER. However maybe I am misunderstanding and this will only be for the duration of this new transaction and not for entities modified in a previous transaction (in the same session).
Under OpenSessionInViewFilter (as opposed to OEMIV Filter whcih I am using) I believe the default flush mode is NEVER. So wouldn't this also prevent the issue regardless of whether the transaction was marked as readOnly. I cannot find any documentation about FlushMode for OEMIV.
Under OpenSessionInViewFilter (as opposed to OEMIV) there is an option to set singleSession to false. Again, I think this would fix the issue as T1 and T2 will no longer be associated with the same session
Slightly confused by all this: I've only been using Spring and Hibernate for the last 6 years after all!
Thanks.
As far as I can see there is also no mechanism to control the Flush Mode.
I am trying to ascertain what the behaviour should be in the following case under the default configuration of OEMIV Filter:
[1] Controller loads an existing entity in a transaction marked as readOnly and auto-binds user input.
[2] Controller queries the database in a transaction marked as readOnly to determine if some fileld related to the entity is unique.
The behaviour I am seeing in that before the query is executed in T2, Hibernate attempts to flush the state of the entity loaded in T1 and modified outside of a transaction. I can see why it might do that as both transactions are associated with the same session.
Is this what should be happening however?
I was under the impression that the readOnly flag would set the FlushMode to NEVER. However maybe I am misunderstanding and this will only be for the duration of this new transaction and not for entities modified in a previous transaction (in the same session).
Under OpenSessionInViewFilter (as opposed to OEMIV Filter whcih I am using) I believe the default flush mode is NEVER. So wouldn't this also prevent the issue regardless of whether the transaction was marked as readOnly. I cannot find any documentation about FlushMode for OEMIV.
Under OpenSessionInViewFilter (as opposed to OEMIV) there is an option to set singleSession to false. Again, I think this would fix the issue as T1 and T2 will no longer be associated with the same session
Slightly confused by all this: I've only been using Spring and Hibernate for the last 6 years after all!
Thanks.