mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-17 00:24:57 +00:00
Cleaned up the dialect error conversion a little bit for PostgresSQL. I was doing more than I needed to.
Updated the LockTest to enable another nowait test for postgresql.
This commit is contained in:
parent
cb1c485774
commit
5c0d449082
@ -38,7 +38,6 @@
|
|||||||
import org.hibernate.dialect.function.StandardSQLFunction;
|
import org.hibernate.dialect.function.StandardSQLFunction;
|
||||||
import org.hibernate.dialect.function.VarArgsSQLFunction;
|
import org.hibernate.dialect.function.VarArgsSQLFunction;
|
||||||
import org.hibernate.exception.LockAcquisitionException;
|
import org.hibernate.exception.LockAcquisitionException;
|
||||||
import org.hibernate.exception.internal.SQLStateConversionDelegate;
|
|
||||||
import org.hibernate.exception.spi.SQLExceptionConversionDelegate;
|
import org.hibernate.exception.spi.SQLExceptionConversionDelegate;
|
||||||
import org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtracter;
|
import org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtracter;
|
||||||
import org.hibernate.exception.spi.ViolatedConstraintNameExtracter;
|
import org.hibernate.exception.spi.ViolatedConstraintNameExtracter;
|
||||||
@ -376,11 +375,10 @@ public String extractConstraintName(SQLException sqle) {
|
|||||||
public SQLExceptionConversionDelegate buildSQLExceptionConversionDelegate() {
|
public SQLExceptionConversionDelegate buildSQLExceptionConversionDelegate() {
|
||||||
SQLExceptionConversionDelegate delegate = super.buildSQLExceptionConversionDelegate();
|
SQLExceptionConversionDelegate delegate = super.buildSQLExceptionConversionDelegate();
|
||||||
if (delegate == null) {
|
if (delegate == null) {
|
||||||
delegate = new SQLStateConversionDelegate(this) {
|
delegate = new SQLExceptionConversionDelegate() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JDBCException convert(SQLException sqlException, String message, String sql) {
|
public JDBCException convert(SQLException sqlException, String message, String sql) {
|
||||||
JDBCException exception = super.convert(sqlException, message, sql);
|
JDBCException exception = null;
|
||||||
|
|
||||||
if (exception == null) {
|
if (exception == null) {
|
||||||
String sqlState = JdbcExceptionHelper.extractSqlState(sqlException);
|
String sqlState = JdbcExceptionHelper.extractSqlState(sqlException);
|
||||||
|
@ -23,6 +23,17 @@
|
|||||||
*/
|
*/
|
||||||
package org.hibernate.ejb.test.lock;
|
package org.hibernate.ejb.test.lock;
|
||||||
|
|
||||||
|
import org.hibernate.dialect.HSQLDialect;
|
||||||
|
import org.hibernate.dialect.Oracle10gDialect;
|
||||||
|
import org.hibernate.dialect.PostgreSQL81Dialect;
|
||||||
|
import org.hibernate.dialect.SybaseASE15Dialect;
|
||||||
|
import org.hibernate.ejb.AvailableSettings;
|
||||||
|
import org.hibernate.ejb.test.BaseEntityManagerFunctionalTestCase;
|
||||||
|
import org.hibernate.testing.*;
|
||||||
|
import org.jboss.logging.Logger;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -30,35 +41,8 @@
|
|||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.FutureTask;
|
import java.util.concurrent.FutureTask;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import javax.persistence.EntityManager;
|
|
||||||
import javax.persistence.LockModeType;
|
|
||||||
import javax.persistence.LockTimeoutException;
|
|
||||||
import javax.persistence.OptimisticLockException;
|
|
||||||
import javax.persistence.PessimisticLockException;
|
|
||||||
import javax.persistence.PersistenceException;
|
|
||||||
import javax.persistence.Query;
|
|
||||||
import javax.persistence.QueryTimeoutException;
|
|
||||||
|
|
||||||
import org.jboss.logging.Logger;
|
import static org.junit.Assert.*;
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import org.hibernate.dialect.HSQLDialect;
|
|
||||||
import org.hibernate.dialect.Oracle10gDialect;
|
|
||||||
import org.hibernate.dialect.SybaseASE15Dialect;
|
|
||||||
import org.hibernate.ejb.AvailableSettings;
|
|
||||||
import org.hibernate.ejb.test.BaseEntityManagerFunctionalTestCase;
|
|
||||||
import org.hibernate.testing.DialectChecks;
|
|
||||||
import org.hibernate.testing.FailureExpected;
|
|
||||||
import org.hibernate.testing.RequiresDialect;
|
|
||||||
import org.hibernate.testing.RequiresDialectFeature;
|
|
||||||
import org.hibernate.testing.SkipForDialect;
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
|
||||||
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import static org.junit.Assert.fail;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Emmanuel Bernard
|
* @author Emmanuel Bernard
|
||||||
@ -116,7 +100,7 @@ public void testFindWithImmediateTimeoutHintVerifyException() {
|
|||||||
EntityManager em3 = createIsolatedEntityManager();
|
EntityManager em3 = createIsolatedEntityManager();
|
||||||
em3.getTransaction().begin();
|
em3.getTransaction().begin();
|
||||||
try {
|
try {
|
||||||
Lock lock3 = em3.find( Lock.class, lock.getId(), LockModeType.PESSIMISTIC_WRITE, properties );
|
em3.find( Lock.class, lock.getId(), LockModeType.PESSIMISTIC_WRITE, properties );
|
||||||
assertFalse("Exception should be thrown", true);
|
assertFalse("Exception should be thrown", true);
|
||||||
} catch (LockTimeoutException lte) {
|
} catch (LockTimeoutException lte) {
|
||||||
assertTrue("Proper exception thrown for dialect supporting lock timeouts when an immediate timeout is set.", true);
|
assertTrue("Proper exception thrown for dialect supporting lock timeouts when an immediate timeout is set.", true);
|
||||||
@ -635,7 +619,7 @@ public Boolean call() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@RequiresDialect( value = Oracle10gDialect.class )
|
@RequiresDialect( value = { Oracle10gDialect.class, PostgreSQL81Dialect.class })
|
||||||
@RequiresDialectFeature( value = DialectChecks.SupportsLockTimeouts.class )
|
@RequiresDialectFeature( value = DialectChecks.SupportsLockTimeouts.class )
|
||||||
public void testContendedPessimisticWriteLockNoWait() throws Exception {
|
public void testContendedPessimisticWriteLockNoWait() throws Exception {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user