How do I set the global transaction isolation level for a postgres data source.
I'm running on jboss and I'm using hibernate to connect.
I know that I can set the isolation level from hibernate, does this work for Postgres?
This would be by setting the hibernate.co开发者_JAVA技巧nnection.isolation hibernate property to 1,2,4,8 - the various values of the relevant static fields.
I'm using the org.postgresql.xa.PGXADataSource
If you're not using Hibernate or just prefer to set the isolation level in the data source, all JBoss datasources support the <transaction-isolation>
tag:
<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>
[...]
I got this information from the JBoss wiki
You can set isolation level that way. Hibernate allows you to do it in a database-agnostic way, so it'll work with PostgreSQL.
精彩评论