代码之家  ›  专栏  ›  技术社区  ›  Michael Wiles

如何设置Postgres数据源的事务隔离级别

  •  3
  • Michael Wiles  · 技术社区  · 16 年前

    如何设置Postgres数据源的全局事务隔离级别。

    我在jboss上运行,并使用hibernate进行连接。

    我知道我可以设置冬眠的隔离级别,这对Postgres有用吗?

    这可以通过将hibernate.connection.isolation hibernate属性设置为1,2,4,8-相关静态字段的各种值来实现。

    我正在使用org.postgresql.xa.pgxadatasource

    2 回复  |  直到 14 年前
        1
  •  1
  •   duffymo    16 年前

    您可以这样设置隔离级别。Hibernate允许您以数据库不可知的方式进行此操作,因此它将与PostgreSQL一起工作。

        2
  •  4
  •   Alexander Torstling    16 年前

    如果您不使用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>
        [...]
    

    我从 JBoss wiki