Abstract. Hierarchical and graph data structures are common in practical application development. In order to query such data, one can use SQL:1999 recursive queries based on Common Table Expressions. Nowadays, numerous relational database management systems implement them. However, some popular systems, e.g. MySQL, still lack this useful feature. In this paper we show three methods to circumvent this situation: (1) the direct loop, (2) horizontal unrolling and (3) vertical unrolling. We analyze them and present a report on tests of their efficiency. We also describe our implementation of these methods as a prototype extension to Hibernate, a major object-relational mapping system. This extension allows running SQL:1999 recursive queries directly from an application code, even when the underlying DBMS does not support them.