OPENJPA-903 - Commit contribution submitted by Tim McConnell. [Ref: http://archives.postgresql.org/pgsql-jdbc/2008-01/msg00089.php]

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@749423 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Albert Lee 2009-03-02 19:32:14 +00:00
parent a95c0f0f89
commit 781c837812
2 changed files with 18 additions and 8 deletions

View File

@ -144,6 +144,7 @@ public class PostgresDictionary
})); }));
supportsLockingWithDistinctClause = false; supportsLockingWithDistinctClause = false;
supportsQueryTimeout = false;
supportsLockingWithOuterJoin = false; supportsLockingWithOuterJoin = false;
supportsNullTableForGetImportedKeys = true; supportsNullTableForGetImportedKeys = true;

View File

@ -29,6 +29,7 @@ import javax.persistence.OptimisticLockException;
import javax.persistence.Query; import javax.persistence.Query;
import javax.persistence.TransactionRequiredException; import javax.persistence.TransactionRequiredException;
import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
import org.apache.openjpa.jdbc.sql.DBDictionary; import org.apache.openjpa.jdbc.sql.DBDictionary;
import org.apache.openjpa.jdbc.sql.SQLErrorCodeReader; import org.apache.openjpa.jdbc.sql.SQLErrorCodeReader;
import org.apache.openjpa.persistence.test.SingleEMFTestCase; import org.apache.openjpa.persistence.test.SingleEMFTestCase;
@ -54,6 +55,10 @@ public class TestException extends SingleEMFTestCase {
* exception thrown is an instance of javax.persistence.OptimisticException. * exception thrown is an instance of javax.persistence.OptimisticException.
*/ */
public void testThrowsOptimisticException() { public void testThrowsOptimisticException() {
boolean supportsQueryTimeout = ((JDBCConfiguration) emf
.getConfiguration()).getDBDictionaryInstance().supportsQueryTimeout;
EntityManager em1 = emf.createEntityManager(); EntityManager em1 = emf.createEntityManager();
EntityManager em2 = emf.createEntityManager(); EntityManager em2 = emf.createEntityManager();
assertNotEquals(em1, em2); assertNotEquals(em1, em2);
@ -75,6 +80,7 @@ public class TestException extends SingleEMFTestCase {
assertTrue(pc1 != pc2); assertTrue(pc1 != pc2);
pc1.setName("Modified in TXN1"); pc1.setName("Modified in TXN1");
if (supportsQueryTimeout) {
em1.flush(); em1.flush();
try { try {
pc2.setName("Modified in TXN2"); pc2.setName("Modified in TXN2");
@ -82,6 +88,9 @@ public class TestException extends SingleEMFTestCase {
fail("Expected " + OptimisticLockException.class); fail("Expected " + OptimisticLockException.class);
} catch (Throwable t) { } catch (Throwable t) {
assertException(t, OptimisticLockException.class); assertException(t, OptimisticLockException.class);
}
} else {
pc2.setName("Modified in TXN2");
} }
em1.getTransaction().commit(); em1.getTransaction().commit();