I’m using hibernate to store a set of objects from a web service.
As the object are received each I am saving them using hibernate.
Receiving the objects is wrapped in a transaction and all the objects appear in the database after the final object is received.
I am now trying have each object appear in the database when saved. I’ve tried to achieve this with
getHibernateTemplate().saveOrUpdate( foo ); getHibernateTemplate().flush(); getHibernateTemplate().clear();
My understanding is this should remove the values hibernate’s cache and write the values to the database.
Any learning or directions?
Thanks for the help Brian. The problems turned out to be a
forloop in another class wrapping the save call.The solution was to remove the
forloop and replace it with aniterator.Hibernate was keeping the same transaction for the entire
forloop. Using theiterator, Hibernate seems to start a new transaction and hence performs the commit to the database and then a flush before beginning the next transaction.