The only problem is your -1, which breaks referential integrity of the whole table! just switch to using an SQL null.
[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