Minimize SQL queries #74
@ -102,15 +102,10 @@ public class Schematic {
|
||||
|
||||
public static List<Schematic> getSchemsAccessibleByUser(int schemOwner){
|
||||
try{
|
||||
ResultSet schematic = SQL.select("SELECT SchemID, SchemName, SchemOwner, Item, SchemType, Rank, SchemFormat FROM Schematic WHERE SchemOwner = ? ORDER BY SchemName", schemOwner);
|
||||
ResultSet schematic = SQL.select("SELECT s.SchemID, s.SchemName, s.SchemOwner, s.Item, s.SchemType, s.Rank, s.SchemFormat FROM Schematic s LEFT JOIN SchemMember sm ON sm.SchemName = s.SchemName AND sm.SchemOwner = s.SchemOwner WHERE s.SchemOwner = ? OR sm.Member = ? ORDER BY s.SchemName", schemOwner, schemOwner);
|
||||
List<Schematic> schematics = new ArrayList<>();
|
||||
while(schematic.next()){
|
||||
while(schematic.next())
|
||||
schematics.add(new Schematic(schematic));
|
||||
}
|
||||
List<SchematicMember> addedSchems = SchematicMember.getAccessibleSchems(schemOwner);
|
||||
for(SchematicMember schem : addedSchems){
|
||||
schematics.add(getSchemFromDB(schem.getSchemName(), schem.getSchemOwner()));
|
||||
}
|
||||
return schematics;
|
||||
}catch(SQLException e){
|
||||
throw new SecurityException("Failed listing schematics", e);
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren