Using Spring transactions, JPA with Hibernate implementation.
I have marked a method as:
Does this combination of readOnly and read uncommitted valid? I am using this on a method who’s native sql is a select statement for a report page. First, I am marking it as read uncommitted so that it does not get stuck waiting on the table which gets frequently updated, as user wants to generate report even during processing time (a warning is shown if this happens). Second, I am marking as readonly to tell JPA not to keep the entities in the persistent context.
Is this a correct understanding?
Since you need intermediate data during the processing time, READ_UNCOMMITTED isolation level makes sense. ReadOnly transaction will make sure that all the sql statements in that particular transaction are Select statements and if it finds any Insert/Update sql statements, it will immediately throw an error. I think ReadOnly is just an additional check to make sure that your are not updating any data during a particular transaction.