Always update then insert in case for whatever reason the zeroth schema version
is not one (like for ItemRecord).
This commit is contained in:
@@ -540,14 +540,16 @@ public class DepotMarshaller<T>
|
|||||||
protected void updateVersion (Connection conn, int version)
|
protected void updateVersion (Connection conn, int version)
|
||||||
throws SQLException
|
throws SQLException
|
||||||
{
|
{
|
||||||
String query = (version == 1) ?
|
String update = "update " + SCHEMA_VERSION_TABLE +
|
||||||
"insert into " + SCHEMA_VERSION_TABLE +
|
" set version = " + version +
|
||||||
" values('" + getTableName() + "', " + version + ")" :
|
|
||||||
"update " + SCHEMA_VERSION_TABLE + " set version = " + version +
|
|
||||||
" where persistentClass = '" + getTableName() + "'";
|
" where persistentClass = '" + getTableName() + "'";
|
||||||
|
String insert = "insert into " + SCHEMA_VERSION_TABLE +
|
||||||
|
" values('" + getTableName() + "', " + version + ")";
|
||||||
Statement stmt = conn.createStatement();
|
Statement stmt = conn.createStatement();
|
||||||
try {
|
try {
|
||||||
stmt.executeUpdate(query);
|
if (stmt.executeUpdate(update) == 0) {
|
||||||
|
stmt.executeUpdate(insert);
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
stmt.close();
|
stmt.close();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user