Now I have another question with regards to collections in general.
I tried to do this: Set subCategories;
public void setSubCategories() public Set getSubCategories() public void addSubCategory() public void removeSubCategory()
in add and remove I refer to the collection subCategories.add(subCat) and inversely for remove. When I put this through my test class it spit up a nasty reflection error so I went back to using the setSubCategories() instead and everything worked alright.
It would be nice to have a helper method like this defined in my class, is it possible with Hibernate though?
Thanks, Warner
On Wednesday, September 10, 2003, at 08:26 AM, [EMAIL PROTECTED] wrote:
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
------------------------------------------------------- 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