i've implemented a composite pattern/tree. That means i have a Parent and a Leaf Class, both descending from the Class Components. The parent class has an attribute that contains a List of Components. This is being saved properly in the Database using Hibernate. When i want to display this tree i get the root element from the database with
Parent root = (Parent) session.createQuery("FROM Parent WHERE id=1").uniqueResult();
and then iterate recursively over the ComponentsList Attribute of this Parent object.
Now we come to my problem: I want to limit the result from the database dynamically. For example the leafs have an integer attribute called "size", and i want to show only that leafs in the tree, that have a leaf.size greater than 100 (i get the value 100 from an html form).
How do I do this? What do i have to change at the code being shown above so that it works? I have something in mind like (its just pseudo code):
session.createQuery("FROM Parent WHERE id=1").limitGT(Leaf.class, "size", 100).uniqeResult();