@Override
    public void accommodateGuestInRoom(Guest guest, Room room) {
        //throw new UnsupportedOperationException("Not supported yet.");
        
        if(guest == null) {
            throw new IllegalArgumentException("Guest is null");
        }        
        if(guest.getId() == null) {
            throw new IllegalArgumentException("ID of guest is null");
        }        
        if(guest.getId() <= 0L) {
            throw new IllegalArgumentException("ID of guest must be a positive integer");
        }
        if(room == null) {
            throw new IllegalArgumentException("Room is null");
        }        
        if(room.getId() == null) {
            throw new IllegalArgumentException("ID of room is null");
        }
        if(room.getId() <= 0L) {
            throw new IllegalArgumentException("ID of room must be a positive integer");
        }
        
        Connection conn = null;
        PreparedStatement st = null;
        try {
            conn = dataSource.getConnection();
            //##//conn = connection; // added
            // Temporary turn autocommit mode off. It is turned back on in 
            // method DBUtils.closeQuietly(...) 
            conn.setAutoCommit(false);
            checkIfRoomHasSpace(conn, room);
            
            st = conn.prepareStatement(
                    "UPDATE Guest SET roomId = ? WHERE id = ? AND roomId IS NULL"); // předělat!!!
            st.setLong(1, room.getId());
            st.setLong(2, guest.getId());
            int count = st.executeUpdate();
            if(count == 0) {
            //if(count != 1) {
                throw new IllegalArgumentException("Guest " + guest + 
                        " not found or it is already placed in some room");
            }
            DBUtils.checkUpdatesCount(count, guest, false);            
            conn.commit();
        } catch (SQLException ex) {
            String msg = "Error when putting guest into room";
            logger.log(Level.SEVERE, msg, ex);
            throw new ServiceFailureException(msg, ex);
        } finally {
            DBUtils.doRollbackQuietly(conn);
            DBUtils.closeQuietly(conn, st);
            /*
            // added:
            if(st != null) {
                try {
                    st.close();
                } catch (SQLException ex) {
                    logger.log(Level.SEVERE, null, ex);
                }
            }
            */
        }
    }