mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-22 15:10:02 +00:00
#2862 - Ebean 13.9.3 : org.postgresql.util.PSQLException: Cannot rollback when autoCommit is enabled
This commit is contained in:
1 parent
f24f912693
commit
3f5800da3b
3 files changed
+55
-1
No files matched your search
@@ -17,6 +17,20 @@
|
|||||||
<version>13.10.1-SNAPSHOT</version>
|
<version>13.10.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.ebean</groupId>
|
||||||
|
<artifactId>ebean-test-containers</artifactId>
|
||||||
|
<version>6.3</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.postgresql</groupId>
|
||||||
|
<artifactId>postgresql</artifactId>
|
||||||
|
<version>42.5.0</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.avaje</groupId>
|
<groupId>io.avaje</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
|
|||||||
+3
-1
@@ -62,7 +62,9 @@ public class PostgresPlatformProvider implements DatabasePlatformProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
connection.rollback();
|
if (!connection.getAutoCommit()) {
|
||||||
|
connection.rollback();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (majorVersion <= 9) {
|
if (majorVersion <= 9) {
|
||||||
return new Postgres9Platform();
|
return new Postgres9Platform();
|
||||||
|
|||||||
@@ -5,8 +5,14 @@ import io.ebean.config.PlatformConfig;
|
|||||||
import io.ebean.config.dbplatform.DatabasePlatform;
|
import io.ebean.config.dbplatform.DatabasePlatform;
|
||||||
import io.ebean.config.dbplatform.DbPlatformType;
|
import io.ebean.config.dbplatform.DbPlatformType;
|
||||||
import io.ebean.config.dbplatform.DbType;
|
import io.ebean.config.dbplatform.DbType;
|
||||||
|
import io.ebean.test.containers.PostgresContainer;
|
||||||
|
import org.junit.jupiter.api.Disabled;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DatabaseMetaData;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
import static io.ebean.Query.LockType.*;
|
import static io.ebean.Query.LockType.*;
|
||||||
import static io.ebean.Query.LockWait.*;
|
import static io.ebean.Query.LockWait.*;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
@@ -14,6 +20,38 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
|||||||
|
|
||||||
class PostgresPlatformTest {
|
class PostgresPlatformTest {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Let's just run this test manually.
|
||||||
|
*/
|
||||||
|
@Disabled
|
||||||
|
@Test
|
||||||
|
void platformDetection() throws SQLException {
|
||||||
|
PostgresContainer container = PostgresContainer.builder("15")
|
||||||
|
.containerName("pg15_ebeanTest")
|
||||||
|
.dbName("unit")
|
||||||
|
.port(0) // use a random port
|
||||||
|
.build();
|
||||||
|
|
||||||
|
container.startWithDropCreate();
|
||||||
|
|
||||||
|
try (Connection connection = container.createConnection()) {
|
||||||
|
connection.setAutoCommit(true);
|
||||||
|
DatabaseMetaData metaData = connection.getMetaData();
|
||||||
|
|
||||||
|
PostgresPlatformProvider platformProvider = new PostgresPlatformProvider();
|
||||||
|
|
||||||
|
DatabasePlatform platform = platformProvider.create(15, 0, metaData, connection);
|
||||||
|
assertThat(platform.name()).isEqualTo("postgres");
|
||||||
|
|
||||||
|
connection.setAutoCommit(false);
|
||||||
|
DatabasePlatform platform2 = platformProvider.create(15, 0, metaData, connection);
|
||||||
|
assertThat(platform2.name()).isEqualTo("postgres");
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
container.stopRemove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testUuidType() {
|
void testUuidType() {
|
||||||
PostgresPlatform platform = new PostgresPlatform();
|
PostgresPlatform platform = new PostgresPlatform();
|
||||||
|
|||||||
Reference in new issue
Block a user