-->
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: Need help in writing a search query
PostPosted: Mon Dec 13, 2010 8:48 pm 
Newbie

Joined: Sat Feb 14, 2009 7:49 am
Posts: 8
I'm having problems executing a search on my domain model. I have 3 entities Person, Event and PartnerOfEvent. They are mapped like this:
Code:
@Indexed
public class Person {
     private String name;
     @OneToMany(mappedBy = "partner", cascade = CascadeType.ALL)
     private Set<PartnerOfEvent> partnerOfEvents;
}

public class PartnerOfEvent {
    @ManyToOne
    @JoinColumn(name = "Partner_Id")
    protected Person partner;
    @ManyToOne(cascade = CascadeType.ALL)
    @JoinColumn(name = "Event_Id", nullable = false)
    protected Event event;
}

public class Event {
    @OneToMany(mappedBy = "event")
    protected Set<PartnerOfEvent> partnersOf;
}


I want to store all this information in the index. Then I want to be able to write a search query that retrieves a Person by its partners name. That would translate into something like partnerOfEvents.event.partnersOf.partner.name:John. But I cannot map my classes so that a query like this is supported. Can map my classes in order to write a query like this? Is there a way to retrieve a person by its partner's names given my domain model?


Top
 Profile  
 
 Post subject: Re: Need help in writing a search query
PostPosted: Tue Dec 14, 2010 6:19 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Besides the fact that I would recommend you to rethink your model in general, have you actually tried added @IndexedEmbedded? Also wouldn't a name for a person's partner not use partnerOfEvents.partner.name:John?


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.