-->
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.  [ 8 posts ] 
Author Message
 Post subject: Exlcuding an item from a list in mappings
PostPosted: Tue Dec 18, 2007 12:34 pm 
Newbie

Joined: Tue Dec 18, 2007 12:18 pm
Posts: 4
Location: Madrid
hi,

i've got two tables
Code:
[Container]-->[Modules]


Container has a list of modules and also container has an attribute named *special* that points to a, ehm, special module.

I want to map the list of modules exluding the *special*. Before adding the *special* feature I coded the relationship as a list:

Code:
<list name=modules" table="UI_MODULES" lazy="false" fetch="join">
   <key column="UUID_CONTAINER"/>
   <list-index column="position"/>
   <one-to-many class="domain.Module"/>
</list>


and now added the *special* mapping:
Code:
<many-to-one name="special" class="domain.Module" column="special_uuid" lazy="false" insert="false" update="false" not-null="true"/>


How do I exclude from the list the desired module??

In SQL it could be
Code:
where ui_modules.uuid <> container.special_uuid


thanks!!!!

Hibernate version: 3


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 18, 2007 12:42 pm 
Beginner
Beginner

Joined: Wed May 16, 2007 7:12 am
Posts: 41
Location: London
Happy holidays :)

Would filters be what you are looking for?
http://www.hibernate.org/hib_docs/v3/reference/en/html/objectstate.html#objectstate-filtering

I believe the SQL example that you posted would have the hibernate equivalent of
Code:
Criteria crit = session.createCriteria(Cat.class);
crit.add( Expression.ne( "color", eg.Color.BLACK ) );

_________________
Dinesh Mahadevan

Visit me at http://www.yelani.com/


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 18, 2007 1:02 pm 
Newbie

Joined: Tue Dec 18, 2007 12:18 pm
Posts: 4
Location: Madrid
Happy holidays ;)

I am trying to get it thru the mapping file because the modules list is aggresivelly loaded while retrieving the container.

Thanks!!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 18, 2007 1:55 pm 
Beginner
Beginner

Joined: Wed May 16, 2007 7:12 am
Posts: 41
Location: London
Sorry, I had this in mind. You could apply a default filter condition not equals

http://www.hibernate.org/hib_docs/reference/en/html/filters.html

_________________
Dinesh Mahadevan

Visit me at http://www.yelani.com/


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 18, 2007 2:43 pm 
Newbie

Joined: Tue Dec 18, 2007 12:18 pm
Posts: 4
Location: Madrid
is the filter automatically applied??

I mean, what i need is to apply the filter always, when the list is retrieved...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 19, 2007 8:24 am 
Beginner
Beginner

Joined: Wed May 16, 2007 7:12 am
Posts: 41
Location: London
The default filter is always automatically applied.
I can see that is the case while using loadAll(class) method.

_________________
Dinesh Mahadevan

Visit me at http://www.yelani.com/


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 19, 2007 8:34 am 
Newbie

Joined: Tue Dec 18, 2007 12:18 pm
Posts: 4
Location: Madrid
I just added
Code:
<list where=""/>
to fix this.

Thanks for your help!!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 19, 2007 9:41 am 
Beginner
Beginner

Joined: Wed May 16, 2007 7:12 am
Posts: 41
Location: London
Glad to be of service, and thanks for the credit

_________________
Dinesh Mahadevan

Visit me at http://www.yelani.com/


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 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.