-->
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.  [ 2 posts ] 
Author Message
 Post subject: Hibernate Search associated objects question
PostPosted: Tue Apr 10, 2007 6:53 am 
Newbie

Joined: Mon Nov 13, 2006 11:22 am
Posts: 5
Location: Graz / Austria
hi!

with the following code i can find the telefonnumbers for a given person name.
(person.name is added to the telefon index)
is there a way to reverse this? e.g. find the person for a given telefonnumber?
(add telefon.telefon to the person index)

Code:
@Entity
@Indexed
public class Person implements java.io.Serializable
{
   @Id
   @GeneratedValue
   @DocumentId
   private long id;
   
   @Field(index=Index.TOKENIZED)
   private String name;
   
   @ContainedIn
   @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "person")
   private Set<Telefon> telefons = new HashSet<Telefon>(0);
   
   ...
   
}

@Entity
@Indexed
public class Telefon implements java.io.Serializable
{
   @Id
   @GeneratedValue
   @DocumentId
   private long id;
   
   @Field(index=Index.TOKENIZED)
   private String telefon;
   
   @IndexedEmbedded
   @ManyToOne(fetch = FetchType.LAZY)
   @JoinColumn(name = "personid")
   private Person person;
   
   ...
}


thx!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 12, 2007 5:26 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You just need to index Telefon (which you are doing).
Do the query to retrieve the matching telefon
and do telefon.getPerson() :-)

_________________
Emmanuel


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