def query(<EOL>self,<EOL>filters=None,<EOL>order_column="<STR_LIT>",<EOL>order_direction="<STR_LIT>",<EOL>page=None,<EOL>page_size=None,<EOL>select_columns=None,<EOL>):
query = self.session.query(self.obj)<EOL>query = self._query_select_options(query, select_columns)<EOL>if len(order_column.split('<STR_LIT:.>')) >= <NUM_LIT:2>:<EOL><INDENT>for join_relation in order_column.split('<STR_LIT:.>')[:-<NUM_LIT:1>]:<EOL><INDENT>relation_tuple = self.get_related_model_and_join(join_relation)<EOL>model_relation, relation_join = relation_tuple<EOL>if not self.is_model_already_joinded(query, model_relation):<EOL><INDENT>query = query.join(model_relation, relation_join, isouter=True)<EOL><DEDENT><DEDENT><DEDENT>query_count = self.session.query(func.count('<STR_LIT:*>')).select_from(self.obj)<EOL>query_count = self._get_base_query(query=query_count, filters=filters)<EOL>query = self._get_base_query(<EOL>query=query,<EOL>filters=filters,<EOL>order_column=order_column,<EOL>order_direction=order_direction,<EOL>)<EOL>count = query_count.scalar()<EOL>if page:<EOL><INDENT>query = query.offset(page * page_size)<EOL><DEDENT>if page_size:<EOL><INDENT>query = query.limit(page_size)<EOL><DEDENT>return count, query.all()<EOL>
QUERY
:param filters:
    dict with filters {<col_name>:<value,...}
:param order_column:
    name of the column to order
:param order_direction:
    the direction to order <'asc'|'desc'>
:param page:
    the current page
:param page_size:
    the current page size