@Override
    public void save(Client client) throws DAOException {
        BaseDAO baseDAO = new BaseDAOImpl();
        PreparedStatement stmtClient = null;
		try (Connection conn = baseDAO.openConnection()) {
			if (client.getId() == -1) {
				stmtClient = getQuery(QueryType.INSERT, client, conn);
				if (stmtClient.executeUpdate() == 0) {
					throw new DAOException("Impossible to save Client in DB. Transaction is rolled back");
				}
				ResultSet resultSet = stmtClient.getGeneratedKeys();
				if (resultSet == null || !resultSet.next()) {
					throw new DAOException("Impossible to save in DB. Can't get clientID.");
				}
				client.setId(resultSet.getInt(1));
				if (resultSet != null) { resultSet.close(); }
				logger.fine(String.format("The client [%d | %s | %s] INSERTED in DB",
						client.getId(), client.getName(), client.getCity()));
			} else {
				stmtClient = getQuery(QueryType.UPDATE, client, conn);
				if (stmtClient.executeUpdate() == 0) {
					throw new DAOException("Impossible to update Client in DB. Transaction is rolled back");
				}
				logger.fine(String.format("The client [%d | %s | %s] UPDATED in DB",
						client.getId(), client.getName(), client.getCity()));
			}
			if (stmtClient != null) { stmtClient.close(); }

			for (Account acc : client.getAccounts()) {
				ServiceFactory.getAccountDAO().save(acc, client.getId());
			}
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			baseDAO.closeConnection();
		}
    }