These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Many-to-many newbie question
PostPosted: Fri Jul 14, 2006 2:36 pm 
Newbie

Joined: Fri Jul 14, 2006 2:21 pm
Posts: 2
First off all, i'd like to say that my english is not that good, so please aplogize all grammar mistakes.

Well, i'm using hibernate and i'm kind of newbie with this tool.
My situation:

I have 2 classes (item and category) and a many to many relationship between them (my category class has a set of items)

my mapping:

Quote:
<hibernate-mapping>
<class name="pckg.category" table="CATEGORIES" discriminator-value="P">
<id name="id" column="categoryCode" type="integer" unsaved-value="null">
<generator class="native"/>
</id>

<property name="description" type="string" length="29"/>
(..)
<property name="otherString" type="string" length="29"/>

<set name="promotions" table="ITEMS_CATEGORIES" cascade="all">
<key column="CATEGORYCODE"/>
<many-to-many column="itemID" class="pckg.item"/>
</set>
</class>
</hibernate-mapping>


So, with this mapping, when i ask for a category (using criteria) i get a set with all the items of this category. And when I delete a category, all the items are deleted. That's fine, but I have a problem that I don't know how to solve:

I need to get all the categories that has no items. How could I do it? I know that probably I have to use criteria or HQL, but I don't know how :(

Tnx in advance!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.