How to Set Postgres Transaction Isolation Level To Serializable?

Hello,
In a project I have to write a lottery function.And I find it best use ISOLATION LEVEL SERIALIZABLE mode to prevent concurrent problem.
After reading cuba platform’s documention, I can’t find a method to achieve this.
How can I set Transaction Isolation Level programmly?

Thanks

Hi,

Option 1: mark required service methods with @Transactional(isolation = Isolation.SERIALIZABLE)
Option 2: If you have the app datasource defined in context.xml you can try to set it in the datasource descriptor:

    <Resource driverClassName="org.hsqldb.jdbc.JDBCDriver"
              defaultTransactionIsolation="SERIALIZABLE"
              maxIdle="2"
              maxTotal="20"
              maxWaitMillis="5000"
              name="jdbc/CubaDS"
              password=""
              type="javax.sql.DataSource"
              url="..."
              username="sa"/>
1 Like

Thanks! :+1: