diff --git a/dbrepo-metadata-service/api/src/main/java/at/tuwien/api/database/DatabaseGiveAccessDto.java b/dbrepo-metadata-service/api/src/main/java/at/tuwien/api/database/DatabaseGiveAccessDto.java
index 5c161e7ae7ec85471d03f1b600e9cf300200d8c4..1b06d0209960353aa67d5e44d12d3997b69250d3 100644
--- a/dbrepo-metadata-service/api/src/main/java/at/tuwien/api/database/DatabaseGiveAccessDto.java
+++ b/dbrepo-metadata-service/api/src/main/java/at/tuwien/api/database/DatabaseGiveAccessDto.java
@@ -6,6 +6,8 @@ import jakarta.validation.constraints.NotBlank;
 import jakarta.validation.constraints.NotNull;
 import lombok.extern.jackson.Jacksonized;
 
+import java.util.UUID;
+
 @Getter
 @Setter
 @Builder
@@ -15,8 +17,8 @@ import lombok.extern.jackson.Jacksonized;
 @ToString
 public class DatabaseGiveAccessDto {
 
-    @NotBlank(message = "username is required")
-    private String username;
+    @NotBlank(message = "user id is required")
+    private UUID userId;
 
     @NotNull(message = "access type is required")
     private AccessTypeDto type;
diff --git a/dbrepo-metadata-service/entities/src/main/java/at/tuwien/entities/container/image/ContainerImage.java b/dbrepo-metadata-service/entities/src/main/java/at/tuwien/entities/container/image/ContainerImage.java
index ae9ab5fefc978e6eff278f2f2eedbe088e195e4b..7a1dfb9f0cf0f51d5ea368b1bdd2aec89dbee096 100644
--- a/dbrepo-metadata-service/entities/src/main/java/at/tuwien/entities/container/image/ContainerImage.java
+++ b/dbrepo-metadata-service/entities/src/main/java/at/tuwien/entities/container/image/ContainerImage.java
@@ -63,11 +63,4 @@ public class ContainerImage {
     @Column(columnDefinition = "TIMESTAMP")
     private Instant lastModified;
 
-    @PreRemove
-    public void preRemove() {
-        this.containers.forEach(container -> {
-            container.setImage(null);
-        });
-    }
-
 }
diff --git a/dbrepo-metadata-service/oai/src/main/java/at/tuwien/oaipmh/OaiListIdentifiersParameters.java b/dbrepo-metadata-service/oai/src/main/java/at/tuwien/oaipmh/OaiListIdentifiersParameters.java
index f08b1f6868e7e8517b55411636648b90ba0eabc7..721175ed17359a1f680931dee4ee763d6cf7dc9c 100644
--- a/dbrepo-metadata-service/oai/src/main/java/at/tuwien/oaipmh/OaiListIdentifiersParameters.java
+++ b/dbrepo-metadata-service/oai/src/main/java/at/tuwien/oaipmh/OaiListIdentifiersParameters.java
@@ -42,11 +42,11 @@ public class OaiListIdentifiersParameters extends RequestParameters {
     public String getParametersString() {
         StringBuilder builder = new StringBuilder();
         appendIfNotEmpty(builder, "verb", "ListIdentifiers");
-        appendIfNotEmpty(builder, "metadataPrefix", this.getMetadataPrefix());
-        appendIfNotEmpty(builder, "from", this.getFrom());
-        appendIfNotEmpty(builder, "until", this.getUntil());
-        appendIfNotEmpty(builder, "set", this.getSet());
-        appendIfNotEmpty(builder, "resumptionToken", this.getResumptionToken());
+        appendIfNotEmpty(builder, "metadataPrefix", metadataPrefix);
+        appendIfNotEmpty(builder, "from", from);
+        appendIfNotEmpty(builder, "until", until);
+        appendIfNotEmpty(builder, "set", set);
+        appendIfNotEmpty(builder, "resumptionToken", resumptionToken);
         return builder.toString();
     }
 
diff --git a/dbrepo-metadata-service/oai/src/main/java/at/tuwien/oaipmh/OaiListRecordsParameters.java b/dbrepo-metadata-service/oai/src/main/java/at/tuwien/oaipmh/OaiListRecordsParameters.java
index 0e540d71918ec83ef33321101da33925e0682227..a18f0b0aec1e50b8fd814e8221c15c89ff0cb8ab 100644
--- a/dbrepo-metadata-service/oai/src/main/java/at/tuwien/oaipmh/OaiListRecordsParameters.java
+++ b/dbrepo-metadata-service/oai/src/main/java/at/tuwien/oaipmh/OaiListRecordsParameters.java
@@ -42,11 +42,11 @@ public class OaiListRecordsParameters extends RequestParameters {
     public String getParametersString() {
         StringBuilder builder = new StringBuilder();
         appendIfNotEmpty(builder, "verb", "ListRecords");
-        appendIfNotEmpty(builder, "metadataPrefix", this.getMetadataPrefix());
-        appendIfNotEmpty(builder, "from", this.getFrom());
-        appendIfNotEmpty(builder, "until", this.getUntil());
-        appendIfNotEmpty(builder, "set", this.getSet());
-        appendIfNotEmpty(builder, "resumptionToken", this.getResumptionToken());
+        appendIfNotEmpty(builder, "metadataPrefix", metadataPrefix);
+        appendIfNotEmpty(builder, "from", from);
+        appendIfNotEmpty(builder, "until", until);
+        appendIfNotEmpty(builder, "set", set);
+        appendIfNotEmpty(builder, "resumptionToken", resumptionToken);
         return builder.toString();
     }
 
diff --git a/dbrepo-metadata-service/oai/src/main/java/at/tuwien/oaipmh/OaiRecordParameters.java b/dbrepo-metadata-service/oai/src/main/java/at/tuwien/oaipmh/OaiRecordParameters.java
index 3548fada79b436ca3d73c46b466ede9f2ef3e16e..da0433c0b67964af3d75c8dba5577f276c111bb5 100644
--- a/dbrepo-metadata-service/oai/src/main/java/at/tuwien/oaipmh/OaiRecordParameters.java
+++ b/dbrepo-metadata-service/oai/src/main/java/at/tuwien/oaipmh/OaiRecordParameters.java
@@ -17,8 +17,8 @@ public class OaiRecordParameters extends RequestParameters {
     public String getParametersString() {
         StringBuilder builder = new StringBuilder();
         appendIfNotEmpty(builder, "verb", "GetRecord");
-        appendIfNotEmpty(builder, "metadataPrefix", this.getMetadataPrefix());
-        appendIfNotEmpty(builder, "identifier", this.getIdentifier());
+        appendIfNotEmpty(builder, "metadataPrefix", metadataPrefix);
+        appendIfNotEmpty(builder, "identifier", identifier);
         return builder.toString();
     }
 
diff --git a/dbrepo-metadata-service/pom.xml b/dbrepo-metadata-service/pom.xml
index 729bd8df76fef5df25ff7ac510fed8fb37ae9496..5b1d35d5eb1738b9c8b5a543d1385ad31ed2e39d 100644
--- a/dbrepo-metadata-service/pom.xml
+++ b/dbrepo-metadata-service/pom.xml
@@ -26,6 +26,11 @@
             <email>moritz.staudinger@tuwien.ac.at</email>
             <organization>TU Wien</organization>
         </developer>
+        <developer>
+            <name>Tobias Grantner</name>
+            <email>tobias.grantner@tuwien.ac.at</email>
+            <organization>TU Wien</organization>
+        </developer>
     </developers>
 
     <packaging>pom</packaging>
diff --git a/dbrepo-metadata-service/repositories/src/main/java/at/tuwien/mapper/DatabaseMapper.java b/dbrepo-metadata-service/repositories/src/main/java/at/tuwien/mapper/DatabaseMapper.java
index 69a0a0b3c3bdde933ddb5d863e0d90619b4e9469..7b73daf49f5a8d45c05dd2d62cc0e32d480b377b 100644
--- a/dbrepo-metadata-service/repositories/src/main/java/at/tuwien/mapper/DatabaseMapper.java
+++ b/dbrepo-metadata-service/repositories/src/main/java/at/tuwien/mapper/DatabaseMapper.java
@@ -1,6 +1,5 @@
 package at.tuwien.mapper;
 
-import at.tuwien.api.auth.SignupRequestDto;
 import at.tuwien.api.database.*;
 import at.tuwien.api.user.UserDetailsDto;
 import at.tuwien.api.user.UserDto;
@@ -125,16 +124,16 @@ public interface DatabaseMapper {
         }
     }
 
-    default DatabaseGiveAccessDto databaseModifyAccessToDatabaseGiveAccessDto(String username, DatabaseModifyAccessDto data) {
+    default DatabaseGiveAccessDto databaseModifyAccessToDatabaseGiveAccessDto(UUID userId, AccessTypeDto type) {
         return DatabaseGiveAccessDto.builder()
-                .username(username)
-                .type(data.getType())
+                .userId(userId)
+                .type(type)
                 .build();
     }
 
-    default DatabaseGiveAccessDto databaseDefaultCreatorAccess(String username) {
+    default DatabaseGiveAccessDto databaseDefaultCreatorAccess(UUID userId) {
         return DatabaseGiveAccessDto.builder()
-                .username(username)
+                .userId(userId)
                 .type(AccessTypeDto.WRITE_ALL)
                 .build();
     }
@@ -165,10 +164,10 @@ public interface DatabaseMapper {
         }
     }
 
-    default PreparedStatement rawGrantUserAccessQuery(Connection connection, DatabaseGiveAccessDto data)
+    default PreparedStatement rawGrantUserAccessQuery(Connection connection, String username, AccessTypeDto type)
             throws QueryMalformedException {
         final StringBuilder statement = new StringBuilder("GRANT ");
-        switch (data.getType()) {
+        switch (type) {
             case READ:
                 statement.append("SELECT");
                 break;
@@ -178,9 +177,9 @@ public interface DatabaseMapper {
                 break;
         }
         statement.append(" ON *.* TO `")
-                .append(data.getUsername())
+                .append(username)
                 .append("`@`%`;");
-        log.debug("raw grant {} privileges statement [{}]", data.getType(), statement);
+        log.debug("raw grant {} privileges statement [{}]", type, statement);
         try {
             return connection.prepareStatement(statement.toString());
         } catch (SQLException e) {
diff --git a/dbrepo-metadata-service/repositories/src/main/java/at/tuwien/repository/mdb/DatabaseAccessRepository.java b/dbrepo-metadata-service/repositories/src/main/java/at/tuwien/repository/mdb/DatabaseAccessRepository.java
index 8dbd1e1f36d90053228c06c72a5c49b9a45b5ca4..68163e2829a66e6c793f7f1d2e595c450bf13ccb 100644
--- a/dbrepo-metadata-service/repositories/src/main/java/at/tuwien/repository/mdb/DatabaseAccessRepository.java
+++ b/dbrepo-metadata-service/repositories/src/main/java/at/tuwien/repository/mdb/DatabaseAccessRepository.java
@@ -27,7 +27,7 @@ public interface DatabaseAccessRepository extends JpaRepository<DatabaseAccess,
 
     List<DatabaseAccess> findByHdbid(Long databaseId);
 
-    @Query("select a from DatabaseAccess a where a.hdbid = :databaseId and a.user.username = :username")
-    Optional<DatabaseAccess> findByDatabaseIdAndUsername(Long databaseId, String username);
+    @Query("select a from DatabaseAccess a where a.hdbid = :databaseId and a.huserid = :userId")
+    Optional<DatabaseAccess> findByDatabaseIdAndUserId(Long databaseId, UUID userId);
 
 }
diff --git a/dbrepo-metadata-service/repositories/src/main/java/at/tuwien/repository/mdb/DatabaseRepository.java b/dbrepo-metadata-service/repositories/src/main/java/at/tuwien/repository/mdb/DatabaseRepository.java
index 301431e85fd7f3a19f1c7140745fbe7043063777..8a2929590da18931e612783a2b8c687fb87adb19 100644
--- a/dbrepo-metadata-service/repositories/src/main/java/at/tuwien/repository/mdb/DatabaseRepository.java
+++ b/dbrepo-metadata-service/repositories/src/main/java/at/tuwien/repository/mdb/DatabaseRepository.java
@@ -2,8 +2,6 @@ package at.tuwien.repository.mdb;
 
 import at.tuwien.entities.database.Database;
 import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.jpa.repository.Query;
-import org.springframework.data.repository.query.Param;
 import org.springframework.stereotype.Repository;
 
 import java.util.List;
@@ -23,10 +21,4 @@ public interface DatabaseRepository extends JpaRepository<Database, Long> {
 
     Optional<Database> findPublic(Long databaseId);
 
-    @Query("select d from Database d where d.id = :databaseId and (d.isPublic = true or d.creator.username = :username)")
-    Optional<Database> findPublicOrMine(@Param("databaseId") Long databaseId, @Param("username") String username);
-
-    @Query("select d from Database d where d.id = :databaseId")
-    Optional<Database> findByDatabaseId(@Param("databaseId") Long databaseId);
-
 }
diff --git a/dbrepo-metadata-service/rest-service/src/main/java/at/tuwien/endpoints/AccessEndpoint.java b/dbrepo-metadata-service/rest-service/src/main/java/at/tuwien/endpoints/AccessEndpoint.java
index 8ff3422edde26b02da9f04ae9a947999a599185a..bb0c34f05af04e0780baba15bc95bd63a7af10ef 100644
--- a/dbrepo-metadata-service/rest-service/src/main/java/at/tuwien/endpoints/AccessEndpoint.java
+++ b/dbrepo-metadata-service/rest-service/src/main/java/at/tuwien/endpoints/AccessEndpoint.java
@@ -8,6 +8,7 @@ import at.tuwien.entities.database.DatabaseAccess;
 import at.tuwien.exception.*;
 import at.tuwien.mapper.DatabaseMapper;
 import at.tuwien.service.AccessService;
+import at.tuwien.utils.UserUtil;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.media.Content;
 import io.swagger.v3.oas.annotations.media.Schema;
@@ -73,9 +74,9 @@ public class AccessEndpoint {
             DatabaseMalformedException, KeycloakRemoteException, AccessDeniedException {
         log.debug("endpoint give access to database, databaseId={}, accessDto={}, principal={}", databaseId, accessDto, principal);
         try {
-            accessService.find(databaseId, accessDto.getUsername());
-            log.error("Failed to give access to user with username {}, already has access", accessDto.getUsername());
-            throw new NotAllowedException("Failed to give access to user");
+            accessService.find(databaseId, accessDto.getUserId());
+            log.error("Failed to give access to user with id {}: already has access", accessDto.getUserId());
+            throw new NotAllowedException("Failed to give access to user with id " + accessDto.getUserId() + ": already has access");
         } catch (NotAllowedException e) {
             /* ignore */
         }
@@ -143,9 +144,10 @@ public class AccessEndpoint {
                             schema = @Schema(implementation = ApiErrorDto.class))}),
     })
     public ResponseEntity<DatabaseAccessDto> find(@NotBlank @PathVariable("id") Long databaseId,
-                                                  @NotNull Principal principal) throws NotAllowedException {
+                                                  @NotNull Principal principal) throws NotAllowedException,
+            AccessDeniedException {
         log.debug("endpoint check access to database, databaseId={}, principal={}", databaseId, principal);
-        final DatabaseAccess access = accessService.find(databaseId, principal.getName());
+        final DatabaseAccess access = accessService.find(databaseId, UserUtil.getId(principal));
         final DatabaseAccessDto dto = databaseMapper.databaseAccessToDatabaseAccessDto(access);
         log.trace("check access resulted in dto {}", dto);
         return ResponseEntity.ok(dto);
diff --git a/dbrepo-metadata-service/rest-service/src/main/java/at/tuwien/endpoints/QueryEndpoint.java b/dbrepo-metadata-service/rest-service/src/main/java/at/tuwien/endpoints/QueryEndpoint.java
index 53ccafd6f97fa567f2beeba042b582af77c1b148..65f4ca6ff63c1e92e4df314b1106ea3437649120 100644
--- a/dbrepo-metadata-service/rest-service/src/main/java/at/tuwien/endpoints/QueryEndpoint.java
+++ b/dbrepo-metadata-service/rest-service/src/main/java/at/tuwien/endpoints/QueryEndpoint.java
@@ -94,7 +94,7 @@ public class QueryEndpoint {
                                                     @RequestParam(required = false) String sortColumn)
             throws QueryStoreException, QueryNotFoundException, DatabaseNotFoundException, ImageNotSupportedException,
             QueryMalformedException, TableMalformedException, ColumnParseException, DatabaseConnectionException,
-            SortException, PaginationException, UserNotFoundException, NotAllowedException {
+            SortException, PaginationException, UserNotFoundException, NotAllowedException, AccessDeniedException {
         log.debug("endpoint re-execute query, databaseId={}, queryId={}, principal={}, page={}, size={}, sortDirection={}, sortColumn={}",
                 databaseId, queryId, principal, page, size, sortDirection, sortColumn);
         endpointValidator.validateDataParams(page, size, sortDirection, sortColumn);
@@ -118,7 +118,7 @@ public class QueryEndpoint {
                                                Principal principal)
             throws QueryStoreException, QueryNotFoundException, DatabaseNotFoundException, ImageNotSupportedException,
             QueryMalformedException, TableMalformedException, ColumnParseException, NotAllowedException,
-            DatabaseConnectionException, UserNotFoundException {
+            DatabaseConnectionException, UserNotFoundException, AccessDeniedException {
         log.debug("endpoint re-execute query count, databaseId={}, queryId={}, principal={}",
                 databaseId, queryId, principal);
         endpointValidator.validateOnlyAccessOrPublic(databaseId, queryId, principal);
diff --git a/dbrepo-metadata-service/rest-service/src/main/java/at/tuwien/endpoints/StoreEndpoint.java b/dbrepo-metadata-service/rest-service/src/main/java/at/tuwien/endpoints/StoreEndpoint.java
index 9f43e72caedb712835439ae17d255fded6525f27..a2792223e5ce200c7d1e516c199daf366d54e2bf 100644
--- a/dbrepo-metadata-service/rest-service/src/main/java/at/tuwien/endpoints/StoreEndpoint.java
+++ b/dbrepo-metadata-service/rest-service/src/main/java/at/tuwien/endpoints/StoreEndpoint.java
@@ -16,6 +16,7 @@ import at.tuwien.service.AccessService;
 import at.tuwien.service.IdentifierService;
 import at.tuwien.service.StoreService;
 import at.tuwien.service.UserService;
+import at.tuwien.utils.UserUtil;
 import at.tuwien.validation.EndpointValidator;
 import io.micrometer.core.annotation.Timed;
 import io.swagger.v3.oas.annotations.Operation;
@@ -45,7 +46,6 @@ import java.util.stream.Collectors;
 @RequestMapping("/api/database/{databaseId}/query")
 public class StoreEndpoint {
 
-    private final UserMapper userMapper;
     private final QueryMapper queryMapper;
     private final UserService userService;
     private final StoreService storeService;
@@ -55,10 +55,9 @@ public class StoreEndpoint {
     private final IdentifierService identifierService;
 
     @Autowired
-    public StoreEndpoint(UserMapper userMapper, QueryMapper queryMapper, UserService userService,
-                         StoreService storeService, AccessService accessService, IdentifierMapper identifierMapper,
+    public StoreEndpoint(QueryMapper queryMapper, UserService userService, StoreService storeService,
+                         AccessService accessService, IdentifierMapper identifierMapper,
                          EndpointValidator endpointValidator, IdentifierService identifierService) {
-        this.userMapper = userMapper;
         this.queryMapper = queryMapper;
         this.userService = userService;
         this.storeService = storeService;
@@ -113,7 +112,8 @@ public class StoreEndpoint {
                                                        @RequestParam(value = "persisted", required = false) Boolean persisted,
                                                        Principal principal) throws QueryStoreException,
             DatabaseNotFoundException, ImageNotSupportedException, ContainerNotFoundException,
-            DatabaseConnectionException, TableMalformedException, UserNotFoundException, NotAllowedException {
+            DatabaseConnectionException, TableMalformedException, UserNotFoundException, NotAllowedException,
+            AccessDeniedException {
         log.debug("endpoint list queries, databaseId={}, persisted={}, principal={}",
                 databaseId, persisted, principal);
         endpointValidator.validateOnlyAccessOrPublic(databaseId, principal);
@@ -247,7 +247,7 @@ public class StoreEndpoint {
             throw new QueryAlreadyPersistedException("Failed to persist");
         }
         /* has access */
-        accessService.find(databaseId, principal.getName());
+        accessService.find(databaseId, UserUtil.getId(principal));
         /* persist */
         final Query query = storeService.persist(databaseId, queryId, data);
         final QueryDto dto = queryMapper.queryToQueryDto(query);
diff --git a/dbrepo-metadata-service/rest-service/src/main/java/at/tuwien/endpoints/TableColumnEndpoint.java b/dbrepo-metadata-service/rest-service/src/main/java/at/tuwien/endpoints/TableColumnEndpoint.java
index 147dec6eb3bf33ae4ff373b0b304df86685a564b..5f6271a571465d2abde71c4b5d1f8009eeec2d2b 100644
--- a/dbrepo-metadata-service/rest-service/src/main/java/at/tuwien/endpoints/TableColumnEndpoint.java
+++ b/dbrepo-metadata-service/rest-service/src/main/java/at/tuwien/endpoints/TableColumnEndpoint.java
@@ -84,7 +84,7 @@ public class TableColumnEndpoint {
                                             @NotNull @RequestHeader("Authorization") String authorization)
             throws TableNotFoundException, TableMalformedException, DatabaseNotFoundException,
             ContainerNotFoundException, NotAllowedException, SemanticEntityPersistException,
-            SemanticEntityNotFoundException, QueryMalformedException {
+            SemanticEntityNotFoundException, QueryMalformedException, AccessDeniedException {
         log.debug("endpoint update table, id={}, tableId={}, principal={}", id, tableId, principal);
         if (!UserUtil.hasRole(principal, "modify-foreign-table-column-semantics")) {
             endpointValidator.validateOnlyAccess(id, principal, true);
diff --git a/dbrepo-metadata-service/rest-service/src/main/java/at/tuwien/endpoints/TableDataEndpoint.java b/dbrepo-metadata-service/rest-service/src/main/java/at/tuwien/endpoints/TableDataEndpoint.java
index 9552418e9a169ecf254281b11b42a2b131c682f7..7d27e09aded124f018e820f3a56b8f0db1380d45 100644
--- a/dbrepo-metadata-service/rest-service/src/main/java/at/tuwien/endpoints/TableDataEndpoint.java
+++ b/dbrepo-metadata-service/rest-service/src/main/java/at/tuwien/endpoints/TableDataEndpoint.java
@@ -56,7 +56,7 @@ public class TableDataEndpoint {
                                        @NotNull Principal principal)
             throws TableNotFoundException, DatabaseNotFoundException, TableMalformedException,
             ImageNotSupportedException, ContainerNotFoundException, DatabaseConnectionException, UserNotFoundException,
-            NotAllowedException {
+            NotAllowedException, AccessDeniedException {
         log.debug("endpoint insert data, databaseId={}, tableId={}, data={}, principal={}",
                 databaseId, tableId, data, principal);
         /* check */
@@ -79,7 +79,7 @@ public class TableDataEndpoint {
                                        @NotNull Principal principal)
             throws TableNotFoundException, DatabaseNotFoundException, TableMalformedException,
             ImageNotSupportedException, DatabaseConnectionException, QueryMalformedException,
-            UserNotFoundException, NotAllowedException {
+            UserNotFoundException, NotAllowedException, AccessDeniedException {
         log.debug("endpoint update data, databaseId={}, tableId={}, data={}, principal={}",
                 databaseId, tableId, data, principal);
         /* check */
@@ -101,7 +101,7 @@ public class TableDataEndpoint {
                                        @NotNull Principal principal)
             throws TableNotFoundException, DatabaseNotFoundException, TableMalformedException,
             ImageNotSupportedException, DatabaseConnectionException, QueryMalformedException, UserNotFoundException,
-            NotAllowedException {
+            NotAllowedException, AccessDeniedException {
         log.debug("endpoint delete data, databaseId={}, tableId={}, data={}, principal={}",
                 databaseId, tableId, data, principal);
         /* check */
@@ -123,7 +123,7 @@ public class TableDataEndpoint {
                                           @NotNull Principal principal)
             throws TableNotFoundException, DatabaseNotFoundException, TableMalformedException,
             ImageNotSupportedException, DatabaseConnectionException, QueryMalformedException, UserNotFoundException,
-            NotAllowedException {
+            NotAllowedException, AccessDeniedException {
         log.debug("endpoint insert data from csv, databaseId={}, tableId={}, data={}, principal={}",
                 databaseId, tableId, data, principal);
         /* check */
@@ -148,7 +148,7 @@ public class TableDataEndpoint {
                                                  @RequestParam(required = false) String sortColumn)
             throws TableNotFoundException, DatabaseNotFoundException, DatabaseConnectionException,
             ImageNotSupportedException, TableMalformedException, PaginationException, QueryMalformedException,
-            UserNotFoundException, SortException, NotAllowedException {
+            UserNotFoundException, SortException, NotAllowedException, AccessDeniedException {
         log.debug("endpoint find table data, databaseId={}, tableId={}, principal={}, timestamp={}, page={}, size={}, sortDirection={}, sortColumn={}",
                 databaseId, tableId, principal, timestamp, page, size, sortDirection, sortColumn);
         /* check */
@@ -176,7 +176,7 @@ public class TableDataEndpoint {
                                          @RequestParam(required = false) Instant timestamp)
             throws TableNotFoundException, DatabaseNotFoundException, DatabaseConnectionException,
             ImageNotSupportedException, TableMalformedException, QueryStoreException, QueryMalformedException,
-            UserNotFoundException, NotAllowedException {
+            UserNotFoundException, NotAllowedException, AccessDeniedException {
         log.debug("endpoint find table data, databaseId={}, tableId={}, principal={}, timestamp={}",
                 databaseId, tableId, principal, timestamp);
         /* check */
diff --git a/dbrepo-metadata-service/rest-service/src/main/java/at/tuwien/endpoints/TableEndpoint.java b/dbrepo-metadata-service/rest-service/src/main/java/at/tuwien/endpoints/TableEndpoint.java
index ce9df5f6e41d4df43497496d912c52b0ff625154..e353f83d42e9ccac08d3f40efa75972b67c3fcfd 100644
--- a/dbrepo-metadata-service/rest-service/src/main/java/at/tuwien/endpoints/TableEndpoint.java
+++ b/dbrepo-metadata-service/rest-service/src/main/java/at/tuwien/endpoints/TableEndpoint.java
@@ -75,7 +75,7 @@ public class TableEndpoint {
     })
     public ResponseEntity<List<TableBriefDto>> list(@NotNull @PathVariable("databaseId") Long databaseId,
                                                     Principal principal)
-            throws DatabaseNotFoundException, NotAllowedException {
+            throws DatabaseNotFoundException, NotAllowedException, AccessDeniedException {
         log.debug("endpoint list tables, databaseId={}, principal={}", databaseId, principal);
         endpointValidator.validateOnlyPrivateAccess(databaseId, principal);
         endpointValidator.validateOnlyPrivateHasRole(databaseId, principal, "list-tables");
@@ -134,7 +134,7 @@ public class TableEndpoint {
                                                 @NotNull Principal principal)
             throws ImageNotSupportedException, DatabaseNotFoundException, TableMalformedException, AmqpException,
             TableNameExistsException, ContainerNotFoundException, UserNotFoundException, QueryMalformedException,
-            NotAllowedException {
+            NotAllowedException, AccessDeniedException {
         log.debug("endpoint create table, databaseId={}, createDto={}, principal={}", databaseId, createDto, principal);
         endpointValidator.validateOnlyAccess(databaseId, principal, true);
         endpointValidator.validateColumnCreateConstraints(createDto);
diff --git a/dbrepo-metadata-service/rest-service/src/main/java/at/tuwien/validation/EndpointValidator.java b/dbrepo-metadata-service/rest-service/src/main/java/at/tuwien/validation/EndpointValidator.java
index 03dce82c02709e45b8a7af06543455bf0cdf0d61..6169e677d4ae1b2b3120262bc91235cb3c084380 100644
--- a/dbrepo-metadata-service/rest-service/src/main/java/at/tuwien/validation/EndpointValidator.java
+++ b/dbrepo-metadata-service/rest-service/src/main/java/at/tuwien/validation/EndpointValidator.java
@@ -47,7 +47,8 @@ public class EndpointValidator {
         this.tableService = tableService;
     }
 
-    public void validateOnlyPrivateAccess(Long databaseId, Principal principal, boolean writeAccessOnly) throws NotAllowedException, DatabaseNotFoundException {
+    public void validateOnlyPrivateAccess(Long databaseId, Principal principal, boolean writeAccessOnly)
+            throws NotAllowedException, DatabaseNotFoundException, AccessDeniedException {
         final Database database = databaseService.find(databaseId);
         if (database.getIsPublic()) {
             log.trace("database with id {} is public: no access needed", databaseId);
@@ -56,18 +57,20 @@ public class EndpointValidator {
         validateOnlyAccess(databaseId, principal, writeAccessOnly);
     }
 
-    public void validateOnlyPrivateAccess(Long databaseId, Principal principal) throws NotAllowedException, DatabaseNotFoundException {
+    public void validateOnlyPrivateAccess(Long databaseId, Principal principal) throws NotAllowedException,
+            DatabaseNotFoundException, AccessDeniedException {
         validateOnlyPrivateAccess(databaseId, principal, false);
     }
 
-    public void validateOnlyAccess(Long databaseId, Principal principal, boolean writeAccessOnly) throws NotAllowedException, DatabaseNotFoundException {
+    public void validateOnlyAccess(Long databaseId, Principal principal, boolean writeAccessOnly)
+            throws NotAllowedException, DatabaseNotFoundException, AccessDeniedException {
         if (principal == null) {
             log.error("Access not allowed: database with id {} is not public and no authorization provided", databaseId);
             throw new NotAllowedException("Access not allowed: database with id " + databaseId + " is not public and no authorization provided");
         }
         databaseService.find(databaseId);
         log.trace("principal: {}", principal.getName());
-        final DatabaseAccess access = accessService.find(databaseId, principal.getName());
+        final DatabaseAccess access = accessService.find(databaseId, UserUtil.getId(principal));
         log.trace("found access: {}", access);
         if (writeAccessOnly && !(access.getType().equals(AccessType.WRITE_OWN) || access.getType().equals(AccessType.WRITE_ALL))) {
             log.error("Access not allowed: no write access");
@@ -130,7 +133,7 @@ public class EndpointValidator {
     }
 
     public void validateOnlyOwnerOrWriteAll(Long databaseId, Long tableId, Principal principal)
-            throws DatabaseNotFoundException, NotAllowedException, TableNotFoundException {
+            throws DatabaseNotFoundException, NotAllowedException, TableNotFoundException, AccessDeniedException {
         if (principal == null) {
             log.error("Access not allowed: no authorization provided");
             throw new NotAllowedException("Access not allowed: no authorization provided");
@@ -138,7 +141,7 @@ public class EndpointValidator {
         final Table table = tableService.findById(databaseId, tableId);
         log.trace("principal: {}", principal.getName());
         log.trace("table creator: {}", table.getCreatedBy());
-        final DatabaseAccess access = accessService.find(databaseId, principal.getName());
+        final DatabaseAccess access = accessService.find(databaseId, UserUtil.getId(principal));
         log.trace("found access {}", access);
         if (access.getType().equals(AccessType.READ)) {
             log.error("Access not allowed: insufficient access (only read-access)");
@@ -226,7 +229,7 @@ public class EndpointValidator {
     }
 
     public void validateOnlyAccessOrPublic(Long databaseId, Principal principal)
-            throws DatabaseNotFoundException, NotAllowedException {
+            throws DatabaseNotFoundException, NotAllowedException, AccessDeniedException {
         final Database database = databaseService.find(databaseId);
         if (database.getIsPublic()) {
             log.trace("database with id {} is public: no access needed", databaseId);
@@ -238,12 +241,12 @@ public class EndpointValidator {
             throw new NotAllowedException("Access not allowed: database with id " + databaseId + " is not public and no authorization provided");
         }
         log.trace("principal is {}", principal);
-        final DatabaseAccess access = accessService.find(databaseId, principal.getName());
+        final DatabaseAccess access = accessService.find(databaseId, UserUtil.getId(principal));
         log.trace("found access {}", access);
     }
 
     public void validateOnlyAccessOrPublic(Long databaseId, Long queryId, Principal principal)
-            throws NotAllowedException, DatabaseNotFoundException {
+            throws NotAllowedException, DatabaseNotFoundException, AccessDeniedException {
         final Optional<Identifier> optional = identifierRepository.findSubsetIdentifier(databaseId, queryId);
         if (optional.isPresent()) {
             final Identifier identifier = optional.get();
@@ -266,14 +269,14 @@ public class EndpointValidator {
     }
 
     public void validateOnlyWriteOwnOrWriteAllAccess(Long databaseId, Long tableId, Principal principal)
-            throws DatabaseNotFoundException, TableNotFoundException, NotAllowedException {
+            throws DatabaseNotFoundException, TableNotFoundException, NotAllowedException, AccessDeniedException {
         final Table table = tableService.find(databaseId, tableId);
         if (principal == null) {
             log.error("Access not allowed: no authorization provided");
             throw new NotAllowedException("Access not allowed: no authorization provided");
         }
         log.trace("principal is {}", principal);
-        final DatabaseAccess access = accessService.find(databaseId, principal.getName());
+        final DatabaseAccess access = accessService.find(databaseId, UserUtil.getId(principal));
         log.trace("found access {}", access);
         if (access.getType().equals(AccessType.WRITE_ALL)) {
             log.debug("user {} has write-all access, skip.", principal.getName());
diff --git a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/config/MariaDbConfig.java b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/config/MariaDbConfig.java
index 4e5be3249ad93271c23784a08540e99860fca2e7..bcf8c86eb11679f8e0fd3b27d99f38354f1d1d91 100644
--- a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/config/MariaDbConfig.java
+++ b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/config/MariaDbConfig.java
@@ -17,10 +17,7 @@ import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
 
 import java.sql.*;
 import java.time.Instant;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -122,16 +119,16 @@ public class MariaDbConfig {
         }
     }
 
-    public void mockGrantUserPermissions(Container container, Database database, String username) throws SQLException,
+    public void mockGrantUserPermissions(Container container, Database database, String username, UUID userId) throws SQLException,
             QueryMalformedException {
         final String jdbc = "jdbc:mariadb://" + container.getHost() + ":" + container.getPort() + "/" + database.getInternalName();
         log.trace("connect to database {}", jdbc);
         try (Connection connection = DriverManager.getConnection(jdbc, container.getPrivilegedUsername(), container.getPrivilegedPassword())) {
             final DatabaseGiveAccessDto access = DatabaseGiveAccessDto.builder()
-                    .username(username)
+                    .userId(userId)
                     .type(AccessTypeDto.WRITE_ALL)
                     .build();
-            final PreparedStatement statement1 = databaseMapper.rawGrantUserAccessQuery(connection, access);
+            final PreparedStatement statement1 = databaseMapper.rawGrantUserAccessQuery(connection, username, AccessTypeDto.WRITE_ALL);
             statement1.executeUpdate();
             final PreparedStatement statement2 = databaseMapper.rawGrantUserProcedure(connection, username);
             statement2.executeUpdate();
diff --git a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/AccessEndpointUnitTest.java b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/AccessEndpointUnitTest.java
index fec328ef2b8e01208ba7935a3cbc04d73d20a3e3..33020d8f9038576e2824e0361b510659f8630d21 100644
--- a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/AccessEndpointUnitTest.java
+++ b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/AccessEndpointUnitTest.java
@@ -58,7 +58,7 @@ public class AccessEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(org.springframework.security.access.AccessDeniedException.class, () -> {
-            generic_create(DATABASE_1_ID, DATABASE_1, null, USER_2_USERNAME, null);
+            generic_create(DATABASE_1_ID, DATABASE_1, null, USER_2_ID, null);
         });
     }
 
@@ -68,7 +68,7 @@ public class AccessEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(org.springframework.security.access.AccessDeniedException.class, () -> {
-            generic_create(DATABASE_1_ID, DATABASE_1, null, USER_4_USERNAME, USER_4_PRINCIPAL);
+            generic_create(DATABASE_1_ID, DATABASE_1, null, USER_4_ID, USER_4_PRINCIPAL);
         });
     }
 
@@ -83,7 +83,7 @@ public class AccessEndpointUnitTest extends BaseUnitTest {
                 .create(eq(DATABASE_1_ID), any(DatabaseGiveAccessDto.class));
 
         /* test */
-        generic_create(DATABASE_1_ID, DATABASE_1, null, USER_2_USERNAME, USER_1_PRINCIPAL);
+        generic_create(DATABASE_1_ID, DATABASE_1, null, USER_2_ID, USER_1_PRINCIPAL);
     }
 
     @Test
@@ -196,12 +196,12 @@ public class AccessEndpointUnitTest extends BaseUnitTest {
     /* ## GENERIC TEST CASES                                                                            ## */
     /* ################################################################################################### */
 
-    protected void generic_create(Long databaseId, Database database, DatabaseAccess access, String username,
+    protected void generic_create(Long databaseId, Database database, DatabaseAccess access, UUID userId,
                                   Principal principal) throws UserNotFoundException, QueryMalformedException,
             DatabaseNotFoundException, DatabaseMalformedException, NotAllowedException, KeycloakRemoteException,
             AccessDeniedException {
         final DatabaseGiveAccessDto request = DatabaseGiveAccessDto.builder()
-                .username(username)
+                .userId(userId)
                 .type(AccessTypeDto.READ)
                 .build();
 
@@ -209,14 +209,14 @@ public class AccessEndpointUnitTest extends BaseUnitTest {
         when(databaseRepository.findById(databaseId))
                 .thenReturn(Optional.of(database));
         if (access != null) {
-            log.trace("mock access {} for user with username {} for database with id {}", access.getType(), username, databaseId);
-            when(accessService.find(databaseId, username))
+            log.trace("mock access {} for user with id {} for database with id {}", access.getType(), userId, databaseId);
+            when(accessService.find(databaseId, userId))
                     .thenReturn(access);
         } else {
-            log.trace("mock no access for user with username {} for database with id {}", username, databaseId);
+            log.trace("mock no access for user with id {} for database with id {}", userId, databaseId);
             doThrow(NotAllowedException.class)
                     .when(accessService)
-                    .find(databaseId, username);
+                    .find(databaseId, userId);
         }
 
         /* test */
diff --git a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/ExportEndpointUnitTest.java b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/ExportEndpointUnitTest.java
index c3a2c82c8605a5bae9d6f46053a88c804a53d081..115129991025b0146d9add251530991c851fbd15 100644
--- a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/ExportEndpointUnitTest.java
+++ b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/ExportEndpointUnitTest.java
@@ -7,14 +7,10 @@ import at.tuwien.annotations.MockOpensearch;
 import at.tuwien.entities.database.Database;
 import at.tuwien.entities.database.DatabaseAccess;
 import at.tuwien.exception.*;
-import at.tuwien.gateway.BrokerServiceGateway;
-import at.tuwien.listener.impl.RabbitMqListenerImpl;
 import at.tuwien.repository.mdb.DatabaseAccessRepository;
 import at.tuwien.repository.mdb.TableRepository;
-import at.tuwien.repository.sdb.ViewIdxRepository;
 import at.tuwien.service.DatabaseService;
 import at.tuwien.service.QueryService;
-import com.rabbitmq.client.Channel;
 import lombok.extern.log4j.Log4j2;
 import org.apache.commons.io.FileUtils;
 import org.junit.jupiter.api.Test;
@@ -35,6 +31,7 @@ import java.security.Principal;
 import java.time.Instant;
 import java.time.temporal.ChronoUnit;
 import java.util.Optional;
+import java.util.UUID;
 
 import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.Mockito.when;
@@ -75,22 +72,20 @@ public class ExportEndpointUnitTest extends BaseUnitTest {
     @WithMockUser(username = USER_1_USERNAME, authorities = {"export-table-data"})
     public void export_publicHasRoleNoAccess_succeeds() throws TableNotFoundException, DatabaseConnectionException,
             TableMalformedException, DatabaseNotFoundException, ImageNotSupportedException, FileStorageException,
-            PaginationException, ContainerNotFoundException, NotAllowedException, QueryMalformedException,
-            UserNotFoundException, IOException {
+            PaginationException, NotAllowedException, QueryMalformedException, UserNotFoundException, IOException {
 
         /* test */
-        export_generic(DATABASE_1_ID, TABLE_1_ID, DATABASE_1, null, USER_1_PRINCIPAL, USER_1_USERNAME, null);
+        export_generic(DATABASE_1_ID, TABLE_1_ID, DATABASE_1, null, USER_1_PRINCIPAL, USER_1_ID, null);
     }
 
     @Test
     @WithMockUser(username = USER_1_USERNAME, authorities = {"export-table-data"})
     public void export_publicHasRoleReadAccess_succeeds() throws TableNotFoundException, DatabaseConnectionException,
             TableMalformedException, DatabaseNotFoundException, ImageNotSupportedException, FileStorageException,
-            PaginationException, ContainerNotFoundException, NotAllowedException, QueryMalformedException,
-            UserNotFoundException, IOException {
+            PaginationException, NotAllowedException, QueryMalformedException, UserNotFoundException, IOException {
 
         /* test */
-        export_generic(DATABASE_1_ID, TABLE_1_ID, DATABASE_1, null, USER_1_PRINCIPAL, USER_1_USERNAME, DATABASE_1_USER_1_READ_ACCESS);
+        export_generic(DATABASE_1_ID, TABLE_1_ID, DATABASE_1, null, USER_1_PRINCIPAL, USER_1_ID, DATABASE_1_USER_1_READ_ACCESS);
     }
 
     @Test
@@ -132,46 +127,42 @@ public class ExportEndpointUnitTest extends BaseUnitTest {
     @WithMockUser(username = USER_2_USERNAME, authorities = {"export-table-data"})
     public void export_privateHasRoleNoAccess_fails() throws TableNotFoundException, DatabaseConnectionException,
             TableMalformedException, DatabaseNotFoundException, ImageNotSupportedException, FileStorageException,
-            PaginationException, ContainerNotFoundException, NotAllowedException, QueryMalformedException,
-            UserNotFoundException, IOException {
+            PaginationException, NotAllowedException, QueryMalformedException, UserNotFoundException, IOException {
 
         /* test */
-        export_generic(DATABASE_2_ID, TABLE_1_ID, DATABASE_2, null, USER_2_PRINCIPAL, USER_2_USERNAME, null);
+        export_generic(DATABASE_2_ID, TABLE_1_ID, DATABASE_2, null, USER_2_PRINCIPAL, USER_2_ID, null);
     }
 
     @Test
     @WithMockUser(username = USER_2_USERNAME, authorities = {"export-table-data"})
     public void export_HasRoleReadAccess_succeeds() throws TableNotFoundException, DatabaseConnectionException,
             TableMalformedException, DatabaseNotFoundException, ImageNotSupportedException, FileStorageException,
-            PaginationException, ContainerNotFoundException, NotAllowedException, QueryMalformedException,
-            UserNotFoundException, IOException {
+            PaginationException, NotAllowedException, QueryMalformedException, UserNotFoundException, IOException {
 
         /* test */
-        export_generic(DATABASE_2_ID, TABLE_1_ID, DATABASE_2, null, USER_2_PRINCIPAL, USER_2_USERNAME, DATABASE_2_USER_1_WRITE_OWN_ACCESS);
+        export_generic(DATABASE_2_ID, TABLE_1_ID, DATABASE_2, null, USER_2_PRINCIPAL, USER_2_ID, DATABASE_2_USER_1_WRITE_OWN_ACCESS);
     }
 
     @Test
     @WithMockUser(username = USER_2_USERNAME, authorities = {"export-table-data"})
     public void export_privateReadWithTimestamp_succeeds() throws TableNotFoundException, DatabaseConnectionException,
             TableMalformedException, DatabaseNotFoundException, ImageNotSupportedException, FileStorageException,
-            PaginationException, ContainerNotFoundException, NotAllowedException, QueryMalformedException,
-            UserNotFoundException, IOException {
+            PaginationException, NotAllowedException, QueryMalformedException, UserNotFoundException, IOException {
         final Instant timestamp = Instant.now();
 
         /* test */
-        export_generic(DATABASE_2_ID, TABLE_1_ID, DATABASE_2, timestamp, USER_2_PRINCIPAL, USER_2_USERNAME, DATABASE_2_USER_1_READ_ACCESS);
+        export_generic(DATABASE_2_ID, TABLE_1_ID, DATABASE_2, timestamp, USER_2_PRINCIPAL, USER_2_ID, DATABASE_2_USER_1_READ_ACCESS);
     }
 
     @Test
     @WithMockUser(username = USER_2_USERNAME, authorities = {"export-table-data"})
     public void export_privateReadWithTimestampInFuture_succeeds() throws TableNotFoundException, DatabaseConnectionException,
             TableMalformedException, DatabaseNotFoundException, ImageNotSupportedException, FileStorageException,
-            PaginationException, ContainerNotFoundException, NotAllowedException, QueryMalformedException,
-            UserNotFoundException, IOException {
+            PaginationException, NotAllowedException, QueryMalformedException, UserNotFoundException, IOException {
         final Instant timestamp = Instant.now().plus(10, ChronoUnit.DAYS);
 
         /* test */
-        export_generic(DATABASE_2_ID, TABLE_1_ID, DATABASE_2, timestamp, USER_2_PRINCIPAL, USER_2_USERNAME, DATABASE_2_USER_1_READ_ACCESS);
+        export_generic(DATABASE_2_ID, TABLE_1_ID, DATABASE_2, timestamp, USER_2_PRINCIPAL, USER_2_ID, DATABASE_2_USER_1_READ_ACCESS);
     }
 
     /* ################################################################################################### */
@@ -179,10 +170,10 @@ public class ExportEndpointUnitTest extends BaseUnitTest {
     /* ################################################################################################### */
 
     protected void export_generic(Long databaseId, Long tableId, Database database, Instant timestamp,
-                                  Principal principal, String username, DatabaseAccess access) throws IOException,
+                                  Principal principal, UUID userId, DatabaseAccess access) throws IOException,
             DatabaseNotFoundException, UserNotFoundException, TableNotFoundException, DatabaseConnectionException,
             TableMalformedException, QueryMalformedException, ImageNotSupportedException, FileStorageException,
-            PaginationException, ContainerNotFoundException, NotAllowedException {
+            PaginationException, NotAllowedException {
         final ExportResource resource = ExportResource.builder()
                 .filename("location.csv")
                 .resource(new InputStreamResource(FileUtils.openInputStream(new File("src/test/resources/weather/location.csv"))))
@@ -192,10 +183,10 @@ public class ExportEndpointUnitTest extends BaseUnitTest {
         when(databaseService.find(databaseId))
                 .thenReturn(database);
         if (access == null) {
-            when(databaseAccessRepository.findByDatabaseIdAndUsername(databaseId, username))
+            when(databaseAccessRepository.findByDatabaseIdAndUserId(databaseId, userId))
                     .thenReturn(Optional.empty());
         } else {
-            when(databaseAccessRepository.findByDatabaseIdAndUsername(databaseId, username))
+            when(databaseAccessRepository.findByDatabaseIdAndUserId(databaseId, userId))
                     .thenReturn(Optional.of(access));
         }
         when(tableRepository.find(databaseId, tableId))
diff --git a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/QueryEndpointUnitTest.java b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/QueryEndpointUnitTest.java
index ab03b010effa5a844d0fb0dbff7a6a6ce01a4832..818594023d516144d6d1113c219f1e01d24573df 100644
--- a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/QueryEndpointUnitTest.java
+++ b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/QueryEndpointUnitTest.java
@@ -36,6 +36,7 @@ import java.io.File;
 import java.io.IOException;
 import java.security.Principal;
 import java.util.Optional;
+import java.util.UUID;
 
 import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.Mockito.when;
@@ -86,7 +87,7 @@ public class QueryEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(QueryMalformedException.class, () -> {
-            generic_execute(DATABASE_3_ID, statement, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_3, DATABASE_3_USER_2_READ_ACCESS);
+            generic_execute(DATABASE_3_ID, statement, USER_2_ID, USER_2_PRINCIPAL, DATABASE_3, DATABASE_3_USER_2_READ_ACCESS);
         });
     }
 
@@ -97,7 +98,7 @@ public class QueryEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(QueryMalformedException.class, () -> {
-            generic_execute(DATABASE_3_ID, statement, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_3, DATABASE_3_USER_2_READ_ACCESS);
+            generic_execute(DATABASE_3_ID, statement, USER_2_ID, USER_2_PRINCIPAL, DATABASE_3, DATABASE_3_USER_2_READ_ACCESS);
         });
     }
 
@@ -141,7 +142,7 @@ public class QueryEndpointUnitTest extends BaseUnitTest {
             KeycloakRemoteException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        generic_execute(DATABASE_3_ID, QUERY_4_STATEMENT, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_3, DATABASE_3_USER_2_WRITE_ALL_ACCESS);
+        generic_execute(DATABASE_3_ID, QUERY_4_STATEMENT, USER_2_ID, USER_2_PRINCIPAL, DATABASE_3, DATABASE_3_USER_2_WRITE_ALL_ACCESS);
     }
 
     @Test
@@ -152,7 +153,7 @@ public class QueryEndpointUnitTest extends BaseUnitTest {
             KeycloakRemoteException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        generic_execute(DATABASE_3_ID, QUERY_4_STATEMENT, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_3, DATABASE_3_USER_2_WRITE_ALL_ACCESS);
+        generic_execute(DATABASE_3_ID, QUERY_4_STATEMENT, USER_2_ID, USER_2_PRINCIPAL, DATABASE_3, DATABASE_3_USER_2_WRITE_ALL_ACCESS);
     }
 
     @Test
@@ -163,7 +164,7 @@ public class QueryEndpointUnitTest extends BaseUnitTest {
             KeycloakRemoteException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        generic_execute(DATABASE_3_ID, QUERY_4_STATEMENT, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_3, DATABASE_3_USER_2_WRITE_ALL_ACCESS);
+        generic_execute(DATABASE_3_ID, QUERY_4_STATEMENT, USER_2_ID, USER_2_PRINCIPAL, DATABASE_3, DATABASE_3_USER_2_WRITE_ALL_ACCESS);
     }
 
     @Test
@@ -174,7 +175,7 @@ public class QueryEndpointUnitTest extends BaseUnitTest {
             KeycloakRemoteException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        generic_execute(DATABASE_3_ID, QUERY_4_STATEMENT, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_3, DATABASE_3_USER_2_WRITE_ALL_ACCESS);
+        generic_execute(DATABASE_3_ID, QUERY_4_STATEMENT, USER_2_ID, USER_2_PRINCIPAL, DATABASE_3, DATABASE_3_USER_2_WRITE_ALL_ACCESS);
     }
 
     @Test
@@ -182,7 +183,7 @@ public class QueryEndpointUnitTest extends BaseUnitTest {
     public void reExecute_publicAnonymized_succeeds() throws UserNotFoundException, QueryStoreException, SortException,
             DatabaseConnectionException, TableMalformedException, NotAllowedException, QueryMalformedException,
             QueryNotFoundException, ColumnParseException, DatabaseNotFoundException, ImageNotSupportedException,
-            PaginationException {
+            PaginationException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
         generic_reExecute(DATABASE_3_ID, QUERY_4_ID, QUERY_4, QUERY_4_RESULT_ID, QUERY_4_RESULT_DTO,
@@ -194,11 +195,11 @@ public class QueryEndpointUnitTest extends BaseUnitTest {
     public void reExecute_publicRead_succeeds() throws UserNotFoundException, QueryStoreException, TableMalformedException,
             DatabaseConnectionException, QueryMalformedException, ColumnParseException, DatabaseNotFoundException,
             ImageNotSupportedException, SortException, NotAllowedException,
-            PaginationException, QueryNotFoundException {
+            PaginationException, QueryNotFoundException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
         generic_reExecute(DATABASE_3_ID, QUERY_4_ID, QUERY_4, QUERY_4_RESULT_ID, QUERY_4_RESULT_DTO,
-                USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_3, DATABASE_3_USER_1_READ_ACCESS);
+                USER_2_ID, USER_2_PRINCIPAL, DATABASE_3, DATABASE_3_USER_1_READ_ACCESS);
     }
 
     @Test
@@ -206,11 +207,11 @@ public class QueryEndpointUnitTest extends BaseUnitTest {
     public void reExecute_public_succeeds() throws UserNotFoundException, QueryStoreException, TableMalformedException,
             DatabaseConnectionException, QueryMalformedException, ColumnParseException, DatabaseNotFoundException,
             ImageNotSupportedException, SortException, NotAllowedException,
-            PaginationException, QueryNotFoundException {
+            PaginationException, QueryNotFoundException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
         generic_reExecute(DATABASE_3_ID, QUERY_4_ID, QUERY_4, QUERY_4_RESULT_ID, QUERY_4_RESULT_DTO,
-                USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_3, DATABASE_3_USER_1_WRITE_OWN_ACCESS);
+                USER_2_ID, USER_2_PRINCIPAL, DATABASE_3, DATABASE_3_USER_1_WRITE_OWN_ACCESS);
     }
 
     @Test
@@ -218,7 +219,7 @@ public class QueryEndpointUnitTest extends BaseUnitTest {
     public void export_publicAnonymized_succeeds() throws UserNotFoundException, QueryStoreException,
             TableMalformedException, DatabaseConnectionException, QueryMalformedException, DatabaseNotFoundException,
             ImageNotSupportedException, QueryNotFoundException, FileStorageException,
-            ContainerNotFoundException, IOException, NotAllowedException {
+            IOException, NotAllowedException {
 
         /* test */
         export_generic(DATABASE_3_ID, QUERY_3_ID, null, null, DATABASE_3, null, null, HttpStatus.OK);
@@ -237,10 +238,10 @@ public class QueryEndpointUnitTest extends BaseUnitTest {
     public void export_publicRead_succeeds() throws UserNotFoundException, QueryStoreException,
             TableMalformedException, DatabaseConnectionException, QueryMalformedException, DatabaseNotFoundException,
             ImageNotSupportedException, QueryNotFoundException, FileStorageException,
-            ContainerNotFoundException, IOException, NotAllowedException {
+             IOException, NotAllowedException {
 
         /* test */
-        export_generic(DATABASE_3_ID, QUERY_3_ID, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_3, DATABASE_3_USER_1_READ_ACCESS, null, HttpStatus.OK);
+        export_generic(DATABASE_3_ID, QUERY_3_ID, USER_2_ID, USER_2_PRINCIPAL, DATABASE_3, DATABASE_3_USER_1_READ_ACCESS, null, HttpStatus.OK);
     }
 
     @Test
@@ -248,10 +249,10 @@ public class QueryEndpointUnitTest extends BaseUnitTest {
     public void export_publicWriteOwn_succeeds() throws UserNotFoundException, QueryStoreException,
             TableMalformedException, DatabaseConnectionException, QueryMalformedException, DatabaseNotFoundException,
             ImageNotSupportedException, QueryNotFoundException, FileStorageException,
-            ContainerNotFoundException, IOException, NotAllowedException {
+            IOException, NotAllowedException {
 
         /* test */
-        export_generic(DATABASE_3_ID, QUERY_4_ID, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_3, DATABASE_3_USER_1_WRITE_OWN_ACCESS, null, HttpStatus.OK);
+        export_generic(DATABASE_3_ID, QUERY_4_ID, USER_2_ID, USER_2_PRINCIPAL, DATABASE_3, DATABASE_3_USER_1_WRITE_OWN_ACCESS, null, HttpStatus.OK);
     }
 
     @Test
@@ -259,10 +260,10 @@ public class QueryEndpointUnitTest extends BaseUnitTest {
     public void export_publicWriteAll_succeeds() throws UserNotFoundException, QueryStoreException,
             TableMalformedException, DatabaseConnectionException, QueryMalformedException, DatabaseNotFoundException,
             ImageNotSupportedException, QueryNotFoundException, FileStorageException,
-            ContainerNotFoundException, IOException, NotAllowedException {
+            IOException, NotAllowedException {
 
         /* test */
-        export_generic(DATABASE_3_ID, QUERY_4_ID, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_3, DATABASE_3_USER_1_WRITE_ALL_ACCESS, null, HttpStatus.OK);
+        export_generic(DATABASE_3_ID, QUERY_4_ID, USER_2_ID, USER_2_PRINCIPAL, DATABASE_3, DATABASE_3_USER_1_WRITE_ALL_ACCESS, null, HttpStatus.OK);
     }
 
     /* ################################################################################################### */
@@ -288,7 +289,7 @@ public class QueryEndpointUnitTest extends BaseUnitTest {
             KeycloakRemoteException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        generic_execute(DATABASE_2_ID, QUERY_1_STATEMENT, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_2, DATABASE_2_USER_1_READ_ACCESS);
+        generic_execute(DATABASE_2_ID, QUERY_1_STATEMENT, USER_2_ID, USER_2_PRINCIPAL, DATABASE_2, DATABASE_2_USER_1_READ_ACCESS);
     }
 
     @Test
@@ -299,7 +300,7 @@ public class QueryEndpointUnitTest extends BaseUnitTest {
             KeycloakRemoteException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        generic_execute(DATABASE_2_ID, QUERY_1_STATEMENT, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_2, DATABASE_2_USER_1_WRITE_OWN_ACCESS);
+        generic_execute(DATABASE_2_ID, QUERY_1_STATEMENT, USER_2_ID, USER_2_PRINCIPAL, DATABASE_2, DATABASE_2_USER_1_WRITE_OWN_ACCESS);
     }
 
     @Test
@@ -310,7 +311,7 @@ public class QueryEndpointUnitTest extends BaseUnitTest {
             KeycloakRemoteException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        generic_execute(DATABASE_2_ID, QUERY_1_STATEMENT, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_2, DATABASE_2_USER_1_WRITE_ALL_ACCESS);
+        generic_execute(DATABASE_2_ID, QUERY_1_STATEMENT, USER_2_ID, USER_2_PRINCIPAL, DATABASE_2, DATABASE_2_USER_1_WRITE_ALL_ACCESS);
     }
 
     @Test
@@ -321,7 +322,7 @@ public class QueryEndpointUnitTest extends BaseUnitTest {
             KeycloakRemoteException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        generic_execute(DATABASE_2_ID, QUERY_1_STATEMENT, USER_1_USERNAME, USER_1_PRINCIPAL, DATABASE_2, DATABASE_2_USER_1_WRITE_ALL_ACCESS);
+        generic_execute(DATABASE_2_ID, QUERY_1_STATEMENT, USER_1_ID, USER_1_PRINCIPAL, DATABASE_2, DATABASE_2_USER_1_WRITE_ALL_ACCESS);
     }
 
     @Test
@@ -340,35 +341,35 @@ public class QueryEndpointUnitTest extends BaseUnitTest {
     public void reExecute_privateRead_succeeds() throws UserNotFoundException, QueryStoreException, TableMalformedException,
             DatabaseConnectionException, QueryMalformedException, ColumnParseException, DatabaseNotFoundException,
             ImageNotSupportedException, SortException, NotAllowedException,
-            PaginationException, QueryNotFoundException {
+            PaginationException, QueryNotFoundException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
         generic_reExecute(DATABASE_2_ID, QUERY_1_ID, QUERY_1, QUERY_1_RESULT_ID, QUERY_1_RESULT_DTO,
-                USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_2, DATABASE_2_USER_1_READ_ACCESS);
+                USER_2_ID, USER_2_PRINCIPAL, DATABASE_2, DATABASE_2_USER_1_READ_ACCESS);
     }
 
     @Test
     @WithMockUser(username = USER_2_USERNAME, authorities = {"execute-query"})
-    public void reExecute_privateWriteOwn_succeeds() throws UserNotFoundException, QueryStoreException, TableMalformedException,
-            DatabaseConnectionException, QueryMalformedException, ColumnParseException, DatabaseNotFoundException,
-            ImageNotSupportedException, SortException, NotAllowedException,
-            PaginationException, QueryNotFoundException {
+    public void reExecute_privateWriteOwn_succeeds() throws UserNotFoundException, QueryStoreException,
+            TableMalformedException, DatabaseConnectionException, QueryMalformedException, ColumnParseException,
+            DatabaseNotFoundException, ImageNotSupportedException, SortException, NotAllowedException,
+            PaginationException, QueryNotFoundException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
         generic_reExecute(DATABASE_2_ID, QUERY_1_ID, QUERY_1, QUERY_1_RESULT_ID, QUERY_1_RESULT_DTO,
-                USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_2, DATABASE_2_USER_1_WRITE_OWN_ACCESS);
+                USER_2_ID, USER_2_PRINCIPAL, DATABASE_2, DATABASE_2_USER_1_WRITE_OWN_ACCESS);
     }
 
     @Test
     @WithMockUser(username = USER_2_USERNAME, authorities = {"execute-query"})
-    public void reExecute_privateWriteAll_succeeds() throws UserNotFoundException, QueryStoreException, TableMalformedException,
-            DatabaseConnectionException, QueryMalformedException, ColumnParseException, DatabaseNotFoundException,
-            ImageNotSupportedException, SortException, NotAllowedException,
-            PaginationException, QueryNotFoundException {
+    public void reExecute_privateWriteAll_succeeds() throws UserNotFoundException, QueryStoreException,
+            TableMalformedException, DatabaseConnectionException, QueryMalformedException, ColumnParseException,
+            DatabaseNotFoundException, ImageNotSupportedException, SortException, NotAllowedException,
+            PaginationException, QueryNotFoundException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
         generic_reExecute(DATABASE_2_ID, QUERY_1_ID, QUERY_1, QUERY_1_RESULT_ID, QUERY_1_RESULT_DTO,
-                USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_2, DATABASE_2_USER_1_WRITE_ALL_ACCESS);
+                USER_2_ID, USER_2_PRINCIPAL, DATABASE_2, DATABASE_2_USER_1_WRITE_ALL_ACCESS);
     }
 
     @Test
@@ -383,10 +384,13 @@ public class QueryEndpointUnitTest extends BaseUnitTest {
 
     @Test
     @WithMockUser(username = USER_2_USERNAME, authorities = {"export-query-data"})
-    public void export_privateInvalidFormat_fails() throws UserNotFoundException, QueryStoreException, DatabaseConnectionException, TableMalformedException, NotAllowedException, QueryMalformedException, QueryNotFoundException, DatabaseNotFoundException, ImageNotSupportedException, IOException, FileStorageException, ContainerNotFoundException {
+    public void export_privateInvalidFormat_fails() throws UserNotFoundException, QueryStoreException,
+            DatabaseConnectionException, TableMalformedException, NotAllowedException, QueryMalformedException,
+            QueryNotFoundException, DatabaseNotFoundException, ImageNotSupportedException, IOException,
+            FileStorageException {
 
         /* test */
-        export_generic(DATABASE_2_ID, QUERY_1_ID, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_2, DATABASE_2_USER_2_READ_ACCESS, "application/json", HttpStatus.NOT_IMPLEMENTED);
+        export_generic(DATABASE_2_ID, QUERY_1_ID, USER_2_ID, USER_2_PRINCIPAL, DATABASE_2, DATABASE_2_USER_2_READ_ACCESS, "application/json", HttpStatus.NOT_IMPLEMENTED);
     }
 
     @Test
@@ -394,10 +398,10 @@ public class QueryEndpointUnitTest extends BaseUnitTest {
     public void export_privateRead_succeeds() throws UserNotFoundException, QueryStoreException,
             TableMalformedException, DatabaseConnectionException, QueryMalformedException, DatabaseNotFoundException,
             ImageNotSupportedException, NotAllowedException, QueryNotFoundException, FileStorageException,
-            ContainerNotFoundException, IOException {
+            IOException {
 
         /* test */
-        export_generic(DATABASE_2_ID, QUERY_1_ID, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_2, DATABASE_2_USER_1_READ_ACCESS, null, HttpStatus.OK);
+        export_generic(DATABASE_2_ID, QUERY_1_ID, USER_2_ID, USER_2_PRINCIPAL, DATABASE_2, DATABASE_2_USER_1_READ_ACCESS, null, HttpStatus.OK);
     }
 
     @Test
@@ -405,10 +409,10 @@ public class QueryEndpointUnitTest extends BaseUnitTest {
     public void export_privateWriteOwn_succeeds() throws UserNotFoundException, QueryStoreException,
             TableMalformedException, DatabaseConnectionException, QueryMalformedException, DatabaseNotFoundException,
             ImageNotSupportedException, NotAllowedException, QueryNotFoundException, FileStorageException,
-            ContainerNotFoundException, IOException {
+            IOException {
 
         /* test */
-        export_generic(DATABASE_2_ID, QUERY_1_ID, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_2, DATABASE_2_USER_1_WRITE_OWN_ACCESS, null, HttpStatus.OK);
+        export_generic(DATABASE_2_ID, QUERY_1_ID, USER_2_ID, USER_2_PRINCIPAL, DATABASE_2, DATABASE_2_USER_1_WRITE_OWN_ACCESS, null, HttpStatus.OK);
     }
 
     @Test
@@ -416,19 +420,19 @@ public class QueryEndpointUnitTest extends BaseUnitTest {
     public void export_privateWriteAll_succeeds() throws UserNotFoundException, QueryStoreException,
             TableMalformedException, DatabaseConnectionException, QueryMalformedException, DatabaseNotFoundException,
             ImageNotSupportedException, NotAllowedException, QueryNotFoundException, FileStorageException,
-            ContainerNotFoundException, IOException {
+            IOException {
 
         /* test */
-        export_generic(DATABASE_2_ID, QUERY_1_ID, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_2, DATABASE_2_USER_1_WRITE_ALL_ACCESS, null, HttpStatus.OK);
+        export_generic(DATABASE_2_ID, QUERY_1_ID, USER_2_ID, USER_2_PRINCIPAL, DATABASE_2, DATABASE_2_USER_1_WRITE_ALL_ACCESS, null, HttpStatus.OK);
     }
 
     /* ################################################################################################### */
     /* ## GENERIC TEST CASES                                                                            ## */
     /* ################################################################################################### */
 
-    protected void generic_execute(Long databaseId, String statement, String username,
-                                   Principal principal, Database database, DatabaseAccess access)
-            throws UserNotFoundException, QueryStoreException, TableMalformedException, DatabaseConnectionException,
+    protected void generic_execute(Long databaseId, String statement, UUID userId, Principal principal,
+                                   Database database, DatabaseAccess access) throws UserNotFoundException,
+            QueryStoreException, TableMalformedException, DatabaseConnectionException,
             QueryMalformedException, ColumnParseException, DatabaseNotFoundException, ImageNotSupportedException,
             SortException, NotAllowedException, PaginationException, KeycloakRemoteException,
             at.tuwien.exception.AccessDeniedException {
@@ -441,17 +445,17 @@ public class QueryEndpointUnitTest extends BaseUnitTest {
         final String sortColumn = "location";
 
         /* mock */
-        when(databaseRepository.findByDatabaseId(databaseId))
+        when(databaseRepository.findById(databaseId))
                 .thenReturn(Optional.of(database));
         log.trace("mock database for container database id {}", databaseId);
         if (access == null) {
-            when(databaseAccessRepository.findByDatabaseIdAndUsername(databaseId, username))
+            when(databaseAccessRepository.findByDatabaseIdAndUserId(databaseId, userId))
                     .thenReturn(Optional.empty());
-            log.trace("mock no access for database with id {} and username {}", databaseId, username);
+            log.trace("mock no access for database with id {} and username {}", databaseId, userId);
         } else {
-            when(databaseAccessRepository.findByDatabaseIdAndUsername(databaseId, username))
+            when(databaseAccessRepository.findByDatabaseIdAndUserId(databaseId, userId))
                     .thenReturn(Optional.of(access));
-            log.trace("mock access {} for database with id {} and username {}", access.getType(), databaseId, username);
+            log.trace("mock access {} for database with id {} and username {}", access.getType(), databaseId, userId);
         }
         when(queryService.execute(databaseId, request, principal, page, size, sortDirection, sortColumn))
                 .thenReturn(QUERY_1_RESULT_DTO);
@@ -469,26 +473,26 @@ public class QueryEndpointUnitTest extends BaseUnitTest {
     }
 
     protected void generic_reExecute(Long databaseId, Long queryId, Query query, Long resultId,
-                                     QueryResultDto result, String username, Principal principal, Database database,
-                                     DatabaseAccess access)
-            throws UserNotFoundException, QueryStoreException, DatabaseConnectionException, QueryNotFoundException,
-            DatabaseNotFoundException, ImageNotSupportedException, TableMalformedException, QueryMalformedException,
-            ColumnParseException, SortException, NotAllowedException, PaginationException {
+                                     QueryResultDto result, UUID userId, Principal principal, Database database,
+                                     DatabaseAccess access) throws UserNotFoundException, QueryStoreException,
+            DatabaseConnectionException, QueryNotFoundException, DatabaseNotFoundException, ImageNotSupportedException,
+            TableMalformedException, QueryMalformedException, ColumnParseException, SortException, NotAllowedException,
+            PaginationException, at.tuwien.exception.AccessDeniedException {
         final Long page = 0L;
         final Long size = 2L;
         final SortType sortDirection = SortType.ASC;
         final String sortColumn = "location";
 
         /* mock */
-        when(databaseRepository.findByDatabaseId(databaseId))
+        when(databaseRepository.findById(databaseId))
                 .thenReturn(Optional.of(database));
         when(storeService.findOne(databaseId, queryId, principal))
                 .thenReturn(query);
         if (access == null) {
-            when(databaseAccessRepository.findByDatabaseIdAndUsername(databaseId, username))
+            when(databaseAccessRepository.findByDatabaseIdAndUserId(databaseId, userId))
                     .thenReturn(Optional.empty());
         } else {
-            when(databaseAccessRepository.findByDatabaseIdAndUsername(databaseId, username))
+            when(databaseAccessRepository.findByDatabaseIdAndUserId(databaseId, userId))
                     .thenReturn(Optional.of(access));
         }
         when(queryService.reExecute(databaseId, query, page, size, sortDirection, sortColumn, principal))
@@ -502,24 +506,24 @@ public class QueryEndpointUnitTest extends BaseUnitTest {
         assertEquals(resultId, response.getBody().getId());
     }
 
-    protected void export_generic(Long databaseId, Long queryId, String username, Principal principal,
+    protected void export_generic(Long databaseId, Long queryId, UUID userId, Principal principal,
                                   Database database, DatabaseAccess access, String accept, HttpStatus status) throws IOException,
             UserNotFoundException, QueryStoreException, DatabaseConnectionException, QueryNotFoundException,
             DatabaseNotFoundException, ImageNotSupportedException, TableMalformedException, QueryMalformedException,
-            FileStorageException, ContainerNotFoundException, NotAllowedException {
+            FileStorageException, NotAllowedException {
         final ExportResource resource = ExportResource.builder()
                 .filename("location.csv")
                 .resource(new InputStreamResource(FileUtils.openInputStream(new File("src/test/resources/weather/location.csv"))))
                 .build();
 
         /* mock */
-        when(databaseRepository.findByDatabaseId(databaseId))
+        when(databaseRepository.findById(databaseId))
                 .thenReturn(Optional.of(database));
         if (access == null) {
-            when(databaseAccessRepository.findByDatabaseIdAndUsername(databaseId, username))
+            when(databaseAccessRepository.findByDatabaseIdAndUserId(databaseId, userId))
                     .thenReturn(Optional.empty());
         } else {
-            when(databaseAccessRepository.findByDatabaseIdAndUsername(databaseId, username))
+            when(databaseAccessRepository.findByDatabaseIdAndUserId(databaseId, userId))
                     .thenReturn(Optional.of(access));
         }
         when(storeService.findOne(databaseId, queryId, principal))
diff --git a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/StoreEndpointUnitTest.java b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/StoreEndpointUnitTest.java
index e81f264bec6ffd7abca13d65d4c91d169396104b..10943ca258cb2b8466d405fa6540c191ba1cf69e 100644
--- a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/StoreEndpointUnitTest.java
+++ b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/StoreEndpointUnitTest.java
@@ -28,6 +28,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
 import java.security.Principal;
 import java.util.List;
 import java.util.Optional;
+import java.util.UUID;
 
 import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.Mockito.*;
@@ -64,7 +65,7 @@ public class StoreEndpointUnitTest extends BaseUnitTest {
     @Test
     @WithAnonymousUser
     public void findAll_publicAnonymous_succeeds() throws QueryStoreException, DatabaseNotFoundException, ImageNotSupportedException,
-            ContainerNotFoundException, DatabaseConnectionException, TableMalformedException, UserNotFoundException, NotAllowedException {
+            ContainerNotFoundException, DatabaseConnectionException, TableMalformedException, UserNotFoundException, NotAllowedException, AccessDeniedException {
 
         /* test */
         findAll_generic(DATABASE_3_ID, DATABASE_3, null);
@@ -73,7 +74,7 @@ public class StoreEndpointUnitTest extends BaseUnitTest {
     @Test
     @WithMockUser(username = USER_1_USERNAME)
     public void findAll_noRole_succeeds() throws QueryStoreException, DatabaseNotFoundException, ImageNotSupportedException,
-            ContainerNotFoundException, DatabaseConnectionException, TableMalformedException, UserNotFoundException, NotAllowedException {
+            ContainerNotFoundException, DatabaseConnectionException, TableMalformedException, UserNotFoundException, NotAllowedException, AccessDeniedException {
 
         /* test */
         findAll_generic(DATABASE_1_ID, DATABASE_1, USER_1_PRINCIPAL);
@@ -82,7 +83,7 @@ public class StoreEndpointUnitTest extends BaseUnitTest {
     @Test
     @WithMockUser(username = USER_1_USERNAME, authorities = {"list-queries"})
     public void findAll_hasRole_succeeds() throws QueryStoreException, DatabaseNotFoundException, ImageNotSupportedException,
-            ContainerNotFoundException, DatabaseConnectionException, TableMalformedException, UserNotFoundException, NotAllowedException {
+            ContainerNotFoundException, DatabaseConnectionException, TableMalformedException, UserNotFoundException, NotAllowedException, AccessDeniedException {
 
         /* test */
         findAll_generic(DATABASE_1_ID, DATABASE_1, USER_1_PRINCIPAL);
@@ -90,12 +91,12 @@ public class StoreEndpointUnitTest extends BaseUnitTest {
 
     @Test
     @WithMockUser(username = USER_2_USERNAME, authorities = {"list-queries"})
-    public void findAll_privateNoAccess_fails() throws NotAllowedException {
+    public void findAll_privateNoAccess_fails() throws AccessDeniedException {
 
         /* mock */
         doThrow(NotAllowedException.class)
                 .when(accessService)
-                .find(DATABASE_1_ID, USER_2_USERNAME);
+                .find(DATABASE_1_ID, USER_2_ID);
 
         /* test */
         assertThrows(NotAllowedException.class, () -> {
@@ -107,12 +108,12 @@ public class StoreEndpointUnitTest extends BaseUnitTest {
     @WithMockUser(username = USER_2_USERNAME, authorities = {"list-queries"})
     public void findAll_publicNoAccess_succeeds() throws UserNotFoundException, QueryStoreException,
             DatabaseConnectionException, TableMalformedException, NotAllowedException, DatabaseNotFoundException,
-            ImageNotSupportedException, ContainerNotFoundException {
+            ImageNotSupportedException, ContainerNotFoundException, AccessDeniedException {
 
         /* mock */
         doThrow(NotAllowedException.class)
                 .when(accessService)
-                .find(DATABASE_3_ID, USER_2_USERNAME);
+                .find(DATABASE_3_ID, USER_2_ID);
 
         /* test */
         findAll_generic(DATABASE_3_ID, DATABASE_3, USER_2_PRINCIPAL);
@@ -122,10 +123,10 @@ public class StoreEndpointUnitTest extends BaseUnitTest {
     @WithMockUser(username = USER_1_USERNAME, authorities = {"list-queries"})
     public void findAll_hasAccess_succeeds() throws UserNotFoundException, QueryStoreException,
             DatabaseConnectionException, TableMalformedException, DatabaseNotFoundException, ImageNotSupportedException,
-            ContainerNotFoundException, NotAllowedException {
+            ContainerNotFoundException, NotAllowedException, AccessDeniedException {
 
         /* mock */
-        when(accessService.find(DATABASE_2_ID, USER_1_USERNAME))
+        when(accessService.find(DATABASE_2_ID, USER_1_ID))
                 .thenReturn(DATABASE_1_USER_1_READ_ACCESS);
 
         /* test */
@@ -205,7 +206,7 @@ public class StoreEndpointUnitTest extends BaseUnitTest {
             DatabaseNotFoundException, ImageNotSupportedException, KeycloakRemoteException, AccessDeniedException {
 
         /* test */
-        final QueryDto response = persist_generic(DATABASE_1_ID, DATABASE_1, QUERY_1_ID, QUERY_1, USER_1_USERNAME, USER_1_PRINCIPAL, DATABASE_1_USER_1_READ_ACCESS);
+        final QueryDto response = persist_generic(DATABASE_1_ID, DATABASE_1, QUERY_1_ID, QUERY_1, USER_1_ID, USER_1_PRINCIPAL, DATABASE_1_USER_1_READ_ACCESS);
         assertEquals(QUERY_1_ID, response.getId());
         assertEquals(QUERY_1_STATEMENT, response.getQuery());
     }
@@ -217,7 +218,7 @@ public class StoreEndpointUnitTest extends BaseUnitTest {
             DatabaseNotFoundException, ImageNotSupportedException, KeycloakRemoteException, AccessDeniedException {
 
         /* test */
-        final QueryDto response = persist_generic(DATABASE_1_ID, DATABASE_1, QUERY_1_ID, QUERY_1, USER_1_USERNAME, USER_1_PRINCIPAL, DATABASE_1_USER_1_WRITE_OWN_ACCESS);
+        final QueryDto response = persist_generic(DATABASE_1_ID, DATABASE_1, QUERY_1_ID, QUERY_1, USER_1_ID, USER_1_PRINCIPAL, DATABASE_1_USER_1_WRITE_OWN_ACCESS);
         assertEquals(QUERY_1_ID, response.getId());
         assertEquals(QUERY_1_STATEMENT, response.getQuery());
     }
@@ -229,7 +230,7 @@ public class StoreEndpointUnitTest extends BaseUnitTest {
             DatabaseNotFoundException, ImageNotSupportedException, KeycloakRemoteException, AccessDeniedException {
 
         /* test */
-        final QueryDto response = persist_generic(DATABASE_1_ID, DATABASE_1, QUERY_1_ID, QUERY_1, USER_1_USERNAME, USER_1_PRINCIPAL, DATABASE_1_USER_1_WRITE_ALL_ACCESS);
+        final QueryDto response = persist_generic(DATABASE_1_ID, DATABASE_1, QUERY_1_ID, QUERY_1, USER_1_ID, USER_1_PRINCIPAL, DATABASE_1_USER_1_WRITE_ALL_ACCESS);
         assertEquals(QUERY_1_ID, response.getId());
         assertEquals(QUERY_1_STATEMENT, response.getQuery());
     }
@@ -241,7 +242,7 @@ public class StoreEndpointUnitTest extends BaseUnitTest {
             DatabaseNotFoundException, ImageNotSupportedException, KeycloakRemoteException, AccessDeniedException {
 
         /* test */
-        persist_generic(DATABASE_1_ID, DATABASE_1, QUERY_1_ID, QUERY_1, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_1_USER_2_WRITE_ALL_ACCESS);
+        persist_generic(DATABASE_1_ID, DATABASE_1, QUERY_1_ID, QUERY_1, USER_2_ID, USER_2_PRINCIPAL, DATABASE_1_USER_2_WRITE_ALL_ACCESS);
 
     }
 
@@ -250,7 +251,7 @@ public class StoreEndpointUnitTest extends BaseUnitTest {
     /* ################################################################################################### */
 
     protected QueryDto persist_generic(Long databaseId, Database database, Long queryId, Query query,
-                                       String username, Principal principal, DatabaseAccess access)
+                                       UUID userId, Principal principal, DatabaseAccess access)
             throws DatabaseNotFoundException, UserNotFoundException, QueryStoreException, QueryNotFoundException,
             ImageNotSupportedException, NotAllowedException, DatabaseConnectionException,
             QueryAlreadyPersistedException, KeycloakRemoteException, AccessDeniedException {
@@ -266,12 +267,12 @@ public class StoreEndpointUnitTest extends BaseUnitTest {
         when(storeService.persist(databaseId, queryId, request))
                 .thenReturn(query);
         if (access != null) {
-            log.trace("mock access for database with id {} and username {}", databaseId, username);
-            when(accessService.find(databaseId, username))
+            log.trace("mock access for database with id {} and user id {}", databaseId, userId);
+            when(accessService.find(databaseId, userId))
                     .thenReturn(access);
         } else {
-            log.trace("mock no access for database with id {} and username {}", databaseId, username);
-            when(accessService.find(databaseId, username))
+            log.trace("mock no access for database with id {} and user id {}", databaseId, userId);
+            when(accessService.find(databaseId, userId))
                     .thenThrow(NotAllowedException.class);
         }
 
@@ -284,7 +285,8 @@ public class StoreEndpointUnitTest extends BaseUnitTest {
 
     protected void findAll_generic(Long databaseId, Database database, Principal principal)
             throws UserNotFoundException, QueryStoreException, DatabaseConnectionException, TableMalformedException,
-            DatabaseNotFoundException, ImageNotSupportedException, ContainerNotFoundException, NotAllowedException {
+            DatabaseNotFoundException, ImageNotSupportedException, ContainerNotFoundException, NotAllowedException,
+            AccessDeniedException {
 
         /* mock */
         doReturn(List.of(QUERY_1)).when(storeService)
diff --git a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/TableColumnEndpointUnitTest.java b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/TableColumnEndpointUnitTest.java
index d3fbf783c6ce95e64301db291478e68c83081023..504fb5717cb894fc2e89c9112a20a5a928a7feac 100644
--- a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/TableColumnEndpointUnitTest.java
+++ b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/TableColumnEndpointUnitTest.java
@@ -33,6 +33,7 @@ import org.springframework.security.test.context.support.WithMockUser;
 import org.springframework.test.context.junit.jupiter.SpringExtension;
 
 import java.security.Principal;
+import java.util.UUID;
 
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.mockito.Mockito.doThrow;
@@ -74,7 +75,7 @@ public class TableColumnEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(NotAllowedException.class, () -> {
-            generic_update(DATABASE_3_ID, TABLE_8_ID, COLUMN_1_1_ID, DATABASE_3, TABLE_8, null, COLUMN_8_2_SEMANTICS_UPDATE_DTO, USER_1_USERNAME, USER_1_PRINCIPAL, null);
+            generic_update(DATABASE_3_ID, TABLE_8_ID, COLUMN_1_1_ID, DATABASE_3, TABLE_8, null, COLUMN_8_2_SEMANTICS_UPDATE_DTO, USER_1_ID, USER_1_PRINCIPAL, null);
         });
     }
 
@@ -84,7 +85,7 @@ public class TableColumnEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(NotAllowedException.class, () -> {
-            generic_update(DATABASE_3_ID, TABLE_8_ID, COLUMN_1_1_ID, DATABASE_3, TABLE_8, null, COLUMN_8_2_SEMANTICS_UPDATE_DTO, USER_1_USERNAME, USER_1_PRINCIPAL, DATABASE_3_USER_1_READ_ACCESS);
+            generic_update(DATABASE_3_ID, TABLE_8_ID, COLUMN_1_1_ID, DATABASE_3, TABLE_8, null, COLUMN_8_2_SEMANTICS_UPDATE_DTO, USER_1_ID, USER_1_PRINCIPAL, DATABASE_3_USER_1_READ_ACCESS);
         });
     }
 
@@ -92,10 +93,10 @@ public class TableColumnEndpointUnitTest extends BaseUnitTest {
     @WithMockUser(username = USER_1_USERNAME, authorities = {"modify-table-column-semantics"})
     public void update_publicHasRoleHasOwnWriteAccess_succeeds() throws TableNotFoundException, NotAllowedException,
             TableMalformedException, DatabaseNotFoundException, ContainerNotFoundException,
-            SemanticEntityPersistException, SemanticEntityNotFoundException, QueryMalformedException {
+            SemanticEntityPersistException, SemanticEntityNotFoundException, QueryMalformedException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        generic_update(DATABASE_3_ID, TABLE_8_ID, COLUMN_1_1_ID, DATABASE_3, TABLE_8, COLUMN_8_2_WITH_SEMANTICS, COLUMN_8_2_SEMANTICS_UPDATE_DTO, USER_1_USERNAME, USER_1_PRINCIPAL, DATABASE_3_USER_1_WRITE_OWN_ACCESS);
+        generic_update(DATABASE_3_ID, TABLE_8_ID, COLUMN_1_1_ID, DATABASE_3, TABLE_8, COLUMN_8_2_WITH_SEMANTICS, COLUMN_8_2_SEMANTICS_UPDATE_DTO, USER_1_ID, USER_1_PRINCIPAL, DATABASE_3_USER_1_WRITE_OWN_ACCESS);
     }
 
     @Test
@@ -104,7 +105,7 @@ public class TableColumnEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(NotAllowedException.class, () -> {
-            generic_update(DATABASE_3_ID, TABLE_8_ID, COLUMN_1_1_ID, DATABASE_3, TABLE_8, null, COLUMN_8_2_SEMANTICS_UPDATE_DTO, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_3_USER_2_WRITE_OWN_ACCESS);
+            generic_update(DATABASE_3_ID, TABLE_8_ID, COLUMN_1_1_ID, DATABASE_3, TABLE_8, null, COLUMN_8_2_SEMANTICS_UPDATE_DTO, USER_2_ID, USER_2_PRINCIPAL, DATABASE_3_USER_2_WRITE_OWN_ACCESS);
         });
     }
 
@@ -114,7 +115,7 @@ public class TableColumnEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(DatabaseNotFoundException.class, () -> {
-            generic_update(DATABASE_3_ID, TABLE_8_ID, COLUMN_1_1_ID, null, TABLE_8, null, COLUMN_8_2_SEMANTICS_UPDATE_DTO, USER_1_USERNAME, USER_1_PRINCIPAL, DATABASE_3_USER_1_WRITE_OWN_ACCESS);
+            generic_update(DATABASE_3_ID, TABLE_8_ID, COLUMN_1_1_ID, null, TABLE_8, null, COLUMN_8_2_SEMANTICS_UPDATE_DTO, USER_1_ID, USER_1_PRINCIPAL, DATABASE_3_USER_1_WRITE_OWN_ACCESS);
         });
     }
 
@@ -124,7 +125,7 @@ public class TableColumnEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(TableNotFoundException.class, () -> {
-            generic_update(DATABASE_3_ID, TABLE_8_ID, COLUMN_1_1_ID, DATABASE_3, null, null, COLUMN_8_2_SEMANTICS_UPDATE_DTO, USER_1_USERNAME, USER_1_PRINCIPAL, DATABASE_3_USER_1_WRITE_OWN_ACCESS);
+            generic_update(DATABASE_3_ID, TABLE_8_ID, COLUMN_1_1_ID, DATABASE_3, null, null, COLUMN_8_2_SEMANTICS_UPDATE_DTO, USER_1_ID, USER_1_PRINCIPAL, DATABASE_3_USER_1_WRITE_OWN_ACCESS);
         });
     }
 
@@ -133,10 +134,10 @@ public class TableColumnEndpointUnitTest extends BaseUnitTest {
     public void update_publicHasRoleForeignHasAllWriteAccess_succeeds() throws TableNotFoundException,
             NotAllowedException, TableMalformedException, DatabaseNotFoundException,
             ContainerNotFoundException, SemanticEntityPersistException, SemanticEntityNotFoundException,
-            QueryMalformedException {
+            QueryMalformedException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        generic_update(DATABASE_3_ID, TABLE_8_ID, COLUMN_1_1_ID, DATABASE_3, TABLE_8, COLUMN_8_2_WITH_SEMANTICS, COLUMN_8_2_SEMANTICS_UPDATE_DTO, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_3_USER_2_WRITE_ALL_ACCESS);
+        generic_update(DATABASE_3_ID, TABLE_8_ID, COLUMN_1_1_ID, DATABASE_3, TABLE_8, COLUMN_8_2_WITH_SEMANTICS, COLUMN_8_2_SEMANTICS_UPDATE_DTO, USER_2_ID, USER_2_PRINCIPAL, DATABASE_3_USER_2_WRITE_ALL_ACCESS);
     }
 
     /* ################################################################################################### */
@@ -159,7 +160,7 @@ public class TableColumnEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(NotAllowedException.class, () -> {
-            generic_update(DATABASE_1_ID, TABLE_1_ID, COLUMN_1_1_ID, DATABASE_1, TABLE_1, null, COLUMN_1_4_SEMANTICS_UPDATE_DTO, USER_1_USERNAME, USER_1_PRINCIPAL, null);
+            generic_update(DATABASE_1_ID, TABLE_1_ID, COLUMN_1_1_ID, DATABASE_1, TABLE_1, null, COLUMN_1_4_SEMANTICS_UPDATE_DTO, USER_1_ID, USER_1_PRINCIPAL, null);
         });
     }
 
@@ -169,7 +170,7 @@ public class TableColumnEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(NotAllowedException.class, () -> {
-            generic_update(DATABASE_1_ID, TABLE_1_ID, COLUMN_1_1_ID, DATABASE_1, TABLE_1, null, COLUMN_1_4_SEMANTICS_UPDATE_DTO, USER_1_USERNAME, USER_1_PRINCIPAL, DATABASE_1_USER_1_READ_ACCESS);
+            generic_update(DATABASE_1_ID, TABLE_1_ID, COLUMN_1_1_ID, DATABASE_1, TABLE_1, null, COLUMN_1_4_SEMANTICS_UPDATE_DTO, USER_1_ID, USER_1_PRINCIPAL, DATABASE_1_USER_1_READ_ACCESS);
         });
     }
 
@@ -177,10 +178,11 @@ public class TableColumnEndpointUnitTest extends BaseUnitTest {
     @WithMockUser(username = USER_1_USERNAME, authorities = {"modify-table-column-semantics"})
     public void update_privateHasRoleHasOwnWriteAccess_succeeds() throws TableNotFoundException, NotAllowedException,
             TableMalformedException, DatabaseNotFoundException, ContainerNotFoundException,
-            SemanticEntityPersistException, SemanticEntityNotFoundException, QueryMalformedException {
+            SemanticEntityPersistException, SemanticEntityNotFoundException, QueryMalformedException,
+            at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        generic_update(DATABASE_1_ID, TABLE_1_ID, COLUMN_1_1_ID, DATABASE_1, TABLE_1, COLUMN_1_4_WITH_SEMANTICS, COLUMN_1_4_SEMANTICS_UPDATE_DTO, USER_1_USERNAME, USER_1_PRINCIPAL, DATABASE_1_USER_1_WRITE_OWN_ACCESS);
+        generic_update(DATABASE_1_ID, TABLE_1_ID, COLUMN_1_1_ID, DATABASE_1, TABLE_1, COLUMN_1_4_WITH_SEMANTICS, COLUMN_1_4_SEMANTICS_UPDATE_DTO, USER_1_ID, USER_1_PRINCIPAL, DATABASE_1_USER_1_WRITE_OWN_ACCESS);
     }
 
     @Test
@@ -189,7 +191,7 @@ public class TableColumnEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(NotAllowedException.class, () -> {
-            generic_update(DATABASE_1_ID, TABLE_1_ID, COLUMN_1_1_ID, DATABASE_1, TABLE_1, null, COLUMN_1_4_SEMANTICS_UPDATE_DTO, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_1_USER_2_WRITE_OWN_ACCESS);
+            generic_update(DATABASE_1_ID, TABLE_1_ID, COLUMN_1_1_ID, DATABASE_1, TABLE_1, null, COLUMN_1_4_SEMANTICS_UPDATE_DTO, USER_2_ID, USER_2_PRINCIPAL, DATABASE_1_USER_2_WRITE_OWN_ACCESS);
         });
     }
 
@@ -199,7 +201,7 @@ public class TableColumnEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(DatabaseNotFoundException.class, () -> {
-            generic_update(DATABASE_1_ID, TABLE_1_ID, COLUMN_1_1_ID, null, TABLE_1, null, COLUMN_1_4_SEMANTICS_UPDATE_DTO, USER_1_USERNAME, USER_1_PRINCIPAL, DATABASE_1_USER_1_WRITE_OWN_ACCESS);
+            generic_update(DATABASE_1_ID, TABLE_1_ID, COLUMN_1_1_ID, null, TABLE_1, null, COLUMN_1_4_SEMANTICS_UPDATE_DTO, USER_1_ID, USER_1_PRINCIPAL, DATABASE_1_USER_1_WRITE_OWN_ACCESS);
         });
     }
 
@@ -209,7 +211,7 @@ public class TableColumnEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(TableNotFoundException.class, () -> {
-            generic_update(DATABASE_1_ID, TABLE_1_ID, COLUMN_1_1_ID, DATABASE_1, null, null, COLUMN_1_4_SEMANTICS_UPDATE_DTO, USER_1_USERNAME, USER_1_PRINCIPAL, DATABASE_1_USER_1_WRITE_OWN_ACCESS);
+            generic_update(DATABASE_1_ID, TABLE_1_ID, COLUMN_1_1_ID, DATABASE_1, null, null, COLUMN_1_4_SEMANTICS_UPDATE_DTO, USER_1_ID, USER_1_PRINCIPAL, DATABASE_1_USER_1_WRITE_OWN_ACCESS);
         });
     }
 
@@ -218,10 +220,10 @@ public class TableColumnEndpointUnitTest extends BaseUnitTest {
     public void update_privateHasRoleForeignHasAllWriteAccess_succeeds() throws TableNotFoundException,
             NotAllowedException, TableMalformedException, DatabaseNotFoundException,
             ContainerNotFoundException, SemanticEntityPersistException, SemanticEntityNotFoundException,
-            QueryMalformedException {
+            QueryMalformedException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        generic_update(DATABASE_1_ID, TABLE_1_ID, COLUMN_1_1_ID, DATABASE_1, TABLE_1, COLUMN_1_4_WITH_SEMANTICS, COLUMN_1_4_SEMANTICS_UPDATE_DTO, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_1_USER_2_WRITE_ALL_ACCESS);
+        generic_update(DATABASE_1_ID, TABLE_1_ID, COLUMN_1_1_ID, DATABASE_1, TABLE_1, COLUMN_1_4_WITH_SEMANTICS, COLUMN_1_4_SEMANTICS_UPDATE_DTO, USER_2_ID, USER_2_PRINCIPAL, DATABASE_1_USER_2_WRITE_ALL_ACCESS);
     }
 
     /* ################################################################################################### */
@@ -230,11 +232,11 @@ public class TableColumnEndpointUnitTest extends BaseUnitTest {
 
     protected ResponseEntity<ColumnDto> generic_update(Long databaseId, Long tableId, Long columnId,
                                                        Database database, Table table, TableColumn column,
-                                                       ColumnSemanticsUpdateDto data, String username,
+                                                       ColumnSemanticsUpdateDto data, UUID userId,
                                                        Principal principal, DatabaseAccess access)
             throws DatabaseNotFoundException, NotAllowedException, TableNotFoundException, TableMalformedException,
             ContainerNotFoundException, SemanticEntityPersistException, SemanticEntityNotFoundException,
-            QueryMalformedException {
+            QueryMalformedException, at.tuwien.exception.AccessDeniedException {
 
         /* mock */
         if (database != null) {
@@ -259,12 +261,12 @@ public class TableColumnEndpointUnitTest extends BaseUnitTest {
                     .findById(databaseId, tableId);
         }
         if (access != null) {
-            when(accessService.find(databaseId, username))
+            when(accessService.find(databaseId, userId))
                     .thenReturn(access);
         } else {
             doThrow(NotAllowedException.class)
                     .when(accessService)
-                    .find(databaseId, username);
+                    .find(databaseId, userId);
         }
 
         /* test */
diff --git a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/TableDataEndpointUnitTest.java b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/TableDataEndpointUnitTest.java
index 0083761dc09e8f2bb08002d2b418c98b487ca1c8..00fef071eb254aec6b50577871936c7a640af143 100644
--- a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/TableDataEndpointUnitTest.java
+++ b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/TableDataEndpointUnitTest.java
@@ -33,6 +33,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
 
 import java.security.Principal;
 import java.time.Instant;
+import java.util.UUID;
 import java.util.stream.Stream;
 
 import static org.junit.jupiter.api.Assertions.*;
@@ -76,7 +77,7 @@ public class TableDataEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(AccessDeniedException.class, () -> {
-            generic_import(DATABASE_1_ID, DATABASE_1, TABLE_1_ID, TABLE_1, USER_2_USERNAME,
+            generic_import(DATABASE_1_ID, DATABASE_1, TABLE_1_ID, TABLE_1, USER_2_ID,
                     DATABASE_1_USER_1_READ_ACCESS, USER_2_PRINCIPAL);
         });
     }
@@ -87,7 +88,7 @@ public class TableDataEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(AccessDeniedException.class, () -> {
-            generic_import(DATABASE_1_ID, DATABASE_1, TABLE_1_ID, TABLE_1, USER_2_USERNAME,
+            generic_import(DATABASE_1_ID, DATABASE_1, TABLE_1_ID, TABLE_1, USER_2_ID,
                     DATABASE_1_USER_1_WRITE_OWN_ACCESS, USER_2_PRINCIPAL);
         });
     }
@@ -108,7 +109,7 @@ public class TableDataEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(AccessDeniedException.class, () -> {
-            generic_import(DATABASE_2_ID, DATABASE_2, TABLE_1_ID, TABLE_1, USER_2_USERNAME,
+            generic_import(DATABASE_2_ID, DATABASE_2, TABLE_1_ID, TABLE_1, USER_2_ID,
                     DATABASE_2_USER_1_READ_ACCESS, USER_2_PRINCIPAL);
         });
     }
@@ -119,7 +120,7 @@ public class TableDataEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(AccessDeniedException.class, () -> {
-            generic_import(DATABASE_2_ID, DATABASE_2, TABLE_1_ID, TABLE_1, USER_2_USERNAME,
+            generic_import(DATABASE_2_ID, DATABASE_2, TABLE_1_ID, TABLE_1, USER_2_ID,
                     DATABASE_2_USER_1_WRITE_OWN_ACCESS, USER_2_PRINCIPAL);
         });
     }
@@ -138,10 +139,10 @@ public class TableDataEndpointUnitTest extends BaseUnitTest {
     @WithMockUser(username = USER_1_USERNAME, authorities = {"insert-table-data"})
     public void import_publicWriteAll_succeeds() throws UserNotFoundException, TableNotFoundException, NotAllowedException,
             TableMalformedException, DatabaseConnectionException, QueryMalformedException, DatabaseNotFoundException,
-            ImageNotSupportedException, ContainerNotFoundException {
+            ImageNotSupportedException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        generic_import(DATABASE_3_ID, DATABASE_3, TABLE_8_ID, TABLE_8, USER_1_USERNAME,
+        generic_import(DATABASE_3_ID, DATABASE_3, TABLE_8_ID, TABLE_8, USER_1_ID,
                 DATABASE_3_USER_1_WRITE_ALL_ACCESS, USER_1_PRINCIPAL);
     }
 
@@ -149,10 +150,10 @@ public class TableDataEndpointUnitTest extends BaseUnitTest {
     @WithMockUser(username = USER_1_USERNAME, authorities = {"insert-table-data"})
     public void import_privateWriteAll_succeeds() throws UserNotFoundException, TableNotFoundException, NotAllowedException,
             TableMalformedException, DatabaseConnectionException, QueryMalformedException, DatabaseNotFoundException,
-            ImageNotSupportedException, ContainerNotFoundException {
+            ImageNotSupportedException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        generic_import(DATABASE_1_ID, DATABASE_1, TABLE_1_ID, TABLE_1, USER_1_USERNAME,
+        generic_import(DATABASE_1_ID, DATABASE_1, TABLE_1_ID, TABLE_1, USER_1_ID,
                 DATABASE_1_USER_1_WRITE_ALL_ACCESS, USER_1_PRINCIPAL);
     }
 
@@ -162,7 +163,7 @@ public class TableDataEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(AccessDeniedException.class, () -> {
-            generic_insert(DATABASE_1_ID, TABLE_1_ID, DATABASE_1, TABLE_1, USER_2_USERNAME, null,
+            generic_insert(DATABASE_1_ID, TABLE_1_ID, DATABASE_1, TABLE_1, USER_2_ID, null,
                     TABLE_1_CSV_DTO, null);
         });
     }
@@ -173,7 +174,7 @@ public class TableDataEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(AccessDeniedException.class, () -> {
-            generic_insert(DATABASE_1_ID, TABLE_1_ID, DATABASE_1, TABLE_1, USER_2_USERNAME,
+            generic_insert(DATABASE_1_ID, TABLE_1_ID, DATABASE_1, TABLE_1, USER_2_ID,
                     DATABASE_1_USER_1_READ_ACCESS, TABLE_1_CSV_DTO, USER_2_PRINCIPAL);
         });
     }
@@ -184,7 +185,7 @@ public class TableDataEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(AccessDeniedException.class, () -> {
-            generic_insert(DATABASE_1_ID, TABLE_1_ID, DATABASE_1, TABLE_1, USER_2_USERNAME,
+            generic_insert(DATABASE_1_ID, TABLE_1_ID, DATABASE_1, TABLE_1, USER_2_ID,
                     DATABASE_1_USER_1_WRITE_OWN_ACCESS, TABLE_1_CSV_DTO, USER_2_PRINCIPAL);
         });
     }
@@ -195,7 +196,7 @@ public class TableDataEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(AccessDeniedException.class, () -> {
-            generic_insert(DATABASE_2_ID, TABLE_1_ID, DATABASE_2, TABLE_1, USER_2_USERNAME, null,
+            generic_insert(DATABASE_2_ID, TABLE_1_ID, DATABASE_2, TABLE_1, USER_2_ID, null,
                     TABLE_1_CSV_DTO, null);
         });
     }
@@ -206,7 +207,7 @@ public class TableDataEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(AccessDeniedException.class, () -> {
-            generic_insert(DATABASE_2_ID, TABLE_1_ID, DATABASE_2, TABLE_1, USER_2_USERNAME,
+            generic_insert(DATABASE_2_ID, TABLE_1_ID, DATABASE_2, TABLE_1, USER_2_ID,
                     DATABASE_2_USER_1_READ_ACCESS, TABLE_1_CSV_DTO, USER_2_PRINCIPAL);
         });
     }
@@ -217,7 +218,7 @@ public class TableDataEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(AccessDeniedException.class, () -> {
-            generic_insert(DATABASE_2_ID, TABLE_1_ID, DATABASE_2, TABLE_1, USER_2_USERNAME,
+            generic_insert(DATABASE_2_ID, TABLE_1_ID, DATABASE_2, TABLE_1, USER_2_ID,
                     DATABASE_2_USER_1_WRITE_OWN_ACCESS, TABLE_1_CSV_DTO, USER_2_PRINCIPAL);
         });
     }
@@ -226,10 +227,10 @@ public class TableDataEndpointUnitTest extends BaseUnitTest {
     @WithMockUser(username = USER_1_USERNAME, authorities = {"insert-table-data"})
     public void insert_publicWriteAll_succeeds() throws UserNotFoundException, TableNotFoundException,
             NotAllowedException, TableMalformedException, DatabaseConnectionException, DatabaseNotFoundException,
-            ImageNotSupportedException, ContainerNotFoundException {
+            ImageNotSupportedException, ContainerNotFoundException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        generic_insert(DATABASE_3_ID, TABLE_8_ID, DATABASE_3, TABLE_8, USER_1_USERNAME,
+        generic_insert(DATABASE_3_ID, TABLE_8_ID, DATABASE_3, TABLE_8, USER_1_ID,
                 DATABASE_3_USER_1_WRITE_ALL_ACCESS, TABLE_8_CSV_DTO, USER_1_PRINCIPAL);
     }
 
@@ -237,22 +238,20 @@ public class TableDataEndpointUnitTest extends BaseUnitTest {
     @WithMockUser(username = USER_1_USERNAME, authorities = {"insert-table-data"})
     public void insert_privateWriteAll_succeeds() throws UserNotFoundException, TableNotFoundException,
             NotAllowedException, TableMalformedException, DatabaseConnectionException, DatabaseNotFoundException,
-            ImageNotSupportedException, ContainerNotFoundException {
+            ImageNotSupportedException, ContainerNotFoundException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        generic_insert(DATABASE_1_ID, TABLE_1_ID, DATABASE_1, TABLE_1, USER_1_USERNAME,
-                DATABASE_1_USER_1_WRITE_ALL_ACCESS, TABLE_1_CSV_DTO, USER_1_PRINCIPAL);
+        generic_insert(DATABASE_1_ID, TABLE_1_ID, DATABASE_1, TABLE_1, USER_1_ID, DATABASE_1_USER_1_WRITE_ALL_ACCESS, TABLE_1_CSV_DTO, USER_1_PRINCIPAL);
     }
 
     @Test
     @WithMockUser(username = USER_1_USERNAME, authorities = {"insert-table-data"})
     public void insert_privateDataNull_fails() throws UserNotFoundException, TableNotFoundException,
             NotAllowedException, TableMalformedException, DatabaseConnectionException, DatabaseNotFoundException,
-            ImageNotSupportedException, ContainerNotFoundException {
+            ImageNotSupportedException, ContainerNotFoundException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        generic_insert(DATABASE_1_ID, TABLE_1_ID, DATABASE_1, TABLE_1, USER_1_USERNAME,
-                DATABASE_1_USER_1_WRITE_ALL_ACCESS, null, USER_1_PRINCIPAL);
+        generic_insert(DATABASE_1_ID, TABLE_1_ID, DATABASE_1, TABLE_1, USER_1_ID, DATABASE_1_USER_1_WRITE_ALL_ACCESS, null, USER_1_PRINCIPAL);
     }
 
     @Test
@@ -326,7 +325,7 @@ public class TableDataEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(NotAllowedException.class, () -> {
-            generic_getAll(DATABASE_1_ID, TABLE_1_ID, DATABASE_1, TABLE_1, USER_4_USERNAME, DATABASE_1_USER_1_READ_ACCESS, USER_4_PRINCIPAL, null, null, null, null, null);
+            generic_getAll(DATABASE_1_ID, TABLE_1_ID, DATABASE_1, TABLE_1, USER_4_ID, DATABASE_1_USER_1_READ_ACCESS, USER_4_PRINCIPAL, null, null, null, null, null);
         });
     }
 
@@ -336,7 +335,7 @@ public class TableDataEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(NotAllowedException.class, () -> {
-            generic_getCount(DATABASE_1_ID, TABLE_1_ID, DATABASE_1, TABLE_1, USER_4_USERNAME, DATABASE_1_USER_1_READ_ACCESS, USER_4_PRINCIPAL, null);
+            generic_getCount(DATABASE_1_ID, TABLE_1_ID, DATABASE_1, TABLE_1, USER_4_ID, DATABASE_1_USER_1_READ_ACCESS, USER_4_PRINCIPAL, null);
         });
     }
 
@@ -369,12 +368,15 @@ public class TableDataEndpointUnitTest extends BaseUnitTest {
     @ParameterizedTest
     @WithMockUser(username = USER_1_USERNAME, authorities = {"insert-table-data"})
     @MethodSource("getAll_succeeds_parameters")
-    public void getAll_succeeds(String test, Long databaseId, Long tableId, Database database,
-                                Table table, String username, DatabaseAccess access, Principal principal,
-                                Instant timestamp, Long page, Long size, SortType sortDirection, String sortColumn) throws UserNotFoundException, TableNotFoundException, QueryStoreException, SortException, TableMalformedException, NotAllowedException, DatabaseConnectionException, QueryMalformedException, DatabaseNotFoundException, ImageNotSupportedException, PaginationException, ContainerNotFoundException {
+    public void getAll_succeeds(String test, Long databaseId, Long tableId, Database database, Table table, UUID userId,
+                                DatabaseAccess access, Principal principal, Instant timestamp, Long page, Long size,
+                                SortType sortDirection, String sortColumn) throws UserNotFoundException,
+            TableNotFoundException, SortException, TableMalformedException, NotAllowedException,
+            DatabaseConnectionException, QueryMalformedException, DatabaseNotFoundException, ImageNotSupportedException,
+            PaginationException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        generic_getAll(databaseId, tableId, database, table, username, access, principal, timestamp,
+        generic_getAll(databaseId, tableId, database, table, userId, access, principal, timestamp,
                 page, size, sortDirection, sortColumn);
     }
 
@@ -406,12 +408,14 @@ public class TableDataEndpointUnitTest extends BaseUnitTest {
     @ParameterizedTest
     @WithMockUser(username = USER_1_USERNAME, authorities = {"insert-table-data"})
     @MethodSource("getAll_succeeds_parameters")
-    public void getCount_succeeds(String test, Long databaseId, Long tableId, Database database,
-                                  Table table, String username, DatabaseAccess access, Principal principal,
-                                  Instant timestamp) throws UserNotFoundException, TableNotFoundException, QueryStoreException, SortException, TableMalformedException, NotAllowedException, DatabaseConnectionException, QueryMalformedException, DatabaseNotFoundException, ImageNotSupportedException, PaginationException, ContainerNotFoundException {
+    public void getCount_succeeds(String test, Long databaseId, Long tableId, Database database, Table table,
+                                  UUID userId, DatabaseAccess access, Principal principal, Instant timestamp)
+            throws UserNotFoundException, TableNotFoundException, QueryStoreException, TableMalformedException,
+            NotAllowedException, DatabaseConnectionException, QueryMalformedException, DatabaseNotFoundException,
+            ImageNotSupportedException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        generic_getCount(databaseId, tableId, database, table, username, access, principal, timestamp);
+        generic_getCount(databaseId, tableId, database, table, userId, access, principal, timestamp);
     }
 
 
@@ -419,14 +423,17 @@ public class TableDataEndpointUnitTest extends BaseUnitTest {
     /* ## GENERIC TEST CASES                                                                            ## */
     /* ################################################################################################### */
 
-    public void generic_import(Long databaseId, Database database, Long tableId, Table table,
-                               String username, DatabaseAccess access, Principal principal) throws DatabaseNotFoundException, TableNotFoundException, NotAllowedException, UserNotFoundException, TableMalformedException, DatabaseConnectionException, QueryMalformedException, ImageNotSupportedException, ContainerNotFoundException {
+    public void generic_import(Long databaseId, Database database, Long tableId, Table table, UUID userId,
+                               DatabaseAccess access, Principal principal) throws DatabaseNotFoundException,
+            TableNotFoundException, NotAllowedException, UserNotFoundException, TableMalformedException,
+            DatabaseConnectionException, QueryMalformedException, ImageNotSupportedException,
+            at.tuwien.exception.AccessDeniedException {
         final ImportDto request = ImportDto.builder().location("test:csv/csv_01.csv").build();
 
         /* mock */
         when(databaseService.find(databaseId)).thenReturn(database);
         when(tableService.find(databaseId, tableId)).thenReturn(table);
-        when(accessService.find(databaseId, username)).thenReturn(access);
+        when(accessService.find(databaseId, userId)).thenReturn(access);
 
         /* test */
         final ResponseEntity<?> response = dataEndpoint.importCsv(databaseId, tableId, request, principal);
@@ -434,13 +441,16 @@ public class TableDataEndpointUnitTest extends BaseUnitTest {
         assertEquals(HttpStatus.ACCEPTED, response.getStatusCode());
     }
 
-    public void generic_insert(Long databaseId, Long tableId, Database database, Table table,
-                               String username, DatabaseAccess access, TableCsvDto data, Principal principal) throws DatabaseNotFoundException, TableNotFoundException, NotAllowedException, UserNotFoundException, TableMalformedException, DatabaseConnectionException, ImageNotSupportedException, ContainerNotFoundException {
+    public void generic_insert(Long databaseId, Long tableId, Database database, Table table, UUID userId,
+                               DatabaseAccess access, TableCsvDto data, Principal principal)
+            throws DatabaseNotFoundException, TableNotFoundException, NotAllowedException, UserNotFoundException,
+            TableMalformedException, DatabaseConnectionException, ImageNotSupportedException,
+            ContainerNotFoundException, at.tuwien.exception.AccessDeniedException {
 
         /* mock */
         when(databaseService.find(databaseId)).thenReturn(database);
         when(tableService.find(databaseId, tableId)).thenReturn(table);
-        when(accessService.find(databaseId, username)).thenReturn(access);
+        when(accessService.find(databaseId, userId)).thenReturn(access);
 
         /* test */
         final ResponseEntity<?> response = dataEndpoint.insert(databaseId, tableId, data, principal);
@@ -448,14 +458,17 @@ public class TableDataEndpointUnitTest extends BaseUnitTest {
         assertEquals(HttpStatus.ACCEPTED, response.getStatusCode());
     }
 
-    public void generic_getAll(Long databaseId, Long tableId, Database database, Table table,
-                               String username, DatabaseAccess access, Principal principal, Instant timestamp,
-                               Long page, Long size, SortType sortDirection, String sortColumn) throws UserNotFoundException, TableMalformedException, NotAllowedException, PaginationException, TableNotFoundException, QueryStoreException, SortException, DatabaseConnectionException, QueryMalformedException, DatabaseNotFoundException, ImageNotSupportedException, ContainerNotFoundException {
+    public void generic_getAll(Long databaseId, Long tableId, Database database, Table table, UUID userId,
+                               DatabaseAccess access, Principal principal, Instant timestamp, Long page, Long size,
+                               SortType sortDirection, String sortColumn) throws UserNotFoundException,
+            TableMalformedException, NotAllowedException, PaginationException, TableNotFoundException, SortException,
+            DatabaseConnectionException, QueryMalformedException, DatabaseNotFoundException, ImageNotSupportedException,
+            at.tuwien.exception.AccessDeniedException {
 
         /* mock */
         when(databaseService.find(databaseId)).thenReturn(database);
         when(tableService.find(databaseId, tableId)).thenReturn(table);
-        when(accessService.find(databaseId, username)).thenReturn(access);
+        when(accessService.find(databaseId, userId)).thenReturn(access);
         when(queryService.tableFindAll(databaseId, tableId, timestamp, page, size, principal)).thenReturn(QUERY_1_RESULT_DTO);
 
         /* test */
@@ -468,13 +481,16 @@ public class TableDataEndpointUnitTest extends BaseUnitTest {
         assertEquals(QUERY_1_RESULT_RESULT, response.getBody().getResult());
     }
 
-    public void generic_getCount(Long databaseId, Long tableId, Database database, Table table,
-                                 String username, DatabaseAccess access, Principal principal, Instant timestamp) throws UserNotFoundException, TableMalformedException, NotAllowedException, PaginationException, TableNotFoundException, QueryStoreException, SortException, DatabaseConnectionException, QueryMalformedException, DatabaseNotFoundException, ImageNotSupportedException, ContainerNotFoundException {
+    public void generic_getCount(Long databaseId, Long tableId, Database database, Table table, UUID userId,
+                                 DatabaseAccess access, Principal principal, Instant timestamp)
+            throws UserNotFoundException, TableMalformedException, NotAllowedException, TableNotFoundException,
+            QueryStoreException, DatabaseConnectionException, QueryMalformedException, DatabaseNotFoundException,
+            ImageNotSupportedException, at.tuwien.exception.AccessDeniedException {
 
         /* mock */
         when(databaseService.find(databaseId)).thenReturn(database);
         when(tableService.find(databaseId, tableId)).thenReturn(table);
-        when(accessService.find(databaseId, username)).thenReturn(access);
+        when(accessService.find(databaseId, userId)).thenReturn(access);
         when(queryService.tableCount(databaseId, tableId, timestamp, principal)).thenReturn(QUERY_1_RESULT_NUMBER);
 
         /* test */
diff --git a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/TableEndpointIntegrationTest.java b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/TableEndpointIntegrationTest.java
index e52f787ea9dc496b3ceb2f3e87fc5547335d7067..3ea981b73cddd1a01c660af11ee530659d44c66e 100644
--- a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/TableEndpointIntegrationTest.java
+++ b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/TableEndpointIntegrationTest.java
@@ -64,7 +64,7 @@ public class TableEndpointIntegrationTest extends BaseUnitTest {
     @WithMockUser(username = USER_1_USERNAME, authorities = {"create-table"})
     public void create_hasRoleHasAccess_succeeds() throws UserNotFoundException, TableMalformedException, NotAllowedException,
             QueryMalformedException, DatabaseNotFoundException, ImageNotSupportedException, AmqpException,
-            TableNameExistsException, ContainerNotFoundException {
+            TableNameExistsException, ContainerNotFoundException, AccessDeniedException {
 
         /* mock */
         accessRepository.save(DATABASE_1_USER_1_WRITE_OWN_ACCESS);
diff --git a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/TableEndpointUnitTest.java b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/TableEndpointUnitTest.java
index 789b3c968f98ae5e3902f9126dc254c8d317c7e8..f45d9a967087eceb3677b0c78ba223e582ce55a8 100644
--- a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/TableEndpointUnitTest.java
+++ b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/TableEndpointUnitTest.java
@@ -31,6 +31,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
 
 import java.security.Principal;
 import java.util.List;
+import java.util.UUID;
 
 import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.Mockito.*;
@@ -63,7 +64,8 @@ public class TableEndpointUnitTest extends BaseUnitTest {
 
     @Test
     @WithAnonymousUser
-    public void list_publicAnonymous_succeeds() throws NotAllowedException, DatabaseNotFoundException {
+    public void list_publicAnonymous_succeeds() throws NotAllowedException, DatabaseNotFoundException,
+            at.tuwien.exception.AccessDeniedException {
 
         /* test */
         generic_list(DATABASE_3_ID, DATABASE_3, null, null, null);
@@ -75,16 +77,17 @@ public class TableEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(DatabaseNotFoundException.class, () -> {
-            generic_list(DATABASE_3_ID, null, USER_1_USERNAME, USER_1_PRINCIPAL, DATABASE_3_USER_1_READ_ACCESS);
+            generic_list(DATABASE_3_ID, null, USER_1_ID, USER_1_PRINCIPAL, DATABASE_3_USER_1_READ_ACCESS);
         });
     }
 
     @Test
     @WithMockUser(username = USER_1_USERNAME, authorities = "find-table")
-    public void list_publicHasRole_succeeds() throws DatabaseNotFoundException, NotAllowedException {
+    public void list_publicHasRole_succeeds() throws DatabaseNotFoundException, NotAllowedException,
+            at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        final ResponseEntity<List<TableBriefDto>> response = generic_list(DATABASE_3_ID, DATABASE_3, USER_1_USERNAME, USER_1_PRINCIPAL, DATABASE_1_USER_1_READ_ACCESS);
+        final ResponseEntity<List<TableBriefDto>> response = generic_list(DATABASE_3_ID, DATABASE_3, USER_1_ID, USER_1_PRINCIPAL, DATABASE_1_USER_1_READ_ACCESS);
         assertEquals(HttpStatus.OK, response.getStatusCode());
         final List<TableBriefDto> body = response.getBody();
         assertNotNull(body);
@@ -93,10 +96,10 @@ public class TableEndpointUnitTest extends BaseUnitTest {
 
     @Test
     @WithMockUser(username = USER_4_USERNAME)
-    public void list_publicNoRole_succeeds() throws NotAllowedException, DatabaseNotFoundException {
+    public void list_publicNoRole_succeeds() throws NotAllowedException, DatabaseNotFoundException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        generic_list(DATABASE_3_ID, DATABASE_3, USER_4_USERNAME, USER_4_PRINCIPAL, null);
+        generic_list(DATABASE_3_ID, DATABASE_3, USER_4_ID, USER_4_PRINCIPAL, null);
     }
 
     @Test
@@ -115,7 +118,7 @@ public class TableEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(DatabaseNotFoundException.class, () -> {
-            generic_create(DATABASE_3_ID, null, TABLE_4_CREATE_DTO, USER_1_USERNAME, USER_1_PRINCIPAL, DATABASE_3_USER_1_WRITE_OWN_ACCESS);
+            generic_create(DATABASE_3_ID, null, TABLE_4_CREATE_DTO, USER_1_ID, USER_1_PRINCIPAL, DATABASE_3_USER_1_WRITE_OWN_ACCESS);
         });
     }
 
@@ -125,7 +128,7 @@ public class TableEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(NotAllowedException.class, () -> {
-            generic_create(DATABASE_3_ID, DATABASE_3, TABLE_4_CREATE_DTO, USER_1_USERNAME, USER_1_PRINCIPAL, null);
+            generic_create(DATABASE_3_ID, DATABASE_3, TABLE_4_CREATE_DTO, USER_1_ID, USER_1_PRINCIPAL, null);
         });
     }
 
@@ -135,7 +138,7 @@ public class TableEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(AccessDeniedException.class, () -> {
-            generic_create(DATABASE_3_ID, DATABASE_3, TABLE_4_CREATE_DTO, USER_1_USERNAME, USER_1_PRINCIPAL, DATABASE_3_USER_1_WRITE_OWN_ACCESS);
+            generic_create(DATABASE_3_ID, DATABASE_3, TABLE_4_CREATE_DTO, USER_1_ID, USER_1_PRINCIPAL, DATABASE_3_USER_1_WRITE_OWN_ACCESS);
         });
     }
 
@@ -145,13 +148,14 @@ public class TableEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(NotAllowedException.class, () -> {
-            generic_create(DATABASE_3_ID, DATABASE_3, TABLE_4_CREATE_DTO, USER_1_USERNAME, USER_1_PRINCIPAL, DATABASE_3_USER_1_READ_ACCESS);
+            generic_create(DATABASE_3_ID, DATABASE_3, TABLE_4_CREATE_DTO, USER_1_ID, USER_1_PRINCIPAL, DATABASE_3_USER_1_READ_ACCESS);
         });
     }
 
     @Test
     @WithAnonymousUser
-    public void findById_publicAnonymous_succeeds() throws UserNotFoundException, TableNotFoundException, NotAllowedException, TableMalformedException, QueryMalformedException, DatabaseNotFoundException, ImageNotSupportedException, AmqpException, TableNameExistsException, ContainerNotFoundException {
+    public void findById_publicAnonymous_succeeds() throws DatabaseNotFoundException, TableNotFoundException,
+            at.tuwien.exception.AccessDeniedException {
 
         /* test */
         generic_findById(DATABASE_3_ID, TABLE_8_ID, DATABASE_3, TABLE_8, null, null, null);
@@ -163,26 +167,26 @@ public class TableEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(TableNotFoundException.class, () -> {
-            generic_findById(DATABASE_3_ID, TABLE_8_ID, DATABASE_3, null, USER_1_USERNAME, USER_1_PRINCIPAL, DATABASE_1_USER_1_READ_ACCESS);
+            generic_findById(DATABASE_3_ID, TABLE_8_ID, DATABASE_3, null, USER_1_ID, USER_1_PRINCIPAL, DATABASE_1_USER_1_READ_ACCESS);
         });
     }
 
     @Test
     @WithMockUser(username = USER_1_USERNAME, authorities = "find-table")
-    public void findById_publicHasRoleDatabaseNotFound_succeeds() throws UserNotFoundException, TableNotFoundException,
-            NotAllowedException, TableMalformedException, QueryMalformedException, DatabaseNotFoundException,
-            ImageNotSupportedException, AmqpException, TableNameExistsException, ContainerNotFoundException {
+    public void findById_publicHasRoleDatabaseNotFound_succeeds() throws DatabaseNotFoundException, TableNotFoundException,
+            at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        generic_findById(DATABASE_3_ID, TABLE_8_ID, null, TABLE_8, USER_1_USERNAME, USER_1_PRINCIPAL, DATABASE_1_USER_1_READ_ACCESS);
+        generic_findById(DATABASE_3_ID, TABLE_8_ID, null, TABLE_8, USER_1_ID, USER_1_PRINCIPAL, DATABASE_1_USER_1_READ_ACCESS);
     }
 
     @Test
     @WithMockUser(username = USER_1_USERNAME, authorities = "find-table")
-    public void findById_publicHasRole_succeeds() throws DatabaseNotFoundException, NotAllowedException, UserNotFoundException, TableNotFoundException, TableMalformedException, QueryMalformedException, ImageNotSupportedException, AmqpException, TableNameExistsException, ContainerNotFoundException {
+    public void findById_publicHasRole_succeeds() throws DatabaseNotFoundException, TableNotFoundException,
+            at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        final ResponseEntity<TableDto> response = generic_findById(DATABASE_3_ID, TABLE_8_ID, DATABASE_3, TABLE_8, USER_1_USERNAME, USER_1_PRINCIPAL, DATABASE_1_USER_1_READ_ACCESS);
+        final ResponseEntity<TableDto> response = generic_findById(DATABASE_3_ID, TABLE_8_ID, DATABASE_3, TABLE_8, USER_1_ID, USER_1_PRINCIPAL, DATABASE_1_USER_1_READ_ACCESS);
         assertEquals(HttpStatus.OK, response.getStatusCode());
         final TableDto body = response.getBody();
         assertNotNull(body);
@@ -190,10 +194,11 @@ public class TableEndpointUnitTest extends BaseUnitTest {
 
     @Test
     @WithMockUser(username = USER_4_USERNAME)
-    public void findById_publicNoRole_succeeds() throws UserNotFoundException, TableNotFoundException, NotAllowedException, TableMalformedException, QueryMalformedException, DatabaseNotFoundException, ImageNotSupportedException, AmqpException, TableNameExistsException, ContainerNotFoundException {
+    public void findById_publicNoRole_succeeds() throws TableNotFoundException, DatabaseNotFoundException,
+            at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        generic_findById(DATABASE_3_ID, TABLE_8_ID, DATABASE_3, TABLE_8, USER_1_USERNAME, USER_1_PRINCIPAL, null);
+        generic_findById(DATABASE_3_ID, TABLE_8_ID, DATABASE_3, TABLE_8, USER_1_ID, USER_1_PRINCIPAL, null);
     }
 
     @Test
@@ -265,16 +270,17 @@ public class TableEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(DatabaseNotFoundException.class, () -> {
-            generic_list(DATABASE_1_ID, null, USER_1_USERNAME, USER_1_PRINCIPAL, DATABASE_1_USER_1_READ_ACCESS);
+            generic_list(DATABASE_1_ID, null, USER_1_ID, USER_1_PRINCIPAL, DATABASE_1_USER_1_READ_ACCESS);
         });
     }
 
     @Test
     @WithMockUser(username = USER_1_USERNAME, authorities = "find-table")
-    public void list_privateHasRole_succeeds() throws DatabaseNotFoundException, NotAllowedException {
+    public void list_privateHasRole_succeeds() throws DatabaseNotFoundException, NotAllowedException,
+            at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        final ResponseEntity<List<TableBriefDto>> response = generic_list(DATABASE_1_ID, DATABASE_1, USER_1_USERNAME, USER_1_PRINCIPAL, DATABASE_1_USER_1_READ_ACCESS);
+        final ResponseEntity<List<TableBriefDto>> response = generic_list(DATABASE_1_ID, DATABASE_1, USER_1_ID, USER_1_PRINCIPAL, DATABASE_1_USER_1_READ_ACCESS);
         assertEquals(HttpStatus.OK, response.getStatusCode());
         final List<TableBriefDto> body = response.getBody();
         assertNotNull(body);
@@ -287,7 +293,7 @@ public class TableEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(NotAllowedException.class, () -> {
-            generic_list(DATABASE_1_ID, DATABASE_1, USER_4_USERNAME, USER_4_PRINCIPAL, null);
+            generic_list(DATABASE_1_ID, DATABASE_1, USER_4_ID, USER_4_PRINCIPAL, null);
         });
     }
 
@@ -307,7 +313,7 @@ public class TableEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(DatabaseNotFoundException.class, () -> {
-            generic_create(DATABASE_1_ID, null, TABLE_4_CREATE_DTO, USER_1_USERNAME, USER_1_PRINCIPAL, DATABASE_1_USER_1_WRITE_OWN_ACCESS);
+            generic_create(DATABASE_1_ID, null, TABLE_4_CREATE_DTO, USER_1_ID, USER_1_PRINCIPAL, DATABASE_1_USER_1_WRITE_OWN_ACCESS);
         });
     }
 
@@ -317,7 +323,7 @@ public class TableEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(NotAllowedException.class, () -> {
-            generic_create(DATABASE_1_ID, DATABASE_1, TABLE_4_CREATE_DTO, USER_1_USERNAME, USER_1_PRINCIPAL, null);
+            generic_create(DATABASE_1_ID, DATABASE_1, TABLE_4_CREATE_DTO, USER_1_ID, USER_1_PRINCIPAL, null);
         });
     }
 
@@ -327,7 +333,7 @@ public class TableEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(AccessDeniedException.class, () -> {
-            generic_create(DATABASE_1_ID, DATABASE_1, TABLE_4_CREATE_DTO, USER_1_USERNAME, USER_1_PRINCIPAL, DATABASE_1_USER_1_WRITE_OWN_ACCESS);
+            generic_create(DATABASE_1_ID, DATABASE_1, TABLE_4_CREATE_DTO, USER_1_ID, USER_1_PRINCIPAL, DATABASE_1_USER_1_WRITE_OWN_ACCESS);
         });
     }
 
@@ -337,15 +343,14 @@ public class TableEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(NotAllowedException.class, () -> {
-            generic_create(DATABASE_1_ID, DATABASE_1, TABLE_4_CREATE_DTO, USER_1_USERNAME, USER_1_PRINCIPAL, DATABASE_1_USER_1_READ_ACCESS);
+            generic_create(DATABASE_1_ID, DATABASE_1, TABLE_4_CREATE_DTO, USER_1_ID, USER_1_PRINCIPAL, DATABASE_1_USER_1_READ_ACCESS);
         });
     }
 
     @Test
     @WithAnonymousUser
-    public void findById_privateAnonymous_succeeds() throws UserNotFoundException, TableNotFoundException,
-            NotAllowedException, TableMalformedException, QueryMalformedException, DatabaseNotFoundException,
-            ImageNotSupportedException, AmqpException, TableNameExistsException, ContainerNotFoundException {
+    public void findById_privateAnonymous_succeeds() throws TableNotFoundException, DatabaseNotFoundException,
+            at.tuwien.exception.AccessDeniedException {
 
         /* test */
         generic_findById(DATABASE_1_ID, TABLE_1_ID, DATABASE_1, TABLE_1, null, null, null);
@@ -357,26 +362,25 @@ public class TableEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(TableNotFoundException.class, () -> {
-            generic_findById(DATABASE_1_ID, TABLE_1_ID, DATABASE_1, null, USER_1_USERNAME, USER_1_PRINCIPAL, DATABASE_1_USER_1_READ_ACCESS);
+            generic_findById(DATABASE_1_ID, TABLE_1_ID, DATABASE_1, null, USER_1_ID, USER_1_PRINCIPAL, DATABASE_1_USER_1_READ_ACCESS);
         });
     }
 
     @Test
     @WithMockUser(username = USER_1_USERNAME, authorities = "find-table")
-    public void findById_privateHasRoleDatabaseNotFound_succeeds() throws UserNotFoundException, TableNotFoundException,
-            NotAllowedException, TableMalformedException, QueryMalformedException, DatabaseNotFoundException,
-            ImageNotSupportedException, AmqpException, TableNameExistsException, ContainerNotFoundException {
+    public void findById_privateHasRoleDatabaseNotFound_succeeds() throws DatabaseNotFoundException,
+            TableNotFoundException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        generic_findById(DATABASE_1_ID, TABLE_1_ID, null, TABLE_1, USER_1_USERNAME, USER_1_PRINCIPAL, DATABASE_1_USER_1_READ_ACCESS);
+        generic_findById(DATABASE_1_ID, TABLE_1_ID, null, TABLE_1, USER_1_ID, USER_1_PRINCIPAL, DATABASE_1_USER_1_READ_ACCESS);
     }
 
     @Test
     @WithMockUser(username = USER_1_USERNAME, authorities = "find-table")
-    public void findById_privateHasRole_succeeds() throws DatabaseNotFoundException, NotAllowedException, UserNotFoundException, TableNotFoundException, TableMalformedException, QueryMalformedException, ImageNotSupportedException, AmqpException, TableNameExistsException, ContainerNotFoundException {
-
+    public void findById_privateHasRole_succeeds() throws DatabaseNotFoundException, TableNotFoundException,
+            at.tuwien.exception.AccessDeniedException {
         /* test */
-        final ResponseEntity<TableDto> response = generic_findById(DATABASE_1_ID, TABLE_1_ID, DATABASE_1, TABLE_1, USER_1_USERNAME, USER_1_PRINCIPAL, DATABASE_1_USER_1_READ_ACCESS);
+        final ResponseEntity<TableDto> response = generic_findById(DATABASE_1_ID, TABLE_1_ID, DATABASE_1, TABLE_1, USER_1_ID, USER_1_PRINCIPAL, DATABASE_1_USER_1_READ_ACCESS);
         assertEquals(HttpStatus.OK, response.getStatusCode());
         final TableDto body = response.getBody();
         assertNotNull(body);
@@ -384,12 +388,11 @@ public class TableEndpointUnitTest extends BaseUnitTest {
 
     @Test
     @WithMockUser(username = USER_4_USERNAME)
-    public void findById_privateNoRole_succeeds() throws UserNotFoundException, TableNotFoundException,
-            NotAllowedException, TableMalformedException, QueryMalformedException, DatabaseNotFoundException,
-            ImageNotSupportedException, AmqpException, TableNameExistsException, ContainerNotFoundException {
+    public void findById_privateNoRole_succeeds() throws TableNotFoundException, DatabaseNotFoundException,
+            at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        generic_findById(DATABASE_1_ID, TABLE_1_ID, DATABASE_1, TABLE_1, USER_4_USERNAME, USER_4_PRINCIPAL, null);
+        generic_findById(DATABASE_1_ID, TABLE_1_ID, DATABASE_1, TABLE_1, USER_4_ID, USER_4_PRINCIPAL, null);
     }
 
     @Test
@@ -424,7 +427,9 @@ public class TableEndpointUnitTest extends BaseUnitTest {
 
     @Test
     @WithMockUser(username = USER_1_USERNAME, authorities = "delete-table")
-    public void delete_privateHasRole_succeeds() throws DatabaseNotFoundException, NotAllowedException, TableNotFoundException, TableMalformedException, QueryMalformedException, ImageNotSupportedException, ContainerNotFoundException, DataProcessingException {
+    public void delete_privateHasRole_succeeds() throws DatabaseNotFoundException, NotAllowedException,
+            TableNotFoundException, TableMalformedException, QueryMalformedException, ImageNotSupportedException,
+            ContainerNotFoundException, DataProcessingException {
 
         /* test */
         final ResponseEntity<?> response = generic_delete(DATABASE_1_ID, TABLE_1_ID, DATABASE_1, TABLE_1, USER_1_PRINCIPAL);
@@ -433,19 +438,20 @@ public class TableEndpointUnitTest extends BaseUnitTest {
 
     @Test
     @WithMockUser(username = USER_4_USERNAME)
-    public void delete_privateNoRole_succeeds() throws UserNotFoundException, TableNotFoundException,
-            NotAllowedException, TableMalformedException, QueryMalformedException, DatabaseNotFoundException,
-            ImageNotSupportedException, AmqpException, TableNameExistsException, ContainerNotFoundException {
+    public void delete_privateNoRole_succeeds() throws TableNotFoundException, DatabaseNotFoundException,
+            at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        generic_findById(DATABASE_1_ID, TABLE_1_ID, DATABASE_1, TABLE_1, USER_4_USERNAME, USER_4_PRINCIPAL, null);
+        generic_findById(DATABASE_1_ID, TABLE_1_ID, DATABASE_1, TABLE_1, USER_4_ID, USER_4_PRINCIPAL, null);
     }
 
     /* ################################################################################################### */
     /* ## GENERIC TEST CASES                                                                            ## */
     /* ################################################################################################### */
 
-    protected ResponseEntity<List<TableBriefDto>> generic_list(Long databaseId, Database database, String username, Principal principal, DatabaseAccess access) throws DatabaseNotFoundException, NotAllowedException {
+    protected ResponseEntity<List<TableBriefDto>> generic_list(Long databaseId, Database database, UUID userId,
+                                                               Principal principal, DatabaseAccess access)
+            throws DatabaseNotFoundException, NotAllowedException, at.tuwien.exception.AccessDeniedException {
 
         /* mock */
         if (database != null) {
@@ -463,19 +469,23 @@ public class TableEndpointUnitTest extends BaseUnitTest {
             log.trace("mock 0 tables");
         }
         if (access != null) {
-            when(accessService.find(databaseId, username))
+            when(accessService.find(databaseId, userId))
                     .thenReturn(access);
         } else {
             doThrow(NotAllowedException.class)
                     .when(accessService)
-                    .find(databaseId, username);
+                    .find(databaseId, userId);
         }
 
         /* test */
         return tableEndpoint.list(databaseId, principal);
     }
 
-    protected ResponseEntity<TableBriefDto> generic_create(Long databaseId, Database database, TableCreateDto data, String username, Principal principal, DatabaseAccess access) throws DatabaseNotFoundException, NotAllowedException, UserNotFoundException, TableMalformedException, QueryMalformedException, ImageNotSupportedException, AmqpException, TableNameExistsException, ContainerNotFoundException {
+    protected ResponseEntity<TableBriefDto> generic_create(Long databaseId, Database database, TableCreateDto data,
+                                                           UUID userId, Principal principal, DatabaseAccess access)
+            throws DatabaseNotFoundException, NotAllowedException, UserNotFoundException, TableMalformedException,
+            QueryMalformedException, ImageNotSupportedException, AmqpException, TableNameExistsException,
+            ContainerNotFoundException, at.tuwien.exception.AccessDeniedException {
 
         /* mock */
         if (database != null) {
@@ -492,19 +502,22 @@ public class TableEndpointUnitTest extends BaseUnitTest {
                     .thenReturn(List.of());
         }
         if (access != null) {
-            when(accessService.find(databaseId, username))
+            when(accessService.find(databaseId, userId))
                     .thenReturn(access);
         } else {
             doThrow(NotAllowedException.class)
                     .when(accessService)
-                    .find(databaseId, username);
+                    .find(databaseId, userId);
         }
 
         /* test */
         return tableEndpoint.create(databaseId, data, principal);
     }
 
-    protected ResponseEntity<TableDto> generic_findById(Long databaseId, Long tableId, Database database, Table table, String username, Principal principal, DatabaseAccess access) throws DatabaseNotFoundException, NotAllowedException, UserNotFoundException, TableMalformedException, QueryMalformedException, ImageNotSupportedException, AmqpException, TableNameExistsException, ContainerNotFoundException, TableNotFoundException {
+    protected ResponseEntity<TableDto> generic_findById(Long databaseId, Long tableId, Database database,
+                                                        Table table, UUID userId, Principal principal,
+                                                        DatabaseAccess access) throws DatabaseNotFoundException,
+            TableNotFoundException, at.tuwien.exception.AccessDeniedException {
 
         /* mock */
         if (table != null) {
@@ -528,12 +541,12 @@ public class TableEndpointUnitTest extends BaseUnitTest {
                     .find(databaseId);
         }
         if (access != null) {
-            when(accessService.find(databaseId, username))
+            when(accessService.find(databaseId, userId))
                     .thenReturn(access);
         } else {
             doThrow(NotAllowedException.class)
                     .when(accessService)
-                    .find(databaseId, username);
+                    .find(databaseId, userId);
         }
 
         /* test */
diff --git a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/TableHistoryEndpointUnitTest.java b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/TableHistoryEndpointUnitTest.java
index 562fab5aa4a64e48fb2f6dfa141300a98f992b10..edec0b481d3e23959992ceac4dbad64ab740437c 100644
--- a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/TableHistoryEndpointUnitTest.java
+++ b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/TableHistoryEndpointUnitTest.java
@@ -26,6 +26,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
 import java.security.Principal;
 import java.util.List;
 import java.util.Optional;
+import java.util.UUID;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -52,8 +53,7 @@ public class TableHistoryEndpointUnitTest extends BaseUnitTest {
 
     @Test
     public void data_publicAnonymous_succeeds() throws UserNotFoundException, TableNotFoundException,
-            QueryStoreException, NotAllowedException, DatabaseConnectionException, QueryMalformedException,
-            DatabaseNotFoundException {
+            QueryStoreException, DatabaseConnectionException, QueryMalformedException, DatabaseNotFoundException {
 
         /* test */
         data_generic(DATABASE_1_ID, DATABASE_1, TABLE_1_ID, TABLE_1, null, null, null);
@@ -62,8 +62,7 @@ public class TableHistoryEndpointUnitTest extends BaseUnitTest {
     @Test
     @WithAnonymousUser
     public void data_publicAnonymous2_succeeds() throws UserNotFoundException, TableNotFoundException,
-            QueryStoreException, NotAllowedException, DatabaseConnectionException, QueryMalformedException,
-            DatabaseNotFoundException {
+            QueryStoreException, DatabaseConnectionException, QueryMalformedException, DatabaseNotFoundException {
 
         /* test */
         data_generic(DATABASE_1_ID, DATABASE_1, TABLE_1_ID, TABLE_1, null, null, null);
@@ -72,21 +71,19 @@ public class TableHistoryEndpointUnitTest extends BaseUnitTest {
     @Test
     @WithMockUser(username = USER_1_USERNAME, roles = {"RESEARCHER"})
     public void data_publicResearcher_succeeds() throws UserNotFoundException, TableNotFoundException,
-            QueryStoreException, NotAllowedException, DatabaseConnectionException, QueryMalformedException,
-            DatabaseNotFoundException {
+            QueryStoreException, DatabaseConnectionException, QueryMalformedException, DatabaseNotFoundException {
 
         /* test */
-        data_generic(DATABASE_1_ID, DATABASE_1, TABLE_1_ID, TABLE_1, USER_1_USERNAME, USER_1_PRINCIPAL, DATABASE_1_USER_1_READ_ACCESS);
+        data_generic(DATABASE_1_ID, DATABASE_1, TABLE_1_ID, TABLE_1, USER_1_ID, USER_1_PRINCIPAL, DATABASE_1_USER_1_READ_ACCESS);
     }
 
     @Test
     @WithMockUser(username = USER_1_USERNAME, roles = {"RESEARCHER"})
     public void data_privateResearcher_fails() throws UserNotFoundException, TableNotFoundException,
-            QueryStoreException, NotAllowedException, DatabaseConnectionException, QueryMalformedException,
-            DatabaseNotFoundException {
+            QueryStoreException, DatabaseConnectionException, QueryMalformedException, DatabaseNotFoundException {
 
         /* test */
-        data_generic(DATABASE_2_ID, DATABASE_2, TABLE_4_ID, TABLE_4, USER_1_USERNAME, USER_1_PRINCIPAL, null);
+        data_generic(DATABASE_2_ID, DATABASE_2, TABLE_4_ID, TABLE_4, USER_1_ID, USER_1_PRINCIPAL, null);
     }
 
     /* ################################################################################################### */
@@ -94,8 +91,8 @@ public class TableHistoryEndpointUnitTest extends BaseUnitTest {
     /* ################################################################################################### */
 
     protected void data_generic(Long databaseId, Database database, Long tableId, Table table,
-                                String username, Principal principal, DatabaseAccess access)
-            throws DatabaseNotFoundException, UserNotFoundException, NotAllowedException, DatabaseConnectionException,
+                                UUID userId, Principal principal, DatabaseAccess access)
+            throws DatabaseNotFoundException, UserNotFoundException, DatabaseConnectionException,
             QueryMalformedException, QueryStoreException, TableNotFoundException {
 
         /* mock */
@@ -104,10 +101,10 @@ public class TableHistoryEndpointUnitTest extends BaseUnitTest {
         when(tableService.find(databaseId, tableId))
                 .thenReturn(table);
         if (access != null) {
-            when(databaseAccessRepository.findByDatabaseIdAndUsername(databaseId, username))
+            when(databaseAccessRepository.findByDatabaseIdAndUserId(databaseId, userId))
                     .thenReturn(Optional.of(access));
         } else {
-            when(databaseAccessRepository.findByDatabaseIdAndUsername(databaseId, username))
+            when(databaseAccessRepository.findByDatabaseIdAndUserId(databaseId, userId))
                     .thenReturn(Optional.empty());
         }
 
diff --git a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/ViewEndpointUnitTest.java b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/ViewEndpointUnitTest.java
index ac325fbe5053dfab95c2cc0200e442ace0f6f401..8e936cbc7dda2078f0efef751cfd6a4b14fd353c 100644
--- a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/ViewEndpointUnitTest.java
+++ b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/ViewEndpointUnitTest.java
@@ -29,6 +29,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
 
 import java.security.Principal;
 import java.util.List;
+import java.util.UUID;
 
 import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.Mockito.doNothing;
@@ -58,8 +59,7 @@ public class ViewEndpointUnitTest extends BaseUnitTest {
 
     @Test
     @WithAnonymousUser
-    public void findAll_publicAnonymous_succeeds() throws UserNotFoundException, NotAllowedException,
-            DatabaseNotFoundException {
+    public void findAll_publicAnonymous_succeeds() throws UserNotFoundException, DatabaseNotFoundException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
         findAll_generic(DATABASE_3_ID, DATABASE_3, null, null, null);
@@ -67,29 +67,28 @@ public class ViewEndpointUnitTest extends BaseUnitTest {
 
     @Test
     @WithMockUser(username = USER_2_USERNAME, authorities = {"list-views"})
-    public void findAll_publicHasRole_succeeds() throws UserNotFoundException, NotAllowedException,
-            DatabaseNotFoundException {
+    public void findAll_publicHasRole_succeeds() throws UserNotFoundException, DatabaseNotFoundException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        findAll_generic(DATABASE_3_ID, DATABASE_3, USER_2_USERNAME, USER_2_PRINCIPAL, null);
+        findAll_generic(DATABASE_3_ID, DATABASE_3, USER_2_ID, USER_2_PRINCIPAL, null);
     }
 
     @Test
     @WithMockUser(username = USER_2_USERNAME, authorities = {"list-views"})
-    public void findAll_publicHasRoleHasAccess_succeeds() throws UserNotFoundException, NotAllowedException,
-            DatabaseNotFoundException {
+    public void findAll_publicHasRoleHasAccess_succeeds() throws UserNotFoundException, DatabaseNotFoundException,
+            at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        findAll_generic(DATABASE_3_ID, DATABASE_3, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_3_USER_2_READ_ACCESS);
+        findAll_generic(DATABASE_3_ID, DATABASE_3, USER_2_ID, USER_2_PRINCIPAL, DATABASE_3_USER_2_READ_ACCESS);
     }
 
     @Test
     @WithMockUser(username = USER_2_USERNAME)
-    public void findAll_publicNoRole_succeeds() throws UserNotFoundException, NotAllowedException,
-            DatabaseNotFoundException {
+    public void findAll_publicNoRole_succeeds() throws UserNotFoundException, DatabaseNotFoundException,
+            at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        findAll_generic(DATABASE_3_ID, DATABASE_3, USER_2_USERNAME, USER_2_PRINCIPAL, null);
+        findAll_generic(DATABASE_3_ID, DATABASE_3, USER_2_ID, USER_2_PRINCIPAL, null);
     }
 
     @Test
@@ -108,7 +107,7 @@ public class ViewEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(NotAllowedException.class, () -> {
-            create_generic(DATABASE_3_ID, DATABASE_3, USER_2_USERNAME, USER_2_PRINCIPAL, null);
+            create_generic(DATABASE_3_ID, DATABASE_3, USER_2_ID, USER_2_PRINCIPAL, null);
         });
     }
 
@@ -118,7 +117,7 @@ public class ViewEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(NotAllowedException.class, () -> {
-            create_generic(DATABASE_3_ID, DATABASE_3, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_2_USER_1_READ_ACCESS);
+            create_generic(DATABASE_3_ID, DATABASE_3, USER_2_ID, USER_2_PRINCIPAL, DATABASE_2_USER_1_READ_ACCESS);
         });
     }
 
@@ -128,14 +127,14 @@ public class ViewEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(AccessDeniedException.class, () -> {
-            create_generic(DATABASE_3_ID, DATABASE_3, USER_2_USERNAME, USER_2_PRINCIPAL, null);
+            create_generic(DATABASE_3_ID, DATABASE_3, USER_2_ID, USER_2_PRINCIPAL, null);
         });
     }
 
     @Test
     @WithAnonymousUser
     public void find_publicAnonymous_succeeds() throws UserNotFoundException, NotAllowedException,
-            DatabaseNotFoundException, ViewNotFoundException {
+            DatabaseNotFoundException, ViewNotFoundException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
         find_generic(DATABASE_3_ID, VIEW_1_ID, DATABASE_3, null, null, null);
@@ -144,28 +143,28 @@ public class ViewEndpointUnitTest extends BaseUnitTest {
     @Test
     @WithMockUser(username = USER_2_USERNAME, authorities = {"find-database-view"})
     public void find_publicHasRole_succeeds() throws UserNotFoundException, NotAllowedException,
-            DatabaseNotFoundException, ViewNotFoundException {
+            DatabaseNotFoundException, ViewNotFoundException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        find_generic(DATABASE_3_ID, VIEW_1_ID, DATABASE_3, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_2_USER_1_READ_ACCESS);
+        find_generic(DATABASE_3_ID, VIEW_1_ID, DATABASE_3, USER_2_ID, USER_2_PRINCIPAL, DATABASE_2_USER_1_READ_ACCESS);
     }
 
     @Test
     @WithMockUser(username = USER_2_USERNAME)
     public void find_publicNoRole_succeeds() throws UserNotFoundException, NotAllowedException,
-            DatabaseNotFoundException, ViewNotFoundException {
+            DatabaseNotFoundException, ViewNotFoundException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        find_generic(DATABASE_3_ID, VIEW_1_ID, DATABASE_3, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_2_USER_1_READ_ACCESS);
+        find_generic(DATABASE_3_ID, VIEW_1_ID, DATABASE_3, USER_2_ID, USER_2_PRINCIPAL, DATABASE_2_USER_1_READ_ACCESS);
     }
 
     @Test
     @WithMockUser(username = USER_2_USERNAME)
     public void find_publicHasRoleHasAccess_succeeds() throws UserNotFoundException, NotAllowedException,
-            DatabaseNotFoundException, ViewNotFoundException {
+            DatabaseNotFoundException, ViewNotFoundException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        find_generic(DATABASE_3_ID, VIEW_1_ID, DATABASE_3, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_2_USER_1_READ_ACCESS);
+        find_generic(DATABASE_3_ID, VIEW_1_ID, DATABASE_3, USER_2_ID, USER_2_PRINCIPAL, DATABASE_2_USER_1_READ_ACCESS);
     }
 
     @Test
@@ -184,7 +183,7 @@ public class ViewEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(NotAllowedException.class, () -> {
-            delete_generic(DATABASE_3_ID, VIEW_1_ID, DATABASE_3, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_2_USER_1_READ_ACCESS);
+            delete_generic(DATABASE_3_ID, VIEW_1_ID, DATABASE_3, USER_2_ID, USER_2_PRINCIPAL, DATABASE_2_USER_1_READ_ACCESS);
         });
     }
 
@@ -194,7 +193,7 @@ public class ViewEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(AccessDeniedException.class, () -> {
-            delete_generic(DATABASE_3_ID, VIEW_1_ID, DATABASE_3, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_2_USER_1_READ_ACCESS);
+            delete_generic(DATABASE_3_ID, VIEW_1_ID, DATABASE_3, USER_2_ID, USER_2_PRINCIPAL, DATABASE_2_USER_1_READ_ACCESS);
         });
     }
 
@@ -202,10 +201,10 @@ public class ViewEndpointUnitTest extends BaseUnitTest {
     @WithMockUser(username = USER_3_USERNAME, authorities = {"delete-database-view"})
     public void delete_publicOwner_succeeds() throws UserNotFoundException, NotAllowedException,
             DatabaseNotFoundException, ViewNotFoundException, DatabaseConnectionException, ViewMalformedException,
-            QueryMalformedException {
+            QueryMalformedException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        delete_generic(DATABASE_3_ID, VIEW_5_ID, DATABASE_3, USER_3_USERNAME, USER_3_PRINCIPAL, DATABASE_3_USER_1_WRITE_ALL_ACCESS);
+        delete_generic(DATABASE_3_ID, VIEW_5_ID, DATABASE_3, USER_3_ID, USER_3_PRINCIPAL, DATABASE_3_USER_1_WRITE_ALL_ACCESS);
     }
 
     @Test
@@ -213,7 +212,7 @@ public class ViewEndpointUnitTest extends BaseUnitTest {
     public void data_publicAnonymous_succeeds() throws UserNotFoundException, NotAllowedException,
             DatabaseNotFoundException, ViewNotFoundException, DatabaseConnectionException, QueryMalformedException,
             QueryStoreException, TableMalformedException, ColumnParseException, ImageNotSupportedException,
-            ContainerNotFoundException, PaginationException, ViewMalformedException {
+            ContainerNotFoundException, PaginationException, ViewMalformedException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
         data_generic(DATABASE_3_ID, VIEW_1_ID, DATABASE_3, null, null, null);
@@ -224,10 +223,10 @@ public class ViewEndpointUnitTest extends BaseUnitTest {
     public void data_publicNoRole_succeeds() throws UserNotFoundException, NotAllowedException,
             DatabaseNotFoundException, ViewNotFoundException, DatabaseConnectionException, QueryMalformedException,
             QueryStoreException, TableMalformedException, ColumnParseException, ImageNotSupportedException,
-            ContainerNotFoundException, PaginationException, ViewMalformedException {
+            ContainerNotFoundException, PaginationException, ViewMalformedException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        data_generic(DATABASE_3_ID, VIEW_1_ID, DATABASE_3, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_2_USER_1_READ_ACCESS);
+        data_generic(DATABASE_3_ID, VIEW_1_ID, DATABASE_3, USER_2_ID, USER_2_PRINCIPAL, DATABASE_2_USER_1_READ_ACCESS);
     }
 
     @Test
@@ -235,10 +234,10 @@ public class ViewEndpointUnitTest extends BaseUnitTest {
     public void data_publicHasRole_succeeds() throws UserNotFoundException, NotAllowedException,
             DatabaseNotFoundException, ViewNotFoundException, DatabaseConnectionException, QueryMalformedException,
             QueryStoreException, TableMalformedException, ColumnParseException, ImageNotSupportedException,
-            ContainerNotFoundException, PaginationException, ViewMalformedException {
+            ContainerNotFoundException, PaginationException, ViewMalformedException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        data_generic(DATABASE_3_ID, VIEW_1_ID, DATABASE_3, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_2_USER_1_READ_ACCESS);
+        data_generic(DATABASE_3_ID, VIEW_1_ID, DATABASE_3, USER_2_ID, USER_2_PRINCIPAL, DATABASE_2_USER_1_READ_ACCESS);
     }
 
     @Test
@@ -246,10 +245,10 @@ public class ViewEndpointUnitTest extends BaseUnitTest {
     public void data_publicHasRoleHasAccess_succeeds() throws UserNotFoundException, NotAllowedException,
             DatabaseNotFoundException, ViewNotFoundException, DatabaseConnectionException, QueryMalformedException,
             QueryStoreException, TableMalformedException, ColumnParseException, ImageNotSupportedException,
-            ContainerNotFoundException, PaginationException, ViewMalformedException {
+            ContainerNotFoundException, PaginationException, ViewMalformedException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        data_generic(DATABASE_3_ID, VIEW_1_ID, DATABASE_3, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_2_USER_1_READ_ACCESS);
+        data_generic(DATABASE_3_ID, VIEW_1_ID, DATABASE_3, USER_2_ID, USER_2_PRINCIPAL, DATABASE_2_USER_1_READ_ACCESS);
     }
 
     /* ################################################################################################### */
@@ -258,8 +257,7 @@ public class ViewEndpointUnitTest extends BaseUnitTest {
 
     @Test
     @WithAnonymousUser
-    public void findAll_privateAnonymous_succeeds() throws UserNotFoundException, NotAllowedException,
-            DatabaseNotFoundException {
+    public void findAll_privateAnonymous_succeeds() throws UserNotFoundException, DatabaseNotFoundException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
         findAll_generic(DATABASE_1_ID, DATABASE_1, null, null, null);
@@ -267,29 +265,26 @@ public class ViewEndpointUnitTest extends BaseUnitTest {
 
     @Test
     @WithMockUser(username = USER_2_USERNAME, authorities = {"list-views"})
-    public void findAll_privateHasRole_succeeds() throws UserNotFoundException, NotAllowedException,
-            DatabaseNotFoundException {
+    public void findAll_privateHasRole_succeeds() throws UserNotFoundException, DatabaseNotFoundException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        findAll_generic(DATABASE_1_ID, DATABASE_1, USER_2_USERNAME, USER_2_PRINCIPAL, null);
+        findAll_generic(DATABASE_1_ID, DATABASE_1, USER_2_ID, USER_2_PRINCIPAL, null);
     }
 
     @Test
     @WithMockUser(username = USER_2_USERNAME, authorities = {"list-views"})
-    public void findAll_privateHasRoleHasAccess_succeeds() throws UserNotFoundException, NotAllowedException,
-            DatabaseNotFoundException {
+    public void findAll_privateHasRoleHasAccess_succeeds() throws UserNotFoundException, DatabaseNotFoundException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        findAll_generic(DATABASE_1_ID, DATABASE_1, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_1_USER_2_READ_ACCESS);
+        findAll_generic(DATABASE_1_ID, DATABASE_1, USER_2_ID, USER_2_PRINCIPAL, DATABASE_1_USER_2_READ_ACCESS);
     }
 
     @Test
     @WithMockUser(username = USER_2_USERNAME)
-    public void findAll_privateNoRole_succeeds() throws UserNotFoundException, NotAllowedException,
-            DatabaseNotFoundException {
+    public void findAll_privateNoRole_succeeds() throws UserNotFoundException, DatabaseNotFoundException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        findAll_generic(DATABASE_1_ID, DATABASE_1, USER_2_USERNAME, USER_2_PRINCIPAL, null);
+        findAll_generic(DATABASE_1_ID, DATABASE_1, USER_2_ID, USER_2_PRINCIPAL, null);
     }
 
     @Test
@@ -308,7 +303,7 @@ public class ViewEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(NotAllowedException.class, () -> {
-            create_generic(DATABASE_1_ID, DATABASE_1, USER_2_USERNAME, USER_2_PRINCIPAL, null);
+            create_generic(DATABASE_1_ID, DATABASE_1, USER_2_ID, USER_2_PRINCIPAL, null);
         });
     }
 
@@ -318,7 +313,7 @@ public class ViewEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(NotAllowedException.class, () -> {
-            create_generic(DATABASE_1_ID, DATABASE_1, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_2_USER_1_READ_ACCESS);
+            create_generic(DATABASE_1_ID, DATABASE_1, USER_2_ID, USER_2_PRINCIPAL, DATABASE_2_USER_1_READ_ACCESS);
         });
     }
 
@@ -328,14 +323,14 @@ public class ViewEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(AccessDeniedException.class, () -> {
-            create_generic(DATABASE_1_ID, DATABASE_1, USER_2_USERNAME, USER_2_PRINCIPAL, null);
+            create_generic(DATABASE_1_ID, DATABASE_1, USER_2_ID, USER_2_PRINCIPAL, null);
         });
     }
 
     @Test
     @WithAnonymousUser
     public void find_privateAnonymous_succeeds() throws UserNotFoundException, NotAllowedException,
-            DatabaseNotFoundException, ViewNotFoundException {
+            DatabaseNotFoundException, ViewNotFoundException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
         find_generic(DATABASE_1_ID, VIEW_1_ID, DATABASE_1, null, null, null);
@@ -344,28 +339,28 @@ public class ViewEndpointUnitTest extends BaseUnitTest {
     @Test
     @WithMockUser(username = USER_2_USERNAME, authorities = {"find-database-view"})
     public void find_privateHasRole_succeeds() throws UserNotFoundException, NotAllowedException,
-            DatabaseNotFoundException, ViewNotFoundException {
+            DatabaseNotFoundException, ViewNotFoundException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        find_generic(DATABASE_1_ID, VIEW_1_ID, DATABASE_1, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_2_USER_1_READ_ACCESS);
+        find_generic(DATABASE_1_ID, VIEW_1_ID, DATABASE_1, USER_2_ID, USER_2_PRINCIPAL, DATABASE_2_USER_1_READ_ACCESS);
     }
 
     @Test
     @WithMockUser(username = USER_2_USERNAME)
     public void find_privateNoRole_succeeds() throws UserNotFoundException, NotAllowedException,
-            DatabaseNotFoundException, ViewNotFoundException {
+            DatabaseNotFoundException, ViewNotFoundException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        find_generic(DATABASE_1_ID, VIEW_1_ID, DATABASE_1, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_2_USER_1_READ_ACCESS);
+        find_generic(DATABASE_1_ID, VIEW_1_ID, DATABASE_1, USER_2_ID, USER_2_PRINCIPAL, DATABASE_2_USER_1_READ_ACCESS);
     }
 
     @Test
     @WithMockUser(username = USER_2_USERNAME)
     public void find_privateHasRoleHasAccess_succeeds() throws UserNotFoundException, NotAllowedException,
-            DatabaseNotFoundException, ViewNotFoundException {
+            DatabaseNotFoundException, ViewNotFoundException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        find_generic(DATABASE_1_ID, VIEW_1_ID, DATABASE_1, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_2_USER_1_READ_ACCESS);
+        find_generic(DATABASE_1_ID, VIEW_1_ID, DATABASE_1, USER_2_ID, USER_2_PRINCIPAL, DATABASE_2_USER_1_READ_ACCESS);
     }
 
     @Test
@@ -384,7 +379,7 @@ public class ViewEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(NotAllowedException.class, () -> {
-            delete_generic(DATABASE_1_ID, VIEW_1_ID, DATABASE_1, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_2_USER_1_READ_ACCESS);
+            delete_generic(DATABASE_1_ID, VIEW_1_ID, DATABASE_1, USER_2_ID, USER_2_PRINCIPAL, DATABASE_2_USER_1_READ_ACCESS);
         });
     }
 
@@ -394,7 +389,7 @@ public class ViewEndpointUnitTest extends BaseUnitTest {
 
         /* test */
         assertThrows(AccessDeniedException.class, () -> {
-            delete_generic(DATABASE_1_ID, VIEW_1_ID, DATABASE_1, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_2_USER_1_READ_ACCESS);
+            delete_generic(DATABASE_1_ID, VIEW_1_ID, DATABASE_1, USER_1_ID, USER_2_PRINCIPAL, DATABASE_2_USER_1_READ_ACCESS);
         });
     }
 
@@ -402,10 +397,10 @@ public class ViewEndpointUnitTest extends BaseUnitTest {
     @WithMockUser(username = USER_1_USERNAME, authorities = {"delete-database-view"})
     public void delete_privateOwner_succeeds() throws UserNotFoundException, NotAllowedException,
             DatabaseNotFoundException, ViewNotFoundException, DatabaseConnectionException, ViewMalformedException,
-            QueryMalformedException {
+            QueryMalformedException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        delete_generic(DATABASE_1_ID, VIEW_1_ID, DATABASE_1, USER_1_USERNAME, USER_1_PRINCIPAL, DATABASE_1_USER_1_WRITE_ALL_ACCESS);
+        delete_generic(DATABASE_1_ID, VIEW_1_ID, DATABASE_1, USER_1_ID, USER_1_PRINCIPAL, DATABASE_1_USER_1_WRITE_ALL_ACCESS);
     }
 
     @Test
@@ -423,10 +418,10 @@ public class ViewEndpointUnitTest extends BaseUnitTest {
     public void data_privateNoRole_succeeds() throws UserNotFoundException, NotAllowedException,
             DatabaseNotFoundException, ViewNotFoundException, DatabaseConnectionException, QueryMalformedException,
             QueryStoreException, TableMalformedException, ColumnParseException, ImageNotSupportedException,
-            ContainerNotFoundException, PaginationException, ViewMalformedException {
+            ContainerNotFoundException, PaginationException, ViewMalformedException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        data_generic(DATABASE_1_ID, VIEW_1_ID, DATABASE_1, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_2_USER_1_READ_ACCESS);
+        data_generic(DATABASE_1_ID, VIEW_1_ID, DATABASE_1, USER_2_ID, USER_2_PRINCIPAL, DATABASE_2_USER_1_READ_ACCESS);
     }
 
     @Test
@@ -434,10 +429,10 @@ public class ViewEndpointUnitTest extends BaseUnitTest {
     public void data_privateHasRole_succeeds() throws UserNotFoundException, NotAllowedException,
             DatabaseNotFoundException, ViewNotFoundException, DatabaseConnectionException, QueryMalformedException,
             QueryStoreException, TableMalformedException, ColumnParseException, ImageNotSupportedException,
-            ContainerNotFoundException, PaginationException, ViewMalformedException {
+            ContainerNotFoundException, PaginationException, ViewMalformedException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        data_generic(DATABASE_1_ID, VIEW_1_ID, DATABASE_1, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_2_USER_1_READ_ACCESS);
+        data_generic(DATABASE_1_ID, VIEW_1_ID, DATABASE_1, USER_2_ID, USER_2_PRINCIPAL, DATABASE_2_USER_1_READ_ACCESS);
     }
 
     @Test
@@ -445,32 +440,32 @@ public class ViewEndpointUnitTest extends BaseUnitTest {
     public void data_privateHasRoleHasAccess_succeeds() throws UserNotFoundException, NotAllowedException,
             DatabaseNotFoundException, ViewNotFoundException, DatabaseConnectionException, QueryMalformedException,
             QueryStoreException, TableMalformedException, ColumnParseException, ImageNotSupportedException,
-            ContainerNotFoundException, PaginationException, ViewMalformedException {
+            ContainerNotFoundException, PaginationException, ViewMalformedException, at.tuwien.exception.AccessDeniedException {
 
         /* test */
-        data_generic(DATABASE_1_ID, VIEW_1_ID, DATABASE_1, USER_2_USERNAME, USER_2_PRINCIPAL, DATABASE_2_USER_1_READ_ACCESS);
+        data_generic(DATABASE_1_ID, VIEW_1_ID, DATABASE_1, USER_2_ID, USER_2_PRINCIPAL, DATABASE_2_USER_1_READ_ACCESS);
     }
 
     /* ################################################################################################### */
     /* ## GENERIC TEST CASES                                                                            ## */
     /* ################################################################################################### */
 
-    protected void findAll_generic(Long databaseId, Database database, String username,
-                                   Principal principal, DatabaseAccess access) throws UserNotFoundException,
-            NotAllowedException, DatabaseNotFoundException {
+    protected void findAll_generic(Long databaseId, Database database, UUID userId, Principal principal,
+                                   DatabaseAccess access) throws UserNotFoundException, DatabaseNotFoundException,
+            at.tuwien.exception.AccessDeniedException {
 
         /* mock */
         when(databaseService.find(databaseId))
                 .thenReturn(database);
         if (access != null) {
-            log.trace("mock access of database with id {} and username {}", databaseId, username);
-            when(accessService.find(databaseId, username))
+            log.trace("mock access of database with id {} and user id {}", databaseId, userId);
+            when(accessService.find(databaseId, userId))
                     .thenReturn(access);
             when(viewService.findAll(databaseId, principal))
                     .thenReturn(List.of(VIEW_1, VIEW_2));
         } else {
-            log.trace("mock no access of database with id {} and username {}", databaseId, username);
-            when(accessService.find(databaseId, username))
+            log.trace("mock no access of database with id {} and user id {}", databaseId, userId);
+            when(accessService.find(databaseId, userId))
                     .thenThrow(NotAllowedException.class);
             when(viewService.findAll(databaseId, principal))
                     .thenReturn(List.of(VIEW_1));
@@ -487,10 +482,10 @@ public class ViewEndpointUnitTest extends BaseUnitTest {
         }
     }
 
-    protected void create_generic(Long databaseId, Database database, String username,
-                                  Principal principal, DatabaseAccess access) throws DatabaseNotFoundException,
-            UserNotFoundException, DatabaseConnectionException, ViewMalformedException, QueryMalformedException,
-            NotAllowedException {
+    protected void create_generic(Long databaseId, Database database, UUID userId, Principal principal,
+                                  DatabaseAccess access) throws DatabaseNotFoundException, UserNotFoundException,
+            DatabaseConnectionException, ViewMalformedException, QueryMalformedException, NotAllowedException,
+            at.tuwien.exception.AccessDeniedException {
         final ViewCreateDto request = ViewCreateDto.builder()
                 .name(VIEW_1_NAME)
                 .query(VIEW_1_QUERY)
@@ -501,12 +496,12 @@ public class ViewEndpointUnitTest extends BaseUnitTest {
         when(databaseService.find(databaseId))
                 .thenReturn(database);
         if (access != null) {
-            log.trace("mock access of database with id {} and username {}", databaseId, username);
-            when(accessService.find(databaseId, username))
+            log.trace("mock access of database with id {} and user id {}", databaseId, userId);
+            when(accessService.find(databaseId, userId))
                     .thenReturn(access);
         } else {
-            log.trace("mock no access of database with id {} and username {}", databaseId, username);
-            when(accessService.find(databaseId, username))
+            log.trace("mock no access of database with id {} and user id {}", databaseId, userId);
+            when(accessService.find(databaseId, userId))
                     .thenThrow(NotAllowedException.class);
         }
         when(viewService.create(databaseId, request, principal))
@@ -520,20 +515,20 @@ public class ViewEndpointUnitTest extends BaseUnitTest {
         assertEquals(VIEW_1_NAME, response.getBody().getName());
     }
 
-    protected void find_generic(Long databaseId, Long viewId, Database database, String username,
+    protected void find_generic(Long databaseId, Long viewId, Database database, UUID userId,
                                 Principal principal, DatabaseAccess access) throws DatabaseNotFoundException,
-            UserNotFoundException, NotAllowedException, ViewNotFoundException {
+            UserNotFoundException, NotAllowedException, ViewNotFoundException, at.tuwien.exception.AccessDeniedException {
 
         /* mock */
         when(databaseService.find(databaseId))
                 .thenReturn(database);
         if (access != null) {
-            log.trace("mock access of database with id {} and username {}", databaseId, username);
-            when(accessService.find(databaseId, username))
+            log.trace("mock access of database with id {} and user id {}", databaseId, userId);
+            when(accessService.find(databaseId, userId))
                     .thenReturn(access);
         } else {
-            log.trace("mock no access of database with id {} and username {}", databaseId, username);
-            when(accessService.find(databaseId, username))
+            log.trace("mock no access of database with id {} and user id {}", databaseId, userId);
+            when(accessService.find(databaseId, userId))
                     .thenThrow(NotAllowedException.class);
         }
         when(viewService.findById(databaseId, viewId, principal))
@@ -547,21 +542,21 @@ public class ViewEndpointUnitTest extends BaseUnitTest {
         assertEquals(VIEW_1_NAME, response.getBody().getName());
     }
 
-    protected void delete_generic(Long databaseId, Long viewId, Database database, String username,
+    protected void delete_generic(Long databaseId, Long viewId, Database database, UUID userId,
                                   Principal principal, DatabaseAccess access) throws DatabaseNotFoundException,
             UserNotFoundException, NotAllowedException, ViewNotFoundException, DatabaseConnectionException,
-            ViewMalformedException, QueryMalformedException {
+            ViewMalformedException, QueryMalformedException, at.tuwien.exception.AccessDeniedException {
 
         /* mock */
         when(databaseService.find(databaseId))
                 .thenReturn(database);
         if (access != null) {
-            log.trace("mock access of database with id {} and username {}", databaseId, username);
-            when(accessService.find(databaseId, username))
+            log.trace("mock access of database with id {} and user id {}", databaseId, userId);
+            when(accessService.find(databaseId, userId))
                     .thenReturn(access);
         } else {
-            log.trace("mock no access of database with id {} and username {}", databaseId, username);
-            when(accessService.find(databaseId, username))
+            log.trace("mock no access of database with id {} and user id {}", databaseId, userId);
+            when(accessService.find(databaseId, userId))
                     .thenThrow(NotAllowedException.class);
         }
         doNothing()
@@ -573,11 +568,12 @@ public class ViewEndpointUnitTest extends BaseUnitTest {
         assertEquals(HttpStatus.ACCEPTED, response.getStatusCode());
     }
 
-    protected void data_generic(Long databaseId, Long viewId, Database database, String username,
+    protected void data_generic(Long databaseId, Long viewId, Database database, UUID userId,
                                 Principal principal, DatabaseAccess access) throws DatabaseNotFoundException,
             UserNotFoundException, NotAllowedException, ViewNotFoundException, DatabaseConnectionException,
             QueryMalformedException, QueryStoreException, TableMalformedException, ColumnParseException,
-            ImageNotSupportedException, ContainerNotFoundException, PaginationException, ViewMalformedException {
+            ImageNotSupportedException, ContainerNotFoundException, PaginationException, ViewMalformedException,
+            at.tuwien.exception.AccessDeniedException {
         final Long page = 0L;
         final Long size = 2L;
 
@@ -585,12 +581,12 @@ public class ViewEndpointUnitTest extends BaseUnitTest {
         when(databaseService.find(databaseId))
                 .thenReturn(database);
         if (access != null) {
-            log.trace("mock access of database with id {} and username {}", databaseId, username);
-            when(accessService.find(databaseId, username))
+            log.trace("mock access of database with id {} and user id {}", databaseId, userId);
+            when(accessService.find(databaseId, userId))
                     .thenReturn(access);
         } else {
-            log.trace("mock no access of database with id {} and username {}", databaseId, username);
-            when(accessService.find(databaseId, username))
+            log.trace("mock no access of database with id {} and user id {}", databaseId, userId);
+            when(accessService.find(databaseId, userId))
                     .thenThrow(NotAllowedException.class);
         }
         when(viewService.findById(databaseId, viewId, principal))
diff --git a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/service/AccessServiceIntegrationTest.java b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/service/AccessServiceIntegrationTest.java
index f4f32b3647629540ddd3bfe65f8fa00693aeae87..cf2e31e0593ecc60b195e06605cdf50a7a4499d0 100644
--- a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/service/AccessServiceIntegrationTest.java
+++ b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/service/AccessServiceIntegrationTest.java
@@ -123,10 +123,10 @@ public class AccessServiceIntegrationTest extends BaseUnitTest {
     @ParameterizedTest
     @MethodSource("create_fails_parameters")
     protected <T extends Throwable> void create_fails(String test, Class<T> expectedException,
-                                                      AccessTypeDto accessTypeDto, String username) {
+                                                      AccessTypeDto accessTypeDto, UUID userId) {
         final DatabaseGiveAccessDto request = DatabaseGiveAccessDto.builder()
                 .type(accessTypeDto)
-                .username(username)
+                .userId(userId)
                 .build();
 
         /* mock */
@@ -141,12 +141,12 @@ public class AccessServiceIntegrationTest extends BaseUnitTest {
     @ParameterizedTest
     @MethodSource("create_succeeds_parameters")
     protected <T extends Throwable> void create_succeeds(String test, AccessTypeDto accessTypeDto, AccessType access,
-                                                         String username, UUID userId) throws UserNotFoundException,
+                                                         UUID userId) throws UserNotFoundException,
             NotAllowedException, QueryMalformedException, DatabaseNotFoundException, DatabaseMalformedException,
             KeycloakRemoteException, AccessDeniedException {
         final DatabaseGiveAccessDto request = DatabaseGiveAccessDto.builder()
                 .type(accessTypeDto)
-                .username(username)
+                .userId(userId)
                 .build();
 
         /* test */
diff --git a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/service/AccessServiceUnitTest.java b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/service/AccessServiceUnitTest.java
index 11eaf02da7944a12ec29e8023f2b06db52fa4156..60fd2a8f0603e78792061292e7d3b141aa16eefc 100644
--- a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/service/AccessServiceUnitTest.java
+++ b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/service/AccessServiceUnitTest.java
@@ -7,6 +7,7 @@ import at.tuwien.api.database.AccessTypeDto;
 import at.tuwien.api.database.DatabaseModifyAccessDto;
 import at.tuwien.entities.database.AccessType;
 import at.tuwien.entities.database.DatabaseAccess;
+import at.tuwien.exception.AccessDeniedException;
 import at.tuwien.exception.NotAllowedException;
 import at.tuwien.repository.mdb.DatabaseAccessRepository;
 import at.tuwien.repository.mdb.DatabaseRepository;
@@ -66,14 +67,14 @@ public class AccessServiceUnitTest extends BaseUnitTest {
     }
 
     @Test
-    public void find_succeeds() throws NotAllowedException {
+    public void find_succeeds() throws AccessDeniedException {
 
         /* mock */
-        when(databaseAccessRepository.findByDatabaseIdAndUsername(DATABASE_1_ID, USER_1_USERNAME))
+        when(databaseAccessRepository.findByDatabaseIdAndUserId(DATABASE_1_ID, USER_1_ID))
                 .thenReturn(Optional.of(DATABASE_1_USER_1_READ_ACCESS));
 
         /* test */
-        final DatabaseAccess response = accessService.find(DATABASE_1_ID, USER_1_USERNAME);
+        final DatabaseAccess response = accessService.find(DATABASE_1_ID, USER_1_ID);
         assertEquals(AccessType.READ, response.getType());
     }
 
@@ -81,12 +82,12 @@ public class AccessServiceUnitTest extends BaseUnitTest {
     public void find_fails() {
 
         /* mock */
-        when(databaseAccessRepository.findByDatabaseIdAndUsername(DATABASE_1_ID, USER_1_USERNAME))
+        when(databaseAccessRepository.findByDatabaseIdAndUserId(DATABASE_1_ID, USER_1_ID))
                 .thenReturn(Optional.empty());
 
         /* test */
         assertThrows(NotAllowedException.class, () -> {
-            accessService.find(DATABASE_1_ID, USER_1_USERNAME);
+            accessService.find(DATABASE_1_ID, USER_1_ID);
         });
     }
 
diff --git a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/service/DatabaseServiceIntegrationTest.java b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/service/DatabaseServiceIntegrationTest.java
index afa64ac6ad6280cde939998173d3d7eb135a759b..410add53338a7d635d7f35b105aab86b5cad54f8 100644
--- a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/service/DatabaseServiceIntegrationTest.java
+++ b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/service/DatabaseServiceIntegrationTest.java
@@ -246,7 +246,7 @@ public class DatabaseServiceIntegrationTest extends BaseUnitTest {
     protected void generic_insert(String query, Long assertQueryId) throws SQLException, QueryMalformedException {
 
         /* mock */
-        mariaDbConfig.mockGrantUserPermissions(CONTAINER_1, DATABASE_3, USER_1_USERNAME);
+        mariaDbConfig.mockGrantUserPermissions(CONTAINER_1, DATABASE_3, USER_1_USERNAME, USER_1_ID);
 
         /* test */
         final Long response = MariaDbConfig.mockSystemQueryInsert(DATABASE_3, query);
@@ -266,7 +266,7 @@ public class DatabaseServiceIntegrationTest extends BaseUnitTest {
     protected void generic_system_insert(String username, String password) throws SQLException, QueryMalformedException {
 
         /* mock */
-        mariaDbConfig.mockGrantUserPermissions(CONTAINER_1, DATABASE_3, USER_1_USERNAME);
+        mariaDbConfig.mockGrantUserPermissions(CONTAINER_1, DATABASE_3, USER_1_USERNAME, USER_1_ID);
 
         /* test */
         final Long queryId = MariaDbConfig.mockSystemQueryInsert(DATABASE_3, QUERY_4_STATEMENT, username, password);
@@ -276,7 +276,7 @@ public class DatabaseServiceIntegrationTest extends BaseUnitTest {
     protected void generic_user_insert(String username, String password) throws SQLException, QueryMalformedException {
 
         /* mock */
-        mariaDbConfig.mockGrantUserPermissions(CONTAINER_1, DATABASE_3, USER_1_USERNAME);
+        mariaDbConfig.mockGrantUserPermissions(CONTAINER_1, DATABASE_3, USER_1_USERNAME, USER_1_ID);
 
         /* test */
         final Long queryId = MariaDbConfig.mockUserQueryInsert(DATABASE_3, QUERY_4_STATEMENT, username, password);
diff --git a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/service/QueueServiceIntegrationTest.java b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/service/QueueServiceIntegrationTest.java
index de4146b122d441561d20c67c48efba9cdf4780be..c5669b5407ea0225db338a63b204364895ebf1c4 100644
--- a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/service/QueueServiceIntegrationTest.java
+++ b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/service/QueueServiceIntegrationTest.java
@@ -149,7 +149,7 @@ public class QueueServiceIntegrationTest extends BaseUnitTest {
                 }}).build();
 
         /* mock */
-        when(databaseRepository.findByDatabaseId(DATABASE_3_ID))
+        when(databaseRepository.findById(DATABASE_3_ID))
                 .thenReturn(Optional.of(DATABASE_3));
         when(tableRepository.find(DATABASE_3_ID, TABLE_8_ID))
                 .thenReturn(Optional.of(TABLE_8));
@@ -172,7 +172,7 @@ public class QueueServiceIntegrationTest extends BaseUnitTest {
                 .build();
 
         /* mock */
-        when(databaseRepository.findByDatabaseId(DATABASE_3_ID))
+        when(databaseRepository.findById(DATABASE_3_ID))
                 .thenReturn(Optional.of(DATABASE_3));
         when(tableRepository.find(DATABASE_3_ID, TABLE_8_ID))
                 .thenReturn(Optional.of(TABLE_8));
@@ -193,7 +193,7 @@ public class QueueServiceIntegrationTest extends BaseUnitTest {
                 .build();
 
         /* mock */
-        when(databaseRepository.findByDatabaseId(DATABASE_3_ID))
+        when(databaseRepository.findById(DATABASE_3_ID))
                 .thenReturn(Optional.of(DATABASE_3));
         when(tableRepository.find(DATABASE_3_ID, TABLE_8_ID))
                 .thenReturn(Optional.of(TABLE_8));
diff --git a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/service/StoreServiceIntegrationReadTest.java b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/service/StoreServiceIntegrationReadTest.java
index 2e4a3251b45c3350cb34e1f886a0155a0aaef63c..5b7d42474025e8aae6c6e8f9fb28077e3d11eac3 100644
--- a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/service/StoreServiceIntegrationReadTest.java
+++ b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/service/StoreServiceIntegrationReadTest.java
@@ -75,7 +75,7 @@ public class StoreServiceIntegrationReadTest extends BaseUnitTest {
             DatabaseNotFoundException, ImageNotSupportedException, TableMalformedException, ContainerNotFoundException {
 
         /* mock */
-        when(databaseRepository.findByDatabaseId(DATABASE_1_ID))
+        when(databaseRepository.findById(DATABASE_1_ID))
                 .thenReturn(Optional.of(DATABASE_1));
 
         /* test */
@@ -88,7 +88,7 @@ public class StoreServiceIntegrationReadTest extends BaseUnitTest {
             DatabaseNotFoundException, ImageNotSupportedException, TableMalformedException, ContainerNotFoundException {
 
         /* mock */
-        when(databaseRepository.findByDatabaseId(DATABASE_1_ID))
+        when(databaseRepository.findById(DATABASE_1_ID))
                 .thenReturn(Optional.of(DATABASE_1));
 
         /* test */
@@ -101,7 +101,7 @@ public class StoreServiceIntegrationReadTest extends BaseUnitTest {
             DatabaseConnectionException, QueryNotFoundException, DatabaseNotFoundException, ImageNotSupportedException {
 
         /* mock */
-        when(databaseRepository.findByDatabaseId(DATABASE_1_ID))
+        when(databaseRepository.findById(DATABASE_1_ID))
                 .thenReturn(Optional.of(DATABASE_1));
 
         /* test */
@@ -112,7 +112,7 @@ public class StoreServiceIntegrationReadTest extends BaseUnitTest {
     public void findOne_notFound_succeeds() {
 
         /* mock */
-        when(databaseRepository.findByDatabaseId(DATABASE_1_ID))
+        when(databaseRepository.findById(DATABASE_1_ID))
                 .thenReturn(Optional.of(DATABASE_1));
 
         /* test */
@@ -126,7 +126,7 @@ public class StoreServiceIntegrationReadTest extends BaseUnitTest {
         final Principal principal = new BasicUserPrincipal(USER_1_USERNAME);
 
         /* mock */
-        when(databaseRepository.findByDatabaseId(DATABASE_1_ID))
+        when(databaseRepository.findById(DATABASE_1_ID))
                 .thenReturn(Optional.of(DATABASE_1));
 
         /* test */
diff --git a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/validator/EndpointValidatorUnitTest.java b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/validator/EndpointValidatorUnitTest.java
index d9bdc7aff4fd86dd3e2d85a9b4f9f4fcbdda60e9..f47a3712804669ccbc4df367a4778a01deefbfd8 100644
--- a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/validator/EndpointValidatorUnitTest.java
+++ b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/validator/EndpointValidatorUnitTest.java
@@ -133,7 +133,7 @@ public class EndpointValidatorUnitTest extends BaseUnitTest {
 
     @Test
     public void validateOnlyAccessOrPublic_publicAnonymous_succeeds() throws DatabaseNotFoundException,
-            NotAllowedException {
+            NotAllowedException, AccessDeniedException {
 
         /* mock */
         when(databaseService.find(DATABASE_3_ID))
@@ -158,14 +158,14 @@ public class EndpointValidatorUnitTest extends BaseUnitTest {
 
     @Test
     public void validateOnlyAccessOrPublic_privateNoAccess_fails() throws DatabaseNotFoundException,
-            NotAllowedException {
+            AccessDeniedException {
 
         /* mock */
         when(databaseService.find(DATABASE_1_ID))
                 .thenReturn(DATABASE_1);
         doThrow(NotAllowedException.class)
                 .when(accessService)
-                .find(DATABASE_1_ID, USER_1_USERNAME);
+                .find(DATABASE_1_ID, USER_1_ID);
 
         /* test */
         assertThrows(NotAllowedException.class, () -> {
@@ -175,12 +175,12 @@ public class EndpointValidatorUnitTest extends BaseUnitTest {
 
     @Test
     public void validateOnlyAccessOrPublic_privateHasReadAccess_succeeds() throws DatabaseNotFoundException,
-            NotAllowedException {
+            NotAllowedException, AccessDeniedException {
 
         /* mock */
         when(databaseService.find(DATABASE_1_ID))
                 .thenReturn(DATABASE_1);
-        when(accessService.find(DATABASE_1_ID, USER_1_USERNAME))
+        when(accessService.find(DATABASE_1_ID, USER_1_ID))
                 .thenReturn(DATABASE_1_USER_1_READ_ACCESS);
 
         /* test */
@@ -189,12 +189,12 @@ public class EndpointValidatorUnitTest extends BaseUnitTest {
 
     @Test
     public void validateOnlyAccessOrPublic_privateHasWriteOwnAccess_succeeds() throws DatabaseNotFoundException,
-            NotAllowedException {
+            NotAllowedException, AccessDeniedException {
 
         /* mock */
         when(databaseService.find(DATABASE_1_ID))
                 .thenReturn(DATABASE_1);
-        when(accessService.find(DATABASE_1_ID, USER_1_USERNAME))
+        when(accessService.find(DATABASE_1_ID, USER_1_ID))
                 .thenReturn(DATABASE_1_USER_1_WRITE_OWN_ACCESS);
 
         /* test */
@@ -203,12 +203,12 @@ public class EndpointValidatorUnitTest extends BaseUnitTest {
 
     @Test
     public void validateOnlyAccessOrPublic_privateHasWriteAllAccess_succeeds() throws DatabaseNotFoundException,
-            NotAllowedException {
+            NotAllowedException, AccessDeniedException {
 
         /* mock */
         when(databaseService.find(DATABASE_1_ID))
                 .thenReturn(DATABASE_1);
-        when(accessService.find(DATABASE_1_ID, USER_1_USERNAME))
+        when(accessService.find(DATABASE_1_ID, USER_1_ID))
                 .thenReturn(DATABASE_1_USER_1_WRITE_ALL_ACCESS);
 
         /* test */
@@ -217,7 +217,7 @@ public class EndpointValidatorUnitTest extends BaseUnitTest {
 
     @Test
     public void validateOnlyAccessOrPublic2_privateAnonymousHasPublicIdentifier_succeeds() throws DatabaseNotFoundException,
-            NotAllowedException {
+            NotAllowedException, AccessDeniedException {
 
         /* mock */
         when(databaseService.find(DATABASE_1_ID))
@@ -250,7 +250,7 @@ public class EndpointValidatorUnitTest extends BaseUnitTest {
 
     @Test
     public void validateOnlyAccessOrPublic2_privateCreatorHasSelfIdentifier_succeeds() throws DatabaseNotFoundException,
-            NotAllowedException {
+            NotAllowedException, AccessDeniedException {
         final Identifier identifier = Identifier.builder()
                 .visibility(VisibilityType.SELF)
                 .createdBy(USER_1_ID)
@@ -277,12 +277,12 @@ public class EndpointValidatorUnitTest extends BaseUnitTest {
 
     @Test
     public void validateOnlyWriteOwnOrWriteAllAccess_privateHasReadAccess_fails() throws NotAllowedException,
-            TableNotFoundException, DatabaseNotFoundException {
+            TableNotFoundException, DatabaseNotFoundException, AccessDeniedException {
 
         /* mock */
         when(tableService.find(DATABASE_1_ID, TABLE_1_ID))
                 .thenReturn(TABLE_1);
-        when(accessService.find(DATABASE_1_ID, USER_1_USERNAME))
+        when(accessService.find(DATABASE_1_ID, USER_1_ID))
                 .thenReturn(DATABASE_1_USER_1_READ_ACCESS);
 
         /* test */
@@ -293,12 +293,12 @@ public class EndpointValidatorUnitTest extends BaseUnitTest {
 
     @Test
     public void validateOnlyWriteOwnOrWriteAllAccess_privateHasWriteOwnAccess_succeeds() throws NotAllowedException,
-            TableNotFoundException, DatabaseNotFoundException {
+            TableNotFoundException, DatabaseNotFoundException, AccessDeniedException {
 
         /* mock */
         when(tableService.find(DATABASE_1_ID, TABLE_1_ID))
                 .thenReturn(TABLE_1);
-        when(accessService.find(DATABASE_1_ID, USER_1_USERNAME))
+        when(accessService.find(DATABASE_1_ID, USER_1_ID))
                 .thenReturn(DATABASE_1_USER_1_WRITE_OWN_ACCESS);
 
         /* test */
@@ -307,7 +307,7 @@ public class EndpointValidatorUnitTest extends BaseUnitTest {
 
     @Test
     public void validateOnlyWriteOwnOrWriteAllAccess_privateHasWriteAllAccess_succeeds() throws NotAllowedException,
-            TableNotFoundException, DatabaseNotFoundException {
+            TableNotFoundException, DatabaseNotFoundException, AccessDeniedException {
         final Table table = Table.builder()
                 .ownedBy(USER_2_ID)
                 .build();
@@ -315,7 +315,7 @@ public class EndpointValidatorUnitTest extends BaseUnitTest {
         /* mock */
         when(tableService.find(DATABASE_1_ID, 9999L))
                 .thenReturn(table);
-        when(accessService.find(DATABASE_1_ID, USER_1_USERNAME))
+        when(accessService.find(DATABASE_1_ID, USER_1_ID))
                 .thenReturn(DATABASE_1_USER_1_WRITE_ALL_ACCESS);
 
         /* test */
diff --git a/dbrepo-metadata-service/services/src/main/java/at/tuwien/service/AccessService.java b/dbrepo-metadata-service/services/src/main/java/at/tuwien/service/AccessService.java
index 707b5b75cae1050513897da712a1ed04f5a6cad2..d3f4619ea0e9697706cca5f531583bcf7d9f26eb 100644
--- a/dbrepo-metadata-service/services/src/main/java/at/tuwien/service/AccessService.java
+++ b/dbrepo-metadata-service/services/src/main/java/at/tuwien/service/AccessService.java
@@ -22,25 +22,15 @@ public interface AccessService {
      */
     DatabaseAccess find(Long databaseId, UUID userId) throws AccessDeniedException;
 
-    /**
-     * Checks if user with username has access to database with given id.
-     *
-     * @param databaseId The database id.
-     * @param username   The username.
-     * @return True if user has access, False otherwise.
-     * @throws NotAllowedException The access is denied.
-     */
-    DatabaseAccess find(Long databaseId, String username) throws NotAllowedException;
-
     /**
      * Checks if the user with username has access to the database with given id.
      *
      * @param databaseId The database id.
-     * @param username   The username.
+     * @param userId     The user id.
      * @return The access object.
      * @throws NotAllowedException The user does not have access.
      */
-    DatabaseAccess hasAccess(Long databaseId, String username) throws NotAllowedException;
+    DatabaseAccess hasAccess(Long databaseId, UUID userId) throws NotAllowedException;
 
     /**
      * Give somebody access to a database of container.
@@ -53,7 +43,9 @@ public interface AccessService {
      * @throws QueryMalformedException    The mapped access query is malformed.
      * @throws DatabaseMalformedException The database has an invalid state.
      */
-    void create(Long databaseId, DatabaseGiveAccessDto accessDto) throws DatabaseNotFoundException, UserNotFoundException, NotAllowedException, QueryMalformedException, DatabaseMalformedException, KeycloakRemoteException, AccessDeniedException;
+    void create(Long databaseId, DatabaseGiveAccessDto accessDto) throws DatabaseNotFoundException,
+            UserNotFoundException, NotAllowedException, QueryMalformedException, DatabaseMalformedException,
+            KeycloakRemoteException, AccessDeniedException;
 
     /**
      * Update access to a database.
@@ -67,7 +59,8 @@ public interface AccessService {
      * @throws QueryMalformedException    The mapped access query is malformed.
      * @throws DatabaseMalformedException The database has an invalid state.
      */
-    void update(Long databaseId, UUID userId, DatabaseModifyAccessDto accessDto) throws DatabaseNotFoundException, UserNotFoundException, QueryMalformedException, DatabaseMalformedException,
+    void update(Long databaseId, UUID userId, DatabaseModifyAccessDto accessDto) throws DatabaseNotFoundException,
+            UserNotFoundException, QueryMalformedException, DatabaseMalformedException,
             NotAllowedException, KeycloakRemoteException, AccessDeniedException;
 
     /**
@@ -81,5 +74,7 @@ public interface AccessService {
      * @throws QueryMalformedException    The mapped access query is malformed.
      * @throws DatabaseMalformedException The database has an invalid state.
      */
-    void delete(Long databaseId, UUID userId) throws DatabaseNotFoundException, UserNotFoundException, NotAllowedException, QueryMalformedException, DatabaseMalformedException, KeycloakRemoteException, AccessDeniedException;
+    void delete(Long databaseId, UUID userId) throws DatabaseNotFoundException, UserNotFoundException,
+            NotAllowedException, QueryMalformedException, DatabaseMalformedException, KeycloakRemoteException,
+            AccessDeniedException;
 }
diff --git a/dbrepo-metadata-service/services/src/main/java/at/tuwien/service/impl/AccessServiceImpl.java b/dbrepo-metadata-service/services/src/main/java/at/tuwien/service/impl/AccessServiceImpl.java
index 9f6c10be734f2cf695493bb47bac8e14b6e544cc..be5b7cf1a5f29975d8efc65f3685946310ecbbc5 100644
--- a/dbrepo-metadata-service/services/src/main/java/at/tuwien/service/impl/AccessServiceImpl.java
+++ b/dbrepo-metadata-service/services/src/main/java/at/tuwien/service/impl/AccessServiceImpl.java
@@ -32,17 +32,15 @@ import java.util.UUID;
 public class AccessServiceImpl extends HibernateConnector implements AccessService {
 
     private final UserMapper userMapper;
-    private final UserService userService;
     private final DatabaseMapper databaseMapper;
     private final DatabaseService databaseService;
     private final KeycloakGateway keycloakGateway;
     private final DatabaseAccessRepository databaseAccessRepository;
 
     @Autowired
-    public AccessServiceImpl(UserMapper userMapper, UserService userService, DatabaseMapper databaseMapper, DatabaseService databaseService,
+    public AccessServiceImpl(UserMapper userMapper, DatabaseMapper databaseMapper, DatabaseService databaseService,
                              KeycloakGateway keycloakGateway, DatabaseAccessRepository databaseAccessRepository) {
         this.userMapper = userMapper;
-        this.userService = userService;
         this.databaseMapper = databaseMapper;
         this.databaseService = databaseService;
         this.keycloakGateway = keycloakGateway;
@@ -55,31 +53,21 @@ public class AccessServiceImpl extends HibernateConnector implements AccessServi
         return databaseAccessRepository.findByHdbid(databaseId);
     }
 
-    @Override
-    public DatabaseAccess find(Long databaseId, UUID userId) throws AccessDeniedException {
-        final Optional<DatabaseAccess> optional = databaseAccessRepository.findByHdbidAndHuserid(databaseId, userId);
-        if (optional.isEmpty()) {
-            log.error("Failed to find access for user with id {}", userId);
-            throw new AccessDeniedException("Failed to find access");
-        }
-        return optional.get();
-    }
-
     @Override
     @Transactional(readOnly = true)
-    public DatabaseAccess find(Long databaseId, String username) throws NotAllowedException {
-        final Optional<DatabaseAccess> optional = databaseAccessRepository.findByDatabaseIdAndUsername(databaseId, username);
+    public DatabaseAccess find(Long databaseId, UUID userId) throws AccessDeniedException {
+        final Optional<DatabaseAccess> optional = databaseAccessRepository.findByDatabaseIdAndUserId(databaseId, userId);
         if (optional.isEmpty()) {
             log.error("Failed to find database access for database with id {}", databaseId);
-            throw new NotAllowedException("Failed to find database access");
+            throw new AccessDeniedException("Failed to find database access for database with id " + databaseId);
         }
         return optional.get();
     }
 
     @Override
     @Transactional(readOnly = true)
-    public DatabaseAccess hasAccess(Long databaseId, String username) throws NotAllowedException {
-        final Optional<DatabaseAccess> optional = databaseAccessRepository.findByDatabaseIdAndUsername(databaseId, username);
+    public DatabaseAccess hasAccess(Long databaseId, UUID userId) throws NotAllowedException {
+        final Optional<DatabaseAccess> optional = databaseAccessRepository.findByHdbidAndHuserid(databaseId, userId);
         if (optional.isEmpty()) {
             log.error("Failed to retrieve access, not found");
             throw new NotAllowedException("Failed to retrieve access");
@@ -95,9 +83,9 @@ public class AccessServiceImpl extends HibernateConnector implements AccessServi
         /* check */
         final Database database = databaseService.findById(databaseId);
         final Container container = database.getContainer();
-        final UserDto user = userMapper.keycloakUserDtoToUserDto(keycloakGateway.findByUsername(accessDto.getUsername()));
-        if (databaseAccessRepository.findByDatabaseIdAndUsername(databaseId, accessDto.getUsername()).isPresent()) {
-            log.error("Failed to give access to user with username {}, has already permission", accessDto.getUsername());
+        final UserDto user = userMapper.keycloakUserDtoToUserDto(keycloakGateway.findById(accessDto.getUserId()));
+        if (databaseAccessRepository.findByDatabaseIdAndUserId(databaseId, user.getId()).isPresent()) {
+            log.error("Failed to give access to user with id {}, has already permission", accessDto.getUserId());
             throw new NotAllowedException("Failed to give access");
         }
         final ComboPooledDataSource dataSource = getPrivilegedDataSource(container.getImage(), container, database);
@@ -107,7 +95,7 @@ public class AccessServiceImpl extends HibernateConnector implements AccessServi
             final PreparedStatement preparedStatement1 = databaseMapper.userToRawCreateUserQuery(connection, user);
             preparedStatement1.executeUpdate();
             /* grant access */
-            final PreparedStatement preparedStatement2 = databaseMapper.rawGrantUserAccessQuery(connection, accessDto);
+            final PreparedStatement preparedStatement2 = databaseMapper.rawGrantUserAccessQuery(connection, user.getUsername(), accessDto.getType());
             preparedStatement2.executeUpdate();
             final PreparedStatement preparedStatement3 = databaseMapper.rawGrantUserProcedure(connection, user.getUsername());
             preparedStatement3.executeUpdate();
@@ -139,14 +127,14 @@ public class AccessServiceImpl extends HibernateConnector implements AccessServi
         }
         final at.tuwien.api.user.UserDto user = userMapper.keycloakUserDtoToUserDto(keycloakGateway.findById(userId));
         final ComboPooledDataSource dataSource = getPrivilegedDataSource(container.getImage(), container, database);
-        final DatabaseGiveAccessDto giveAccess = databaseMapper.databaseModifyAccessToDatabaseGiveAccessDto(user.getUsername(), accessDto);
+        final DatabaseGiveAccessDto giveAccess = databaseMapper.databaseModifyAccessToDatabaseGiveAccessDto(userId, accessDto.getType());
         try {
             final Connection connection = dataSource.getConnection();
             /* create user if not exists */
             final PreparedStatement preparedStatement1 = databaseMapper.userToRawCreateUserQuery(connection, user);
             preparedStatement1.executeUpdate();
             /* grant access */
-            final PreparedStatement preparedStatement2 = databaseMapper.rawGrantUserAccessQuery(connection, giveAccess);
+            final PreparedStatement preparedStatement2 = databaseMapper.rawGrantUserAccessQuery(connection, user.getUsername(), accessDto.getType());
             preparedStatement2.executeUpdate();
             final PreparedStatement preparedStatement3 = databaseMapper.rawGrantUserProcedure(connection, user.getUsername());
             preparedStatement3.executeUpdate();
diff --git a/dbrepo-metadata-service/services/src/main/java/at/tuwien/service/impl/MariaDbServiceImpl.java b/dbrepo-metadata-service/services/src/main/java/at/tuwien/service/impl/MariaDbServiceImpl.java
index 9d8b95e4fd6d8d957b8cf96e8b04fc631a962bcd..24b6de07cbd6296a5260f2f0199afcb5b1ce2fab 100644
--- a/dbrepo-metadata-service/services/src/main/java/at/tuwien/service/impl/MariaDbServiceImpl.java
+++ b/dbrepo-metadata-service/services/src/main/java/at/tuwien/service/impl/MariaDbServiceImpl.java
@@ -55,7 +55,7 @@ public class MariaDbServiceImpl extends HibernateConnector implements DatabaseSe
 
     @Override
     public Database find(Long databaseId) throws DatabaseNotFoundException {
-        final Optional<Database> database = databaseRepository.findByDatabaseId(databaseId);
+        final Optional<Database> database = databaseRepository.findById(databaseId);
         if (database.isEmpty()) {
             log.error("Failed to find database with id {}", databaseId);
             throw new DatabaseNotFoundException("could not find database with this id");