Thanks for your quick answer.
I changed my code to disable the automatic flush :
Code:
HibernateTemplate hibernateTemplate = getHibernateTemplate();
hibernateTemplate.setFlushMode(HibernateAccessor.FLUSH_NEVER);
List undistinctList = hibernateTemplate.findByNamedQuery("projectByUser", userLogin);
But it doesn't work. I still have some hibernate queries at the commit of the Tx (I use a TransactionInterceptor to do declarative Tx management). I looked at the HibernateTemplate code and I found this in the execute Method :
Code:
if (!existingTransaction && getFlushMode() == FLUSH_NEVER) {
session.setFlushMode(FlushMode.NEVER);
}
I don't understand why you can't set the flush mode to never if you use a tx.
Thanks,
Gaetan