diff -r fd8c40ff78c3 -r 824d4042c857 src/main/java/de/uapcore/lightpit/dao/UserDao.java --- a/src/main/java/de/uapcore/lightpit/dao/UserDao.java Sat May 09 15:19:21 2020 +0200 +++ b/src/main/java/de/uapcore/lightpit/dao/UserDao.java Sat May 09 17:01:29 2020 +0200 @@ -1,8 +1,8 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * + * * Copyright 2018 Mike Becker. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * @@ -30,50 +30,6 @@ import de.uapcore.lightpit.entities.User; -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.ArrayList; -import java.util.List; - -public class UserDao { - - /** - * Maps SQL columns to POJO fields. - * - * @param result the database result set - * @param user the POJO - * @throws SQLException on any kind of SQL errors - */ - protected void mapColumns(ResultSet result, User user) throws SQLException { - user.setUserID(result.getInt("userid")); - user.setUsername(result.getString("username")); - user.setGivenname(result.getString("givenname")); - user.setLastname(result.getString("lastname")); - } +public interface UserDao extends GenericDao { - /** - * Returns a list of all users ordered by their username. - *

- * Does not return reserved system users with negative user IDs. - * - * @param conn the connection to use - * @return a list of all users - * @throws SQLException on any kind of SQL errors - */ - public List listAll(Connection conn) throws SQLException { - List list = new ArrayList<>(); - try ( - Statement stmt = conn.createStatement(); - ResultSet result = stmt.executeQuery( - "SELECT * FROM lpitcore_user WHERE userid >= 0 ORDER BY username")) { - while (result.next()) { - final User user = new User(); - mapColumns(result, user); - list.add(user); - } - } - return list; - } }