Accessing the Db entity in the RPC Controller

My objective is to download a document for a given id. In this regard I get the id from the caller via route mydomain.com/v1/documents/download[/:id], search for the id in the db(for documents table), gets the file_name from the db table, form the URL and return the URL to the caller.

My question is how do I access the entity in the DownloadController? Can I use HAL for this; can someone provide the snippet for this.

Thanks in advance.