I have this mapping:
Code:
<hibernate-mapping>
<class name="org.appfuse.model.Category" table="CATEGORY">
<id name="id" type="long" column="CATEGORY_ID">
<generator class="increment"/>
</id>
<property name="name" type="string" column="CATEGORY_NAME" not-null="true"/>
<list name="parents" table="CATEGORY_STRUCTURE">
<key column="CATEGORY_ID"/>
<index column="POSITION"/>
<composite-element class="org.appfuse.model.CategoryStructure">
<many-to-one name="parent" class="org.appfuse.model.Category" column="PARENT_ID"/>
</composite-element>
</list>
</class>
</hibernate-mapping>
This works well for grabbing the parents of a category, but I also need to grab the children as well. The SQL code I'd use to do this would look something like:
Code:
SELECT CATEGORY_ID FROM CATEGORY_STRUCTURE WHERE PARENT_ID=fooId;
The only problem is I'm having trouble figuring out how to write this query in HSQL. Could somebody point me in the right direction?
Thanks,
PJ