mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-28 12:07:35 +01:00
Fixes BatchUpdateException: Subquery returns more than 1 row (#501):
- Added LIMIT 1 to all subqueries used in tables.
This commit is contained in:
parent
097958c416
commit
118cbe7ee7
@ -47,8 +47,8 @@ public class ServerTable extends Table {
|
||||
|
||||
public ServerTable(SQLDB db) {
|
||||
super("plan_servers", db);
|
||||
statementSelectServerID = "(" + Select.from(tableName, tableName + "." + columnServerID).where(columnServerUUID + "=?").toString() + ")";
|
||||
statementSelectServerNameID = "(" + Select.from(tableName, tableName + "." + columnServerName).where(columnServerID + "=?").toString() + ")";
|
||||
statementSelectServerID = "(" + Select.from(tableName, tableName + "." + columnServerID).where(columnServerUUID + "=?").toString() + " LIMIT 1)";
|
||||
statementSelectServerNameID = "(" + Select.from(tableName, tableName + "." + columnServerName).where(columnServerID + "=?").toString() + " LIMIT 1)";
|
||||
insertStatement = Insert.values(tableName,
|
||||
columnServerUUID,
|
||||
columnServerName,
|
||||
|
@ -29,7 +29,7 @@ public class UsersTable extends UserIDTable {
|
||||
|
||||
public UsersTable(SQLDB db) {
|
||||
super("plan_users", db);
|
||||
statementSelectID = "(" + Select.from(tableName, tableName + "." + columnID).where(columnUUID + "=?").toString() + ")";
|
||||
statementSelectID = "(" + Select.from(tableName, tableName + "." + columnID).where(columnUUID + "=?").toString() + " LIMIT 1)";
|
||||
insertStatement = Insert.values(tableName,
|
||||
columnUUID,
|
||||
columnRegistered,
|
||||
|
@ -31,7 +31,7 @@ public class WorldTable extends Table {
|
||||
|
||||
public WorldTable(SQLDB db) {
|
||||
super("plan_worlds", db);
|
||||
statementSelectID = "(SELECT " + columnWorldId + " FROM " + tableName + " WHERE (" + columnWorldName + "=?))";
|
||||
statementSelectID = "(SELECT " + columnWorldId + " FROM " + tableName + " WHERE (" + columnWorldName + "=?) LIMIT 1)";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -146,4 +146,22 @@ public class WorldTable extends Table {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Map<String, Integer> getWorldIds() throws SQLException {
|
||||
String sql = "SELECT DISTINCT " +
|
||||
columnWorldName + ", " +
|
||||
columnWorldId + " FROM " +
|
||||
tableName;
|
||||
|
||||
return query(new QueryAllStatement<Map<String, Integer>>(sql, 200) {
|
||||
@Override
|
||||
public Map<String, Integer> processResults(ResultSet set) throws SQLException {
|
||||
Map<String, Integer> worldIds = new HashMap<>();
|
||||
while (set.next()) {
|
||||
|
||||
}
|
||||
return worldIds;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user