-->
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: Best practice how to search for similar entities at a time?
PostPosted: Sat Aug 28, 2010 11:29 am 
Newbie

Joined: Sat Aug 28, 2010 10:37 am
Posts: 6
Hi,

my entities and associations look like this:
Code:
@Entity
@Indexed
class TemplateValue {
@Id
Integer id;

@ManyToOne
@IndexedEmbedded
Template template;

@ManyToOne
@IndexedEmbedded
Property property;

@OneToMany
@IndexedEmbedded
Set<Value> values;
...
}

@Entity
@Indexed
class ConfigurationValue {
@Id
Integer id;

@ManyToOne
@IndexedEmbedded
Configuration configuration;

@ManyToOne
@IndexedEmbedded
Property property;

@OneToMany
@IndexedEmbedded
Set<Value> values;
...
}

@Entity
class Template {
@Id
Integer id;

@Field
String name;

@ManyToOne
@ContainedIn
Set<TemplateValue> values;
...
}

@Entity
class Value {
@Id
Integer id;

@Field
String value;

@ManyToOne
@ContainedIn
Set<TemplateValue> templateValues;

@ManyToOne
@ContainedIn
Set<ConfigurationValue> configurationValues;

String type;
...
}

The entities Property and Configuration look like Template and thus are not listed.

Now, the use case is to to search for both, TemplateValue and ConfigurationValue, at a time and to show the merged results in frontend. Therefor, wrapper objects are used which have a flag indicating whether TemplateValue or ConfigurationValue is being wrapped.

At the moment, I'm first querying TemplateValue and then the ConfigurationValue index to finally build a collection of wrapper objects mentioned above.

I wonder if there isn't an easier way to accomplish this. Any idea?

One further thing I can think of would be to provide a database view, map it to an entity and use this one as a sole index...


Thanks in advance!


Top
 Profile  
 
 Post subject: Re: Best practice how to search for similar entities at a time?
PostPosted: Mon Aug 30, 2010 8:59 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Did you see that FullTextSession.createFullTextQuery takes a vararg parameter Class<?> entities? Effectively you can specified which entities/indexes should be searched. So in your case you might want to call:

Code:
fulltextQuery = fullTextSession.createFullTextQuery(luceneQuery,  TemplateValue.class, ConfigurationValue.class);
...


--Hardy


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.