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.  [ 4 posts ] 
Author Message
 Post subject: strange many-to-many association
PostPosted: Wed Nov 24, 2004 2:10 pm 
Regular
Regular

Joined: Tue Oct 12, 2004 9:02 am
Posts: 66
Location: Italy
I have a table ITEMS and a table CATEGORY with a many-to-may association.
The problem is that the linking table have some entry with category_id null:

ITEM_ID | CATEGORY_ID | ID

1 1 1
1 2 2
....

10 null 100


And using <many-to-many> usual mapping, between ITEMS and CATEGORIES, hibernate throws exception and I think it is because of the nulls!

How to tell to hibernate that null on category should be retrieved ad item with no category?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 24, 2004 2:20 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
try adding a where (xxx is not null)attribute in your mapping file

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 24, 2004 4:34 pm 
Regular
Regular

Joined: Tue Oct 12, 2004 9:02 am
Posts: 66
Location: Italy
In the collection element:
<set name="..." table=".." where="category_id is not null">

or in the class element of the link table (I have not a class for the linking table at the moment, so i should create the new mapping).

<class name="ItemCategory"....where="category_id is not null">...

because in the set element doesn't solve the problem.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 24, 2004 5:02 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
try both, turn on sql and see what happen

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


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

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.