-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathTransactionBasedMigrationContext.java
More file actions
66 lines (55 loc) · 1.55 KB
/
TransactionBasedMigrationContext.java
File metadata and controls
66 lines (55 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package io.ebean.migration.db;
import io.ebean.Database;
import io.ebean.Transaction;
import io.ebean.migration.MigrationConfig;
import io.ebean.migration.MigrationContext;
import java.sql.Connection;
import java.sql.SQLException;
/**
* A default implementation of the MigrationContext.
*
* @author Roland Praml, FOCONIS AG
*/
class TransactionBasedMigrationContext implements MigrationContextDb {
private final Transaction transaction;
private final String migrationPath;
private final String platform;
private final String basePlatform;
private final Database database;
TransactionBasedMigrationContext(MigrationConfig config, Transaction transaction, Database database) {
this.transaction = transaction;
this.migrationPath = config.getMigrationPath();
this.platform = config.getPlatform();
this.basePlatform = config.getBasePlatform();
this.database = database;
}
@Override
public Connection connection() {
return transaction.connection();
}
@Override
public String migrationPath() {
return migrationPath;
}
@Override
public String platform() {
return platform;
}
@Override
public String basePlatform() {
return basePlatform;
}
@Override
public void commit() throws SQLException {
// we must not use txn.commit here, as this closes the underlying connection, which is needed for logicalLock etc.
transaction.commitAndContinue();
}
@Override
public Transaction transaction() {
return transaction;
}
@Override
public Database database() {
return database;
}
}