My web application uses Hibernate 3.2 and Spring, and is configured to use an OpenSessionInViewFilter with the default FlushMode (FlushMode.NEVER).
It appears that the session is being flushed automatically, however, whenever I fetch some data using Criteria.
This means that if I want to create entity instances for use in the view only, I'm restricted. With the following code, "myEntity" would be written to the database on line 2 where there's a call to findByCriteria(...)
Code:
1: myEntity = new EntityObject();
2: getHibernateTemplate().findByCriteria(some detached criteria);
Is this the expected behaviour?
I realise that I could avoid "myEntity" being written to the database by swapping lines 1 and 2, but in my scenario that's not possible as I have custom JSP tags that fetch data using the criteria API.