2010-06-07 119 views
3

如何設置postgres數據源的全局事務隔離級別。如何設置Postgres數據源的事務隔離級別

我在jboss上運行,我正在使用hibernate連接。

我知道我可以從休眠設置隔離級別,這是否適用於Postgres?

這將通過將hibernate.connection.isolation hibernate屬性設置爲1,2,4,8 - 相關靜態字段的各種值。

我使用org.postgresql.xa.PGXADataSource

+1

這一信息一個什麼?什麼? :-) – amphetamachine 2010-06-07 15:05:54

+0

添加了「什麼」 – 2012-01-17 09:52:24

回答

1

您可以設置隔離級別的方式。 Hibernate允許你以一種與數據庫無關的方式來完成它,所以它可以和PostgreSQL一起工作。

+0

Hibernate In Action書中提到:「Hibernate從不改變從託管環境中應用程序服務器提供的數據源獲得的連接的隔離級別。」亞歷山大T回答說,你最好在JBoss的DS配置中設置隔離級別。 – 2011-03-18 03:07:56

4

如果你不使用休眠或只是喜歡來設置數據源的隔離級別,所有的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