On Tuesday, September 9, 2003, at 07:07 PM, Gavin King wrote:
Theres nothing particularly special about this. Just map it as you would any other association.
The only problem is your -1, which breaks referential integrity of the whole table! just switch to using an SQL null.
Ok, I guess this is where I'm having a problem. How do I map this like any other association? BTW - I'm using Xdoclet for my mapping generation.
Here's what I defined for my collection:
<id
name="id"
column="id"
type="string"
>
<generator class="assigned">
</generator>
</id> <property
name="parentId"
type="string"
update="true"
insert="true"
column="parentid"
/>
<set
name="subCategories"
table="category"
lazy="false"
inverse="false"
cascade="all"
sort="unsorted"
> <key
column="parentid"
/> <one-to-many
class="Category"
/>
</set>Thanks for the assistance.
-warner
[EMAIL PROTECTED] wrote:
Alright, so I've searched all over the web (this list doesn't appear to be archived either), so here I am ;-).
I am finally getting into using Hibernate on a few projects and have run across something that I'm sure how it would be handled. I have one table that uses itself as a collection.
Basically the table looks like this: create table Category ( id VARCHAR(255) not null, parentid VARCHAR(255), name VARCHAR(255), description VARCHAR(255), primary key (id) )
Where parentid is the parent of this category. If it's -1 then it's a root category (if there's a better way to do this please let me know.
What I'm unclear on is how to represent this in a mapping (and class-wise). I want to have a method getSubCategories which will return a set of Categories.
Thanks in advance, Warner
------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ hibernate-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/hibernate-devel
------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ hibernate-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/hibernate-devel
------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ hibernate-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/hibernate-devel
