如何为 postgres 数据源设置全局事务隔离级别。
我在 jboss 上运行,我正在使用 hibernate 进行连接。
我知道我可以从休眠中设置隔离级别,这对 Postgres 有用吗?
这可以通过将 hibernate.connection.isolation hibernate 属性设置为 1,2,4,8 - 相关静态字段的各种值来实现。
我正在使用 org.postgresql.xa.PGXADataSource
如何为 postgres 数据源设置全局事务隔离级别。
我在 jboss 上运行,我正在使用 hibernate 进行连接。
我知道我可以从休眠中设置隔离级别,这对 Postgres 有用吗?
这可以通过将 hibernate.connection.isolation hibernate 属性设置为 1,2,4,8 - 相关静态字段的各种值来实现。
我正在使用 org.postgresql.xa.PGXADataSource
如果您不使用 Hibernate 或者只是更喜欢在数据源中设置隔离级别,所有 JBoss 数据源都支持该<transaction-isolation>
标记:
<datasources>
<local-tx-datasource>
<jndi-name>GenericDS</jndi-name>
<connection-url>[jdbc: url for use with Driver class]</connection-url>
<driver-class>[fully qualified class name of java.sql.Driver implementation]</driver-class>
<user-name>x</user-name>
<password>y</password>
<!-- you can include connection properties that will get passed in
the DriverManager.getConnection(props) call-->
<!-- look at your Driver docs to see what these might be -->
<connection-property name="char.encoding">UTF-8</connection-property>
<transaction-isolation>TRANSACTION_SERIALIZABLE</transaction-isolation>
[...]
您可以通过这种方式设置隔离级别。Hibernate 允许您以与数据库无关的方式进行操作,因此它可以与 PostgreSQL 一起使用。