how to set query to be read uncommited?

hibernate, java, transactions

Solution

Using Spring with Hibernate it is possible to have Spring controlling transactions with annotations, that is some configuration like the one below in spring applicationContext.xml:

<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory"/>
</bean>

<!-- To use annotation driven in aspect mode (mode="aspectj"), it is necessary to add spring-aspects lib -->
<tx:annotation-driven transaction-manager="transactionManager" />

The best way to achieve that is to using an annotation like the one below:

@Transactional(propagation=Propagation.REQUIRED, isolation=Isolation.READ_UNCOMMITTED)

Problem

with hibernate, how can I set a query to be read uncommitted? I don't want this to be a global setting, just want to do it on a per query basis.

Original source