-->
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.  [ 3 posts ] 
Author Message
 Post subject: Querying null fields
PostPosted: Wed Feb 24, 2010 2:31 pm 
Newbie

Joined: Wed Feb 24, 2010 1:53 pm
Posts: 2
Hi,

I have a field that in certain cases is persisted with null value. I don't know how I can create a query for the case that this field is null.

I have two classes, Group and Person in a many to many relationship.
I don't know how to create a search for the case of person without Group

A simplified domain model is:

Person
@Field(index=Index.TOKENIZED, store=Store.NO)
private String name;
@ManyToMany
@IndexedEmbedded
private Set<Grupo> groups = new HashSet<Grupo>();

Groups
@Field(index = Index.TOKENIZED, store = Store.YES)
private Long id;
@ContainedIn
@ManyToMany
private Set<Person> persons = new HashSet<Person>();

For the search of Person who have a group I've just included a clause for the group Id in the lucene query.
My problem is persons without a group.

Thanks


Top
 Profile  
 
 Post subject: Re: Querying null fields
PostPosted: Thu Feb 25, 2010 4:17 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
hello,
there's no concept of null in Lucene, you'll have to make sure a marker keyword is indexed and searched on exact matches of you keyword.
You can create a fake group or add an appropriate fieldBridge.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: Querying null fields
PostPosted: Thu Feb 25, 2010 2:17 pm 
Newbie

Joined: Wed Feb 24, 2010 1:53 pm
Posts: 2
Hello,
Thank you!
I've implemented a fake boolean field to store this information.


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