diff --git a/hsarback/src/de/hsadmin/mods/pac/PacModuleImpl.java b/hsarback/src/de/hsadmin/mods/pac/PacModuleImpl.java index adfbc60..8cad528 100644 --- a/hsarback/src/de/hsadmin/mods/pac/PacModuleImpl.java +++ b/hsarback/src/de/hsadmin/mods/pac/PacModuleImpl.java @@ -126,15 +126,25 @@ public class PacModuleImpl extends AbstractModuleImpl { } GenericModuleImpl helperModule = new GenericModuleImpl(getTransaction()); - Query qDoms = em.createQuery("SELECT dom FROM Domains dom WHERE dom.user.pac.name = :pac"); - qDoms.setParameter("pac", pacName); - List domsList = qDoms.getResultList(); - for (Object o : domsList) { - if (o instanceof Domain) { - helperModule.delete((AbstractEntity) o); + String[] dependQueries = new String[] { + "SELECT dom FROM Domains dom WHERE dom.user.pac.name = :pac", + "SELECT db FROM MySqlDatabases db WHERE db.pac.name = :pac", + "SELECT db FROM PgSqlDatabases db WHERE db.pac.name = :pac", + "SELECT dbusr FROM MySqlUsers dbusr WHERE dbusr.pac.name = :pac", + "SELECT dbusr FROM PgSqlUsers dbusr WHERE dbusr.pac.name = :pac", + }; + + for (String queryString : dependQueries) { + Query qDoms = em.createQuery(queryString); + qDoms.setParameter("pac", pacName); + List domsList = qDoms.getResultList(); + for (Object o : domsList) { + if (o instanceof AbstractEntity) { + helperModule.delete((AbstractEntity) o); + } } } - + for (UnixUser user : pac.getUnixUser()) { if (!pacName.equals(user.getName())) { helperModule.delete(user);