<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_object_from_session(entity, key):
 """Get an object from the database given an entity and the session key. :param entity: Class type of the object to retrieve. :param key: Array that defines the path of the value inside the message. """

    def object_from_session_function(service, message):
        """Actual implementation of get_object_from_session function.

        :param service: SelenolService object.
        :param message: SelenolMessage request.
        """
        id_ = get_value_from_session(key)(service, message)
        result = service.session.query(entity).get(id_)
        if not result:
            raise SelenolInvalidArgumentException(key, id_)
        return result
    return object_from_session_function