@Override
    public void updateGuest(Guest guest) {    
        checkDataSource();
        
        validateCreateUpdate(guest);    
        
        if(guest.getId() == null) {
            throw new IllegalArgumentException("Guest id is null");
        }                
        if(guest.getId() <= 0) {
            throw new IllegalArgumentException("Guest id must be positive");
        }
                
        Long tmp = getGuestIdWithGivenIdentityCard(guest.getIdentityCardNumber());
        if(tmp != null && tmp != guest.getId()) { // exists room with different ID but same number
            // ID cannot be changed
            throw new IllegalArgumentException("Another guest with given identityCardNumber "
                    + "(and different ID) already exists");
        }
        
        Connection conn = null;
        PreparedStatement st = null;
        try {
            conn = dataSource.getConnection();
                //set AutoComit to off and closeQuietly se it on on
            conn.setAutoCommit(false);
            st = conn.prepareStatement(
                "UPDATE guest SET name=?, surname=?, identityCardNumber=?, gender=? WHERE id=?");
            st.setString(1, guest.getName().trim()); //replace method replaceAll("\\s", "")); with trim() and on elsewhere
            st.setString(2, guest.getSurname().trim());
            st.setString(3, guest.getIdentityCardNumber().trim());
            st.setString(4, guest.getGender().name());
            st.setLong(5, guest.getId());
            
            int updatedGuest = st.executeUpdate();
            if(updatedGuest != 1) {
                throw new ServiceFailureException("Internal Error: More rows( updatedGuest:"+ updatedGuest + ") "
                        + "updated when trying to update guest " + guest);
            }
            
            conn.commit();
        } catch(SQLException ex) {
            String msg = "Error when updating guest in the db";
            logger.log(Level.SEVERE, msg, ex);
            throw new ServiceFailureException(msg, ex);
        } finally {
            DBUtils.doRollbackQuietly(conn);
            DBUtils.closeQuietly(conn, st);
        }
        
    }