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!