I have a really simple problem where I want to create hierarchical "Category" where I'm using a legacy mysql database structure. (I searched the forums for a similar problem but couldn't find anything)
The current structure defines a Category as being a root Category if the parent_category column value is 0.
So in my hibernate mapping I have the following:
Code:
<class name="com.mydomain.myproject.Category" table="wp_categories" >
<id name="id" column="cat_ID" type="java.lang.Long" unsaved-value="0">
<generator class="identity"/>
</id>
<property name="name" column="cat_name" type="java.lang.String" />
<property name="description" column="category_description" type="java.lang.String" />
<many-to-one name="parent" column="category_parent" />
</class>
Is there a way to define the many-to-one mapping such that it the parent object will be null? I keep getting a "UnresolvableObjectException: No row with the given identifier exists: 0"
I would rather not redefine my mysql database because it's a legacy structure and I am still planning on using the older software that accesses it.