You can't. A hierarchical query like this requires either:
- procedural code, which SQL doesn't provide
or
- proprietary vendor extensions like CONNECT BY or SELECT RECURSIVE
which internally, are executed as a procedure with recursive semantics. You either have to write and call a stored procedure and call it with Hibernate 2.1 createSQLQuery() or fall use the proprietary vendor function in direct SQL, again with a createSQLQuery() or with a fallback to a SQL connection.
P.S. We are working on a solution for this problem, but it won't be ready soon.
_________________ JAVA PERSISTENCE WITH HIBERNATE http://jpwh.org Get the book, training, and consulting for your Hibernate team.
|